mirror of
https://github.com/arnaucube/gnark-plonky2-verifier.git
synced 2026-01-12 09:01:32 +01:00
Compiles
This commit is contained in:
@@ -88,8 +88,8 @@ func Sha512compression(api frontend.API, hin, inp []frontend.Variable) ([]fronte
|
||||
// t2[t].c[k] <== c[t][k];
|
||||
// }
|
||||
|
||||
sume := BinSum(d[t], t1)
|
||||
suma := BinSum(t1, t2)
|
||||
sume := BinSum(api, d[t][:], t1)
|
||||
suma := BinSum(api, t1, t2)
|
||||
// for (k=0; k<64; k++) {
|
||||
// sume[t].in[0][k] <== d[t][k];
|
||||
// sume[t].in[1][k] <== t1[t].out[k];
|
||||
@@ -161,7 +161,7 @@ func Sha512compression(api frontend.API, hin, inp []frontend.Variable) ([]fronte
|
||||
|
||||
var fsum [8][]frontend.Variable
|
||||
for i := 0; i < 8; i++ {
|
||||
fsum[i] = BinSum(fsum_in[i][0], fsum_in[i][1])
|
||||
fsum[i] = BinSum(api, fsum_in[i][0][:], fsum_in[i][1][:])
|
||||
}
|
||||
|
||||
var out [512]frontend.Variable
|
||||
|
||||
37
sha512/sha_test.go
Normal file
37
sha512/sha_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package sha512
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/consensys/gnark/frontend"
|
||||
"github.com/consensys/gnark/test"
|
||||
)
|
||||
|
||||
type Sha512Circuit struct {
|
||||
in []frontend.Variable `gnark:"in"`
|
||||
out []frontend.Variable `gnark:"out"`
|
||||
}
|
||||
|
||||
func (circuit *Sha512Circuit) Define(api frontend.API) error {
|
||||
res := Sha512(api, circuit.in)
|
||||
for i := 0; i < 512; i++ {
|
||||
api.AssertIsEqual(res[i], circuit.out[i])
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
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")),
|
||||
},
|
||||
}
|
||||
err := test.IsSolved(&circuit, &witness, testCurve.ScalarField())
|
||||
assert.NoError(err)
|
||||
}
|
||||
|
||||
var testCurve = ecc.BN254
|
||||
@@ -11,7 +11,12 @@ func SigmaPlus512(api frontend.API, in2, in7, in15, in16 []frontend.Variable) ([
|
||||
sigma1 := SmallSigma512(api, in2, 19, 61, 6)
|
||||
sigma0 := SmallSigma512(api, in15, 1, 8, 7)
|
||||
|
||||
return BinSum(api, sigma1, in7, sigma0, in16)
|
||||
inter := BinSum(api, sigma1, in7, sigma0, in16)
|
||||
var out [64]frontend.Variable
|
||||
for k := 0; k < 64; k++ {
|
||||
out[k] = inter[k]
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user