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

wrong order of proof parameters for 2-d array parameter #491

Open
mattador1 opened this issue Apr 22, 2024 · 0 comments
Open

wrong order of proof parameters for 2-d array parameter #491

mattador1 opened this issue Apr 22, 2024 · 0 comments

Comments

@mattador1
Copy link

mattador1 commented Apr 22, 2024

Hi,

Testing so I noticed, when I generate a proof.json below

When I generate solidity contract parameters for following method:

function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[2] calldata _pubSignals) public view returns (bool)

It seems proof parameters for this method when dealing with matrix, so [2][2] input need to be provided in reverse order.
Which means for example input is to _pB parameter should be [
[pi_b[0][1], pi_b[0][0]],
[pi_b[1][1], pi_b[1][0]],
];

comparing to my expectation:

[
[pi_b[0][0], pi_b[0][1]],
[pi_b[1][0], pi_b[1][1]],
];

This was hard to detect as I was getting wrong result with verifyProof method, but off-chain verification with snarkjs verify was successful. Finally when I executed snarkjs generatecall in terminal I saw that for matrix parameters order was wrong.
Is this expected that in proof.json for 2-d arrays order is not aligned with generatecall command ?
Note that 1-d array are aligned.

{
 "pi_a": [
  "14428826828042518324421422329988789856536657961271818745744806287476079921289",
  "18527209694571787876201849047404494301911717518646759571914981408485501733051",
  "1"
 ],
 "pi_b": [
  [
   "3742075560985712714714310078460446264618902779421483336520317354354312740707",
   "19592035976815060919412508604491826305547281176496378004482106996774768884011"
  ],
  [
   "10700985629708337308865894830113721364551332949994556280532145859554546012019",
   "17771119755473848230314188751485183953296624294987265914597848962635484398259"
  ],
  [
   "1",
   "0"
  ]
 ],
 "pi_c": [
  "13255040454789652847815597024280275348398244740182333801755579280354131884939",
  "2722691790381909141322293529200822146133554412144714540985245589680922123124",
  "1"
 ],
 "protocol": "groth16",
 "curve": "bn128"
}


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