Browse Source

feat: makes mimcsponge contract act like the circuit version

feature/pr-19
Kobi Gurkan 5 years ago
parent
commit
1483abaa2f
2 changed files with 9 additions and 5 deletions
  1. +2
    -2
      package-lock.json
  2. +7
    -3
      src/mimcsponge_gencontract.js

+ 2
- 2
package-lock.json

@ -8632,7 +8632,7 @@
}, },
"os-tmpdir": { "os-tmpdir": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
}, },
"p-cancelable": { "p-cancelable": {
@ -9248,7 +9248,7 @@
}, },
"sprintf-js": { "sprintf-js": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "http://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
}, },
"sshpk": { "sshpk": {

+ 7
- 3
src/mimcsponge_gencontract.js

@ -50,7 +50,11 @@ function createCode(seed, n) {
C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q) C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q)
for (let i=0; i<n-1; i++) { for (let i=0; i<n-1; i++) {
ci = Web3Utils.keccak256(ci);
if (i < n-2) {
ci = Web3Utils.keccak256(ci);
} else {
ci = "0x00";
}
C.swap(1); // xR xL k q C.swap(1); // xR xL k q
C.dup(3); // q xR xL k q C.dup(3); // q xR xL k q
C.dup(3); // k q xR xL k q C.dup(3); // k q xR xL k q
@ -74,9 +78,9 @@ function createCode(seed, n) {
C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q) C.addmod(); // e=t^5+xR xL k q (for next round: xL xR k q)
} }
C.push("0x00");
C.mstore(); // Save it to pos 0;
C.push("0x20"); C.push("0x20");
C.mstore(); // Save it to pos 0;
C.push("0x00");
C.mstore(); // Save it to pos 1; C.mstore(); // Save it to pos 1;
C.push("0x40"); C.push("0x40");
C.push("0x00"); C.push("0x00");

Loading…
Cancel
Save