Skip to content

Read snarkjs proof file into Rust code #16

Description

@ppoliani

@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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions