From 5bb4de69bba94202fcbd6010f41cdcc7ff839732 Mon Sep 17 00:00:00 2001 From: Jacob Jackson Date: Tue, 4 Oct 2022 17:16:50 +0000 Subject: [PATCH] get test running --- sha512/binsum.go | 2 -- sha512/sha_test.go | 28 ++++++++++++++++++++-------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/sha512/binsum.go b/sha512/binsum.go index 029761e..3c4ef60 100644 --- a/sha512/binsum.go +++ b/sha512/binsum.go @@ -1,7 +1,6 @@ package sha512 import ( - "fmt" "math/big" "github.com/consensys/gnark/backend/hint" "github.com/consensys/gnark/frontend" @@ -106,7 +105,6 @@ func BinSum(api frontend.API, args ...[]frontend.Variable) ([]frontend.Variable) v.And(v, big.NewInt(1)) outputs[i] = v } - fmt.Println(ops, n, nout, inputs, outputs) return nil } diff --git a/sha512/sha_test.go b/sha512/sha_test.go index fe567fb..78a142d 100644 --- a/sha512/sha_test.go +++ b/sha512/sha_test.go @@ -1,7 +1,6 @@ package sha512 import ( - "math/big" "testing" "github.com/consensys/gnark/frontend" @@ -23,15 +22,28 @@ func (circuit *Sha512Circuit) Define(api frontend.API) error { func TestSha512(t *testing.T) { assert := test.NewAssert(t) - circuit := OnCurveTest[Ed25519, Ed25519Scalars]{} - witness := OnCurveTest[Ed25519, Ed25519Scalars]{ - P: AffinePoint[Ed25519]{ - X: emulated.NewElement[Ed25519](newBigInt("216936D3CD6E53FEC0A4E231FDD6DC5C692CC7609525A7B2C9562D608F25D51A")), - Y: emulated.NewElement[Ed25519](newBigInt("6666666666666666666666666666666666666666666666666666666666666658")), - }, + in := toBytes("Succinct Labs") + out := toBytes("503ace098aa03f6feec1b5df0a38aee923f744a775508bc81f2b94ad139be297c2e8cd8c44af527b5d3f017a7fc929892c896604047e52e3f518924f52bff0dc") + circuit := Sha512Circuit { + in: toVariables(make([]byte, len(in))), + out: toVariables(make([]byte, len(out))), + } + witness := Sha512Circuit { + in: toVariables(in), + out: toVariables(out), } err := test.IsSolved(&circuit, &witness, testCurve.ScalarField()) assert.NoError(err) } -var testCurve = ecc.BN254 +func toVariables(arr []byte) []frontend.Variable { + result := make([]frontend.Variable, len(arr)) + for i, v := range arr { + result[i] = v + } + return result +} + +func toBytes(s string) []byte { + return []byte(s) +}