Skip to content

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

@mattador1

Description

@mattador1

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"
}


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