From 75bb37e7e66eecb7f1eee6154df99f648669940b Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 23 Jan 2024 23:34:05 +0000 Subject: [PATCH 1/5] add small test --- common/common_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 common/common_test.go diff --git a/common/common_test.go b/common/common_test.go new file mode 100644 index 0000000..09e55e2 --- /dev/null +++ b/common/common_test.go @@ -0,0 +1,45 @@ +package common_test + +import ( + "bytes" + "encoding/hex" + "testing" + + "github.com/crate-crypto/go-ipa/common" +) + +func TestJavaRegressionOneEndian(t *testing.T) { + hexStr := "f6e31f7a565a390b48fdd24569ac10d43562d19de37ea951c7f9f250a339d059" + byteArray := hexStrToBytes(hexStr) + _scalar, err := common.ReadScalar(bytes.NewReader(byteArray)) + if err != nil { + t.Fatalf(err.Error()) + } + _ = _scalar +} +func TestJavaRegressionOtherEndian(t *testing.T) { + hexStr := "f6e31f7a565a390b48fdd24569ac10d43562d19de37ea951c7f9f250a339d059" + byteArray := hexStrToBytes(hexStr) + reverse(byteArray) + _scalar, err := common.ReadScalar(bytes.NewReader(byteArray)) + if err != nil { + t.Fatalf(err.Error()) + } + _ = _scalar +} + +func reverse(data []byte) { + for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 { + data[i], data[j] = data[j], data[i] + } +} + +func hexStrToBytes(numStr string) []byte { + + // Use Hex package + byteArray, err := hex.DecodeString(numStr) + if err != nil { + panic(err) + } + return byteArray +} From ca2d05ad4261a001e7bdae89cccdb5dc0c5a5af6 Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Tue, 23 Jan 2024 23:38:17 +0000 Subject: [PATCH 2/5] make it more obvious that both tests have non-canonical inputs --- common/common_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/common_test.go b/common/common_test.go index 09e55e2..328c9f2 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -12,8 +12,9 @@ func TestJavaRegressionOneEndian(t *testing.T) { hexStr := "f6e31f7a565a390b48fdd24569ac10d43562d19de37ea951c7f9f250a339d059" byteArray := hexStrToBytes(hexStr) _scalar, err := common.ReadScalar(bytes.NewReader(byteArray)) - if err != nil { - t.Fatalf(err.Error()) + + if err == nil { + t.Fatalf("expected an error because the scalar is too large") } _ = _scalar } @@ -22,8 +23,8 @@ func TestJavaRegressionOtherEndian(t *testing.T) { byteArray := hexStrToBytes(hexStr) reverse(byteArray) _scalar, err := common.ReadScalar(bytes.NewReader(byteArray)) - if err != nil { - t.Fatalf(err.Error()) + if err == nil { + t.Fatalf("expected an error because the scalar is too large, even though we changed the endian") } _ = _scalar } From ff43c01a68ad188310936d651e44f2de554ba474 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Tue, 23 Jan 2024 23:38:58 +0000 Subject: [PATCH 3/5] Apply suggestions from code review --- common/common_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/common/common_test.go b/common/common_test.go index 328c9f2..b612c03 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -37,7 +37,6 @@ func reverse(data []byte) { func hexStrToBytes(numStr string) []byte { - // Use Hex package byteArray, err := hex.DecodeString(numStr) if err != nil { panic(err) From 005eb2426c558225bfde8200312b513178dab4fd Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Wed, 24 Jan 2024 00:02:06 +0000 Subject: [PATCH 4/5] Add new test file --- common/common_test.go | 54 ++++++++ genesis_lvl1_commits.json | 263 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 317 insertions(+) create mode 100644 genesis_lvl1_commits.json diff --git a/common/common_test.go b/common/common_test.go index b612c03..c7c9d1c 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -3,9 +3,15 @@ package common_test import ( "bytes" "encoding/hex" + "encoding/json" + "fmt" + "io" + "os" "testing" + "github.com/crate-crypto/go-ipa/bandersnatch/fr" "github.com/crate-crypto/go-ipa/common" + "github.com/crate-crypto/go-ipa/ipa" ) func TestJavaRegressionOneEndian(t *testing.T) { @@ -29,6 +35,54 @@ func TestJavaRegressionOtherEndian(t *testing.T) { _ = _scalar } +type AutoGenerated []struct { + Frs []string `json:"frs"` + Expected string `json:"expected"` +} + +// genesis_lvl1_commitments.json was generated by serializing the scalars -1, -2,...,-256 +// The scalars are encoded in big-endian format for now, so that the java code does not need +// much change. +func TestNewGenesisLvl1Commit(t *testing.T) { + // Open the JSON file + jsonFile, err := os.Open("../genesis_lvl1_commits.json") + if err != nil { + t.Fail() + fmt.Println(err) + } + defer jsonFile.Close() + + // Read the opened jsonFile as a byte array. + byteArray, _ := io.ReadAll(jsonFile) + + // We initialize our struct + var testData AutoGenerated + json.Unmarshal(byteArray, &testData) + + ipaConf, err := ipa.NewIPASettings() + if err != nil { + t.Fatalf("creating IPA settings: %s", err) + } + + scalars := make([]fr.Element, common.VectorLength) + + serializedScalars := testData[0].Frs + for i := 0; i < common.VectorLength; i++ { + scalarBytes, err := hex.DecodeString(serializedScalars[i]) + if err != nil { + t.Fatalf("decoding scalar bytes: %s", err) + } + reverse(scalarBytes) // Reverse bytes so we use LE + scalars[i].SetBytesLECanonical(scalarBytes) + } + comm := ipaConf.Commit(scalars) + commBytes := comm.Bytes() + commHexStr := hex.EncodeToString(commBytes[:]) + if commHexStr != testData[0].Expected { + t.Fatalf("expected %s, got %s", testData[0].Expected, commHexStr) + } +} + func reverse(data []byte) { for i, j := 0, len(data)-1; i < j; i, j = i+1, j-1 { data[i], data[j] = data[j], data[i] diff --git a/genesis_lvl1_commits.json b/genesis_lvl1_commits.json new file mode 100644 index 0000000..1fd7c62 --- /dev/null +++ b/genesis_lvl1_commits.json @@ -0,0 +1,263 @@ +[ + { + "frs": [ + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7e0", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7df", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7de", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7dd", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7dc", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7db", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7da", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d9", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d8", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d7", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d6", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d5", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d4", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d3", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d2", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d1", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7d0", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7cf", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ce", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7cd", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7cc", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7cb", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ca", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c9", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c8", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c7", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c6", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c5", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c4", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c3", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c2", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c1", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7c0", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7bf", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7be", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7bd", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7bc", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7bb", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ba", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b9", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b8", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b7", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b6", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b5", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b4", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b3", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b2", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b1", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7b0", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7af", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ae", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ad", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ac", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7ab", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7aa", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a9", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a8", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a7", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a6", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a5", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a4", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a3", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a2", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a1", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e7a0", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e79f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e79e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e79d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e79c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e79b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e79a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e799", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e798", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e797", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e796", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e795", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e794", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e793", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e792", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e791", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e790", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e78f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e78e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e78d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e78c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e78b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e78a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e789", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e788", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e787", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e786", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e785", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e784", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e783", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e782", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e781", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e780", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e77f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e77e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e77d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e77c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e77b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e77a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e779", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e778", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e777", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e776", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e775", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e774", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e773", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e772", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e771", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e770", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e76f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e76e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e76d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e76c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e76b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e76a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e769", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e768", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e767", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e766", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e765", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e764", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e763", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e762", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e761", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e760", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e75f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e75e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e75d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e75c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e75b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e75a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e759", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e758", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e757", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e756", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e755", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e754", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e753", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e752", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e751", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e750", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e74f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e74e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e74d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e74c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e74b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e74a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e749", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e748", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e747", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e746", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e745", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e744", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e743", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e742", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e741", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e740", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e73f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e73e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e73d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e73c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e73b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e73a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e739", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e738", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e737", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e736", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e735", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e734", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e733", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e732", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e731", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e730", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e72f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e72e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e72d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e72c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e72b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e72a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e729", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e728", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e727", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e726", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e725", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e724", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e723", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e722", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e721", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e720", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e71f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e71e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e71d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e71c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e71b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e71a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e719", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e718", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e717", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e716", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e715", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e714", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e713", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e712", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e711", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e710", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e70f", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e70e", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e70d", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e70c", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e70b", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e70a", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e709", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e708", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e707", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e706", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e705", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e704", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e703", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e702", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e701", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e700", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6ff", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6fe", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6fd", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6fc", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6fb", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6fa", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f9", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f8", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f7", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f6", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f5", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f4", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f3", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f2", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f1", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6f0", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6ef", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6ee", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6ed", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6ec", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6eb", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6ea", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e9", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e8", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e7", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e6", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e5", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e4", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e3", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e2", + "1cfb69d4ca675f520cce760202687600ff8f87007419047174fd06b52876e6e1" + ], + "expected": "4aa25f88fc65a75a1a490f2579164ef2a2383256fe5742767f3fa72ac7e57344" + } +] \ No newline at end of file From e0789a5807368ae5f31e82c9a139e4d43545540a Mon Sep 17 00:00:00 2001 From: Kevaundray Wedderburn Date: Wed, 24 Jan 2024 00:06:30 +0000 Subject: [PATCH 5/5] use ReadScalar --- common/common_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/common_test.go b/common/common_test.go index c7c9d1c..a258da2 100644 --- a/common/common_test.go +++ b/common/common_test.go @@ -73,7 +73,11 @@ func TestNewGenesisLvl1Commit(t *testing.T) { t.Fatalf("decoding scalar bytes: %s", err) } reverse(scalarBytes) // Reverse bytes so we use LE - scalars[i].SetBytesLECanonical(scalarBytes) + scalars_i, err := common.ReadScalar(bytes.NewReader(scalarBytes)) + if err != nil { + t.Fatalf("reading scalar: %s", err) + } + scalars[i] = *scalars_i } comm := ipaConf.Commit(scalars) commBytes := comm.Bytes()