From 9757978d276ebce21e6f802662f1021cd6677765 Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Fri, 13 Dec 2019 13:18:16 -0800 Subject: [PATCH] new circomlib update --- circuits/merkleTree.circom | 2 +- contracts/MerkleTreeWithHistory.sol | 20 ++--- package-lock.json | 112 +--------------------------- package.json | 2 +- 4 files changed, 14 insertions(+), 122 deletions(-) diff --git a/circuits/merkleTree.circom b/circuits/merkleTree.circom index 18dad81..3a66975 100644 --- a/circuits/merkleTree.circom +++ b/circuits/merkleTree.circom @@ -6,7 +6,7 @@ template HashLeftRight() { signal input right; signal output hash; - component hasher = MiMCSponge(2, 220, 1); + component hasher = MiMCSponge(2, 1); hasher.ins[0] <== left; hasher.ins[1] <== right; hasher.k <== 0; diff --git a/contracts/MerkleTreeWithHistory.sol b/contracts/MerkleTreeWithHistory.sol index f264cd0..756e424 100644 --- a/contracts/MerkleTreeWithHistory.sol +++ b/contracts/MerkleTreeWithHistory.sol @@ -12,7 +12,7 @@ pragma solidity ^0.5.8; library Hasher { - function MiMCSponge(uint256 in_xL, uint256 in_xR, uint256 in_k) public pure returns (uint256 xL, uint256 xR); + function MiMCSponge(uint256 in_xL, uint256 in_xR) public pure returns (uint256 xL, uint256 xR); } contract MerkleTreeWithHistory { @@ -56,9 +56,9 @@ contract MerkleTreeWithHistory { require(uint256(_right) < FIELD_SIZE, "_right should be inside the field"); uint256 R = uint256(_left); uint256 C = 0; - (R, C) = Hasher.MiMCSponge(R, C, 0); + (R, C) = Hasher.MiMCSponge(R, C); R = addmod(R, uint256(_right), FIELD_SIZE); - (R, C) = Hasher.MiMCSponge(R, C, 0); + (R, C) = Hasher.MiMCSponge(R, C); return bytes32(R); } @@ -100,13 +100,13 @@ contract MerkleTreeWithHistory { } uint32 i = currentRootIndex; do { - if (_root == roots[i]) { - return true; - } - if (i == 0) { - i = ROOT_HISTORY_SIZE; - } - i--; + if (_root == roots[i]) { + return true; + } + if (i == 0) { + i = ROOT_HISTORY_SIZE; + } + i--; } while (i != currentRootIndex); return false; } diff --git a/package-lock.json b/package-lock.json index 3f5bf11..1eb4ecc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1687,122 +1687,14 @@ } }, "circomlib": { - "version": "0.0.19", - "resolved": "https://registry.npmjs.org/circomlib/-/circomlib-0.0.19.tgz", - "integrity": "sha512-0Jei/2BplQM/XFx3lC8+kcaSCxKHhE3w1MrjfWCFSTyT+VRRbBwHH1Kd7HYqYsQ4XMJELIEHmIhtQnKpC9Rr5w==", + "version": "git+https://github.com/tornadocash/circomlib.git#347822604996bf25f659f96ee0f02810a1f71bb0", + "from": "git+https://github.com/tornadocash/circomlib.git#347822604996bf25f659f96ee0f02810a1f71bb0", "requires": { "blake-hash": "^1.1.0", "blake2b": "^2.1.3", "snarkjs": "^0.1.20", "typedarray-to-buffer": "^3.1.5", "web3": "^1.0.0-beta.55" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "eslint": { - "version": "5.16.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-5.16.0.tgz", - "integrity": "sha512-S3Rz11i7c8AA5JPv7xAH+dOyq/Cu/VXHiHXBPOU1k/JAM5dXqQPt3qcrhpHSorXmrpu2g0gkIBVXAqCpzfoZIg==", - "requires": { - "@babel/code-frame": "^7.0.0", - "ajv": "^6.9.1", - "chalk": "^2.1.0", - "cross-spawn": "^6.0.5", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "eslint-scope": "^4.0.3", - "eslint-utils": "^1.3.1", - "eslint-visitor-keys": "^1.0.0", - "espree": "^5.0.1", - "esquery": "^1.0.1", - "esutils": "^2.0.2", - "file-entry-cache": "^5.0.1", - "functional-red-black-tree": "^1.0.1", - "glob": "^7.1.2", - "globals": "^11.7.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "inquirer": "^6.2.2", - "js-yaml": "^3.13.0", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.3.0", - "lodash": "^4.17.11", - "minimatch": "^3.0.4", - "mkdirp": "^0.5.1", - "natural-compare": "^1.4.0", - "optionator": "^0.8.2", - "path-is-inside": "^1.0.2", - "progress": "^2.0.0", - "regexpp": "^2.0.1", - "semver": "^5.5.1", - "strip-ansi": "^4.0.0", - "strip-json-comments": "^2.0.1", - "table": "^5.2.3", - "text-table": "^0.2.0" - } - }, - "globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" - }, - "snarkjs": { - "version": "0.1.20", - "resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.20.tgz", - "integrity": "sha512-tYmWiVm1sZiB44aIh5w/3HUaTntTUC4fv+CWs4rR0gfkt2KbHTpArOqZW++/Lxujrn9IypXVhdKVUr/eE6Hxfg==", - "requires": { - "big-integer": "^1.6.43", - "chai": "^4.2.0", - "escape-string-regexp": "^1.0.5", - "eslint": "^5.16.0", - "keccak": "^2.0.0", - "yargs": "^12.0.5" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "requires": { - "has-flag": "^3.0.0" - } - } } }, "cli-cursor": { diff --git a/package.json b/package.json index 6f4f264..604ef88 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "circom": "0.0.34", - "circomlib": "^0.0.19", + "circomlib": "git+https://github.com/tornadocash/circomlib.git#347822604996bf25f659f96ee0f02810a1f71bb0", "dotenv": "^8.2.0", "eslint": "^6.6.0", "ganache-cli": "^6.7.0",