pedersen: canonicalize DST to PEDERSEN_{G,H}_V1 in DeterministicGenerators

Lines 84/90 of pedersen.go still used legacy LUX_PEDERSEN_{G,H}. Sweep #196
left them unchanged; commitments produced by DeterministicGenerators were
not byte-equal to C++/Metal/CUDA/WGSL outputs. Replace with the canonical
PEDERSEN_G_V1 / PEDERSEN_H_V1 strings (matches NewGenerators at lines
50/54 and the seeded path at PEDERSEN_SEEDED_GEN_V1).

Regenerate the KAT golden vectors in pedersen_test.go for the new DSTs;
seed string "lux-pedersen-kat-v1" is content (passed as the seed bytes),
not a DST, so left intact. Cross-checks against the C++ canonical golden
(G=c563aa8a..0c6b7, H=e9ebf439..0f3186 for incrementing seed) continue
to pass via pedersen_seed_test.go.

Tests pass: go test ./pedersen/... -count=1 -short -race -timeout 30s.
This commit is contained in:
Hanzo AI
2026-04-28 08:23:40 -07:00
parent 59f69a50ab
commit d3dee505b0
2 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -81,13 +81,13 @@ func DeterministicGenerators(seed []byte) (*Generators, error) {
digest := h.Sum(nil)
return bn254.HashToG1(digest, dst)
}
g, err := deriveOne(0, []byte("LUX_PEDERSEN_G"))
g, err := deriveOne(0, []byte("PEDERSEN_G_V1"))
if err != nil {
return nil, err
}
var h bn254.G1Affine
for c := uint32(1); c < 1024; c++ {
hp, err := deriveOne(c, []byte("LUX_PEDERSEN_H"))
hp, err := deriveOne(c, []byte("PEDERSEN_H_V1"))
if err != nil {
return nil, err
}
+14 -12
View File
@@ -19,23 +19,25 @@ const katSeed = "lux-pedersen-kat-v1"
// Format: m, r (uint64) -> hex of commit.RawBytes() (64 bytes uncompressed
// affine: x || y, big-endian).
//
// Generated once via /tmp/pdgen.go; any deviation in the byte-equal output
// of either Commit or DeterministicGenerators breaks this test loudly.
// Generators use the canonical brand-neutral DSTs PEDERSEN_G_V1 and
// PEDERSEN_H_V1 (matches C++/Metal/CUDA/WGSL canonical). Any deviation in
// the byte-equal output of either Commit or DeterministicGenerators breaks
// this test loudly.
var katCases = []struct {
m, r uint64
hex string
}{
{0x0, 0x0, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"},
{0x1, 0x0, "2310d50ca3158e269dc37815614edd42375c9a6f9c74f91a6378d8090c74e98c2783703587b324f031f528caef154a1612cbcd8a5e56e4b9e48b0fc235a249ad"},
{0x0, 0x1, "1832d62bfd4f05533bac846e2e899b78b5dd985a3f80438adab0b5d7ef77ab420d2263bda11d9cb874eb5afce16bb6a3d5d9685a0da11c6e2fcf76dd9aba361a"},
{0x1, 0x1, "09444d23ca0c39d550f69b46291c04ed8acbe83f9538497df61b4abc5b83650d26b590b491bac2b0c7d7e7504dcaa9cb9747492de57178ec77cfe7a1ab4d58e0"},
{0x7, 0xd, "041a9769b433550c22ae82929c2c6e97bc384f58527d1e04257879e9bd43f3dd1cf90b789b4ea6b8720b5190df8770b6a058bfe47abcfc4ff81baf8a94d2ed73"},
{0x5, 0xb, "09d0f5e13cec7feef92fb061025e4d1b04516bc97a33c079c3b35958e905d56b01282228cdc98d0a7f4ba3e20de6d021fa2a6e3aa3e7e2ad1cfb9081e9eb0149"},
{0xdeadbeef, 0xcafebabe, "0e5218d479935a1122d73ca4da24913fa2902c16ec8f0b41520945054945e409055967e503083e0ef918cfc5a16d91138b526f97df01b7bb1aeaf9fc2b39bcc9"},
{0x1, 0xffffffffffffffff, "0a4eda06d99f3fccbf4b0b22326abe9ba08ee4de5d102275353e3a7101712c8e1aff88e50bb4ea4a5d24789df8bc803d8d202c0bcdd6e59ccf9c6f33bf7b69dd"},
{0xffffffffffffffff, 0x1, "297f6e6ae77d1636e06508bc4443544d411faab1d6bc5801498dea30047192101bdc0e255c38b1a96e8d668d5f6d6620bab6c5c2134cd505771f80198eaf35c9"},
{0x2a, 0x6c1, "08ffa127da11795588ec290e2fc944902bf86f11078abf16a63a7e786b38f1aa1667ff1bcbd1bffdd6d3e6836986ff84b213d705e97a47ae0d3d94a245f98224"},
{0x499602d2, 0x24cb016ea, "0c8c93752e15f732ad39af50dbfb0a6983da1d4bf0a4cf62181acb9b5980b05b237dc1d486d64d7cd42f02c320d6d08d5787f7925cb59358e39c8aad8b282287"},
{0x1, 0x0, "1690bf214b3b458ac68ff8ad15298b2c0757eb3c908bd196d20a1a28032749bd2142beee737e4802be84e65551e57ad829fc3084a712503e38c09a171b8f7af8"},
{0x0, 0x1, "11ed080cfc66661d0256d269e66fba661924d0e95c02763b6a9c3c848f8eb40c07682429c46304a6f09495a4036e794669f91858d53ac89c06b0db6bbebf8907"},
{0x1, 0x1, "046bf2f0fd48f5378636781d86b78ba9dfecdbc6fedaa15feb0caf59cd10f65e07db066137fec1f80c8eff58e6968dec57149f293b7e8e15ebfee303b5d9dabf"},
{0x7, 0xd, "1fd7362ee9fdb2fe14708eaeb359cf0790e05011ea0f75eff0950982b0fb1bbe07a6a565ea9db0073d3d057d4f643c985de3acf1639853e7800347979e35f95e"},
{0x5, 0xb, "227f1cbf8905b2b56628a794770047335d1902ce2a1015deb9727099570a067923ccb9407067a34a178926e5627addf4262cf5c235902b78acf0b2119f8a3bff"},
{0xdeadbeef, 0xcafebabe, "2151496276fae67477633528c8e1b29b144526713297da2fb6b58f64afb24295162abca28ca2d2055910e3d852b5edb3611055bccca66b3b7f372e2d25312f8d"},
{0x1, 0xffffffffffffffff, "2cb8a0a4f69fdabbf027456efa83963005a1b5347069bb5a6832ae8473ca39341a898c5bb4842c504b3d6030e5593566af58088bdb950de9d78db1096df220e2"},
{0xffffffffffffffff, 0x1, "2bf9365670f2dc77b54c01178714048abdd75cb6c5bd77b8a1180e28964cf8cd044540b44128e0bb43a73e68fb29bee84f8e7ff1324bd551181c1e8a4a8d3da5"},
{0x2a, 0x6c1, "146d5342e3acc1ce2a6b83d879a876c063a0a2ad8ce0d3c27efd624c9f33accb05b8c5f8e773ee4d7082ad7c103c639abcae61327d57cdb9d0d1f4acb0eeb566"},
{0x499602d2, 0x24cb016ea, "12778b903c6ce3846d58ffbeee0e173ba26b6ac95c8987001e6fa9a37f114e2f2a5c6eef88c60deb4d89bb11fdd769dafd0b0a19e2e6bc647f620bcc2bdaf92a"},
}
func TestKATs(t *testing.T) {