Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read snarkjs proof file into Rust code #16

Open
ppoliani opened this issue Feb 28, 2025 · 0 comments
Open

Read snarkjs proof file into Rust code #16

ppoliani opened this issue Feb 28, 2025 · 0 comments

Comments

@ppoliani
Copy link

@ananas-block is there a simple example of how we can compare the proof.json created via snarkjs into the values required by this library.

More specifically, the circom tool set allows you to run snarkjs groth16 prove which creates a json for the proof. That file has the following fields

  • pi_a: array with 3 bigInts (the third one is the number 1)
  • pi_b: nested array of bigInts
  • pi_c: array with 3 bigInts (the third one is the number 1)

Have tried multiple combinations but I can make the verifier verify successfully.

Let me share an example of such json file:

{
 "pi_a": [
  "7009850523380053417559359838274166345753459194827739539298258909727627620654",
  "8548305476914007287325069713428341320454044376283723944078898404773884726316",
  "1"
 ],
 "pi_b": [
  [
   "15892179406650945016703084011668441157894244396481426517502514759790693299090",
   "12656884454551498574200568284978773565242679009778067861652394211967848934857"
  ],
  [
   "7337817382302232780034223753908236778025711865739231129080101998424953224332",
   "9448638272149622936404627582112169394940750029902189763015703572300433784990"
  ],
  [
   "1",
   "0"
  ]
 ],
 "pi_c": [
  "2625468363450068209652280038415340055639418870448524270859981997692020323166",
  "1760889068094629347884977005056513991804173440921197754307899447129721200844",
  "1"
 ],
 "protocol": "groth16",
 "curve": "bn128"
}

Not sure how to convert those three values to value required by the Groth16Verifier

proof_a: &'a [u8; 64],
proof_b: &'a [u8; 128],
proof_c: &'a [u8; 64],

I've tried to follow the tests here

let proof_a: G1 = G1::deserialize_with_mode(
but to no avail. I literally used the exact same code.

The PROOF value here

pub const PROOF: [u8; 256] = [
is a byte array. So I believe if I can turn the above json into such a byte array then the verification should pass. But the question is how to do that in Rust?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant