mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-12 09:01:32 +01:00
get test running
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package sha512
|
package sha512
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"math/big"
|
"math/big"
|
||||||
"github.com/consensys/gnark/backend/hint"
|
"github.com/consensys/gnark/backend/hint"
|
||||||
"github.com/consensys/gnark/frontend"
|
"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))
|
v.And(v, big.NewInt(1))
|
||||||
outputs[i] = v
|
outputs[i] = v
|
||||||
}
|
}
|
||||||
fmt.Println(ops, n, nout, inputs, outputs)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package sha512
|
package sha512
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/big"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/consensys/gnark/frontend"
|
"github.com/consensys/gnark/frontend"
|
||||||
@@ -23,15 +22,28 @@ func (circuit *Sha512Circuit) Define(api frontend.API) error {
|
|||||||
|
|
||||||
func TestSha512(t *testing.T) {
|
func TestSha512(t *testing.T) {
|
||||||
assert := test.NewAssert(t)
|
assert := test.NewAssert(t)
|
||||||
circuit := OnCurveTest[Ed25519, Ed25519Scalars]{}
|
in := toBytes("Succinct Labs")
|
||||||
witness := OnCurveTest[Ed25519, Ed25519Scalars]{
|
out := toBytes("503ace098aa03f6feec1b5df0a38aee923f744a775508bc81f2b94ad139be297c2e8cd8c44af527b5d3f017a7fc929892c896604047e52e3f518924f52bff0dc")
|
||||||
P: AffinePoint[Ed25519]{
|
circuit := Sha512Circuit {
|
||||||
X: emulated.NewElement[Ed25519](newBigInt("216936D3CD6E53FEC0A4E231FDD6DC5C692CC7609525A7B2C9562D608F25D51A")),
|
in: toVariables(make([]byte, len(in))),
|
||||||
Y: emulated.NewElement[Ed25519](newBigInt("6666666666666666666666666666666666666666666666666666666666666658")),
|
out: toVariables(make([]byte, len(out))),
|
||||||
},
|
}
|
||||||
|
witness := Sha512Circuit {
|
||||||
|
in: toVariables(in),
|
||||||
|
out: toVariables(out),
|
||||||
}
|
}
|
||||||
err := test.IsSolved(&circuit, &witness, testCurve.ScalarField())
|
err := test.IsSolved(&circuit, &witness, testCurve.ScalarField())
|
||||||
assert.NoError(err)
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user