Conversation
17a6c1d to
dec3923
Compare
dec3923 to
d49c8f8
Compare
|
Precompiles done. Will update the stats in the corresponding issues. Will do rest of the precompiles later (modexp, SHA256, Blake, RipeMD) |
|
@yelhousni, ping |
yelhousni
left a comment
There was a problem hiding this comment.
LGTM! apart from the 08-bnpairing.go where I think the precompile does not return the pairing value but just checks it is equal to 1 (there is no support of Fp12 arithmetic in EVM).
We perform the check in the following packLimbs anyway. And the check there is more precise. We only need to figure out if we have variables or constants.
10b68ea to
59bb100
Compare
|
Resolved the comments. Right now didn't refactor ECRecover into If re-checking code, then I would particularly point to ECPair test. I tried to define a succeeding test. |
Suggested edit for ECPair test to use random points each time: diff --git a/std/evmprecompiles/bn_test.go b/std/evmprecompiles/bn_test.go
index ed1cfb24..74815562 100644
--- a/std/evmprecompiles/bn_test.go
+++ b/std/evmprecompiles/bn_test.go
@@ -133,9 +133,8 @@ func TestECMulCircuitFull(t *testing.T) {
}
type ecpairCircuit struct {
- P [2]sw_bn254.G1Affine
- Q [2]sw_bn254.G2Affine
- Expected sw_bn254.GTEl
+ P [2]sw_bn254.G1Affine
+ Q [2]sw_bn254.G2Affine
}
func (c *ecpairCircuit) Define(api frontend.API) error {
@@ -148,10 +147,19 @@ func (c *ecpairCircuit) Define(api frontend.API) error {
func TestECPairCircuitShort(t *testing.T) {
assert := test.NewAssert(t)
_, _, p1, q1 := bn254.Generators()
+
+ var u, v fr.Element
+ u.SetRandom()
+ v.SetRandom()
+
+ p1.ScalarMultiplication(&p1, u.BigInt(new(big.Int)))
+ q1.ScalarMultiplication(&q1, v.BigInt(new(big.Int)))
+
var p2 bn254.G1Affine
var q2 bn254.G2Affine
p2.Neg(&p1)
q2.Set(&q1)
+
err := test.IsSolved(&ecpairCircuit{}, &ecpairCircuit{
P: [2]sw_bn254.G1Affine{sw_bn254.NewG1Affine(p1), sw_bn254.NewG1Affine(p2)},
Q: [2]sw_bn254.G2Affine{sw_bn254.NewG2Affine(q1), sw_bn254.NewG2Affine(q2)},
|
|
@ivokub I applied the edit in the last commit + removed |
|
Should we merge this PR or wait for the remaining precompiles? |
Looks good, I'll merge. Rest of the precompiles takes a bit time and is less important, so can do in another PR. |
Closes #466.
Even if we have many primitives, then this PR is introducing tightly coupled circuits for using with EVM precompiles. The goal is that we can take verbatim precompile call arguments and return whatever implementations would return.
Still WIP, but starting a draft PR for discussions on interfaces etc. Need to fix #484 as with test engine right now get errors where shouldn't.
More specifically:
Tasks:
v). Need to polish the implementation and merge in gnark-crypto for better maintainability.