add verifyProof overload that accepts a single byte buffer of snark proof params
This commit is contained in:
parent
f2e5bc56b3
commit
869181cfaf
6
cli.js
6
cli.js
@ -446,7 +446,7 @@ function generateVerifier_original(verificationKey) {
|
|||||||
|
|
||||||
// The points
|
// The points
|
||||||
|
|
||||||
template = template.replace("<%vk_input_length%>", (verificationKey.IC.length-1).toString());
|
template = template.replace(/<%vk_input_length%>/g, (verificationKey.IC.length-1).toString());
|
||||||
template = template.replace("<%vk_ic_length%>", verificationKey.IC.length.toString());
|
template = template.replace("<%vk_ic_length%>", verificationKey.IC.length.toString());
|
||||||
let vi = "";
|
let vi = "";
|
||||||
for (let i=0; i<verificationKey.IC.length; i++) {
|
for (let i=0; i<verificationKey.IC.length; i++) {
|
||||||
@ -488,7 +488,7 @@ function generateVerifier_groth(verificationKey) {
|
|||||||
|
|
||||||
// The points
|
// The points
|
||||||
|
|
||||||
template = template.replace("<%vk_input_length%>", (verificationKey.IC.length-1).toString());
|
template = template.replace(/<%vk_input_length%>/g, (verificationKey.IC.length-1).toString());
|
||||||
template = template.replace("<%vk_ic_length%>", verificationKey.IC.length.toString());
|
template = template.replace("<%vk_ic_length%>", verificationKey.IC.length.toString());
|
||||||
let vi = "";
|
let vi = "";
|
||||||
for (let i=0; i<verificationKey.IC.length; i++) {
|
for (let i=0; i<verificationKey.IC.length; i++) {
|
||||||
@ -529,7 +529,7 @@ function generateVerifier_kimleeoh(verificationKey) {
|
|||||||
|
|
||||||
// The points
|
// The points
|
||||||
|
|
||||||
template = template.replace("<%vk_input_length%>", (verificationKey.IC.length-1).toString());
|
template = template.replace(/<%vk_input_length%>/g, (verificationKey.IC.length-1).toString());
|
||||||
template = template.replace("<%vk_ic_length%>", verificationKey.IC.length.toString());
|
template = template.replace("<%vk_ic_length%>", verificationKey.IC.length.toString());
|
||||||
let vi = "";
|
let vi = "";
|
||||||
for (let i=0; i<verificationKey.IC.length; i++) {
|
for (let i=0; i<verificationKey.IC.length; i++) {
|
||||||
|
@ -220,4 +220,9 @@ contract Verifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function verifyProof(bytes calldata proof, uint[<%vk_input_length%>] calldata inputs) external view returns (bool r) {
|
||||||
|
// solidity does not support decoding uint[2][2] yet
|
||||||
|
(uint[2] memory a, uint[2] memory b1, uint[2] memory b2, uint[2] memory c) = abi.decode(proof, (uint[2], uint[2], uint[2], uint[2]));
|
||||||
|
return verifyProof(a, [b1, b2], c, inputs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,4 +211,9 @@ contract Verifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function verifyProof(bytes calldata proof, uint[<%vk_input_length%>] calldata inputs) external view returns (bool r) {
|
||||||
|
// solidity does not support decoding uint[2][2] yet
|
||||||
|
(uint[2] memory a, uint[2] memory b1, uint[2] memory b2, uint[2] memory c) = abi.decode(proof, (uint[2], uint[2], uint[2], uint[2]));
|
||||||
|
return verifyProof(a, [b1, b2], c, inputs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,21 @@ contract Verifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function verifyProof(bytes calldata proof, uint[<%vk_input_length%>] calldata inputs) external view returns (bool r) {
|
||||||
|
// solidity does not support decoding uint[2][2] yet
|
||||||
|
(
|
||||||
|
uint[2] memory a,
|
||||||
|
uint[2] memory a_p,
|
||||||
|
uint[2] memory b1,
|
||||||
|
uint[2] memory b2,
|
||||||
|
uint[2] memory b_p,
|
||||||
|
uint[2] memory c,
|
||||||
|
uint[2] memory c_p,
|
||||||
|
uint[2] memory h,
|
||||||
|
uint[2] memory k
|
||||||
|
) = abi.decode(proof, (uint[2], uint[2], uint[2], uint[2], uint[2], uint[2], uint[2], uint[2], uint[2]));
|
||||||
|
return verifyProof(a, a_p, [b1, b2], b_p, c, c_p, h, k, inputs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user