Consensys / gnark

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license
https://hackmd.io/@gnark
Apache License 2.0
1.43k stars 369 forks source link

BN254 Signature verification #535

Closed hussein-aitlahcen closed 1 year ago

hussein-aitlahcen commented 1 year ago

Hi,

I tried doing a simple BLS sig verification, using the BW6/BLS12377 I am able to generate a proof. On the other hand, on the develop branch, the same code is failing with BN254/BN254

Here is the code https://github.com/hussein-aitlahcen/dnarthk/blob/main/main.go

The log

~/dnarthk (main*) » go run main.go                                                                                130 ↵ hussein@nerded
Private key: cb1b49bc28bb6a76f305958ab33c271a
G2 Generator: E([10857046999023057135944570762232829481370756359578518086990519993285655852781+11559732032986387107991004021392285783925812861821192530917403151452391805634*u,8495653923123431417604973247489272438418190587263600148770280649306958101930+4082367875863433681332203403145435568316851327593401208105741076214120093531*u])
Public key: db6f931d760dfb2c46519779a3cd4036807722d828b92ca3f1a13d05e059a5e01df63da6eef100fe929f9aa49b931624626a776417c200f2fbee00689e73e2f8
Signature: a870fcfcb5617b69864549e7ab199746882b5fd6695421f40cb6f0e77f00a533
Compiling circuit...
11:56:19 INF gnark profiling enabled path=gnark.pprof
11:56:19 INF compiling circuit
11:56:19 INF parsed circuit inputs nbPublic=96 nbSecret=0
11:59:00 INF building constraint builder nbConstraints=27968503
11:59:27 INF gnark profiling disabled path=gnark.pprof
Setup groth16

Creating witness
Extracting public
Proving...
12:23:46 ERR error="unsatisfied constraint" backend=groth16 id=14035 nbConstraints=27968503
constraint #14035 is not satisfied: [assertIsEqual] 378854710029902890293054204364038659831688 == 371947698990354403993986810629589972368712
r1cs.(*builder).AssertIsEqual
    api_assertions.go:35
emulated.(*Field[...]).mul
    field_ops.go:195

Outside of the circuit, the direct PairingCheck is working. Am I missing something obvious here?

NOTE: Executed on MAC M1

hussein-aitlahcen commented 1 year ago

Looks like latest develop solved the issue

ivokub commented 1 year ago

Looks like latest develop solved the issue

Yep, it was #534. Thanks for reporting.