Compare commits

...

4 Commits

Author SHA1 Message Date
672b738d06 Set as specific tornado cash package 2023-07-21 04:37:52 -07:00
gozzy
733c435f66 update commit history 2022-09-08 23:18:33 +00:00
gozzy
ae4309e189 initialise 2022-08-28 18:41:09 +00:00
poma
869181cfaf add verifyProof overload that accepts a single byte buffer of snark proof params 2019-11-08 00:50:02 +03:00
5 changed files with 68 additions and 43 deletions

6
cli.js Executable file → Normal file
View File

@@ -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++) {

View File

@@ -1,42 +1,42 @@
{ {
"name": "snarkjs", "name": "@tornado/snarkjs",
"version": "0.1.20", "version": "0.1.20",
"description": "zkSNARKs implementation in JavaScript", "description": "zkSNARKs implementation in JavaScript",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "mocha" "test": "mocha"
}, },
"bin": { "bin": {
"snarkjs": "cli.js" "snarkjs": "cli.js"
}, },
"directories": { "directories": {
"templates": "templates" "templates": "templates"
}, },
"keywords": [ "keywords": [
"zksnark", "zksnark",
"zcash", "zcash",
"ethereum", "ethereum",
"zero", "zero",
"knowlage", "knowlage",
"cryptography", "cryptography",
"circuit" "circuit"
], ],
"author": "Jordi Baylina", "author": "Jordi Baylina",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/iden3/snarkjs.git" "url": "https://git.tornado.ws/tornado-packages/snarkjs"
}, },
"dependencies": { "dependencies": {
"big-integer": "^1.6.43", "big-integer": "^1.6.43",
"chai": "^4.2.0", "chai": "^4.2.0",
"escape-string-regexp": "^1.0.5", "escape-string-regexp": "^1.0.5",
"eslint": "^5.16.0", "eslint": "^5.16.0",
"keccak": "^2.0.0", "keccak": "^2.0.0",
"yargs": "^12.0.5" "yargs": "^12.0.5"
}, },
"devDependencies": { "devDependencies": {
"eslint-plugin-mocha": "^5.3.0", "eslint-plugin-mocha": "^5.3.0",
"mocha": "^5.2.0" "mocha": "^5.2.0"
} }
} }

View File

@@ -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);
}
} }

View File

@@ -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);
}
} }

View File

@@ -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);
}
} }