Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ be used directly with this library.
node ../tools/buildpkey.js -i proving_key.json -o proving_key.bin
```

The result is a JSON object with pi_a, pi_b and pi_c points.
The result is a JSON object with pi_a, pi_b, pi_c points and protocol groth field.

You can use the stringified version of this JSON as a proof.json in [snarkjs](https://github.com/iden3/snarkjs)

Expand All @@ -62,20 +62,24 @@ Here is a simple example of a web page that loads a key and a witness and genera
<script>

var witness;
var proving_key;
var provingKey;

function onLoad() {

document.getElementById("calcProof").disabled = true;
fetch("proving_key.bin").then( (response) => {
return response.arrayBuffer();
}).then( (b) => {
provingKey = b;
});

fetch("witness.bin").then( (response) => {
return response.arrayBuffer();
}).then( (b) => {
witness = b;
console.log("proving key loaded");
}).then( () =>{
fetch("witness.bin").then( (response) => {
return response.arrayBuffer();
}).then( (b) => {
witness = b;
}).then ( () => {
console.log("witness loaded");
document.getElementById("calcProof").disabled = false;
});
});
}

Expand All @@ -96,7 +100,7 @@ function calcProof() {
<body onLoad="onLoad()">
<h1>iden3</h1>
<h2>Zero knowledge proof generator</h2>
<button onClick="calcProof()">Test</button>
<button id="calcProof" onClick="calcProof()">Test</button>
<div id="time"></div>
<pre id="proof"></pre>

Expand Down
9 changes: 6 additions & 3 deletions build/websnark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,10 @@ function thread(self) {
while (i32[0] & 3) i32[0]++; // Return always aligned pointers
const res = i32[0];
i32[0] += length;
while (i32[0] > memory.buffer.byteLength) {
memory.grow(100);
}
i32 = new Uint32Array(memory.buffer);
return res;
}

Expand Down Expand Up @@ -2099,6 +2103,7 @@ class Groth16 {
pi_a: this.bin2g1(this.getBin(pi_a, 96)),
pi_b: this.bin2g2(this.getBin(pi_b, 192)),
pi_c: this.bin2g1(this.getBin(pi_c, 96)),
protocol: 'groth',
};

}
Expand Down Expand Up @@ -3378,7 +3383,6 @@ function fromByteArray (uint8) {
}

},{}],10:[function(require,module,exports){
(function (Buffer){
/*!
* The buffer module from node.js, for the browser.
*
Expand Down Expand Up @@ -5157,8 +5161,7 @@ function numberIsNaN (obj) {
return obj !== obj // eslint-disable-line no-self-compare
}

}).call(this,require("buffer").Buffer)
},{"base64-js":9,"buffer":10,"ieee754":11}],11:[function(require,module,exports){
},{"base64-js":9,"ieee754":11}],11:[function(require,module,exports){
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m
var eLen = (nBytes * 8) - mLen - 1
Expand Down
20 changes: 12 additions & 8 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@
var provingKey;

function onLoad() {

document.getElementById("calcProof").disabled = true;
fetch("proving_key.bin").then( (response) => {
return response.arrayBuffer();
}).then( (b) => {
provingKey = b;
});

fetch("witness.bin").then( (response) => {
return response.arrayBuffer();
}).then( (b) => {
witness = b;
console.log("proving key loaded");
}).then( () =>{
fetch("witness.bin").then( (response) => {
return response.arrayBuffer();
}).then( (b) => {
witness = b;
}).then ( () => {
console.log("witness loaded");
document.getElementById("calcProof").disabled = false;
});
});
}

Expand Down Expand Up @@ -75,7 +79,7 @@
<body onLoad="onLoad()">
<h1>iden3</h1>
<h2>Zero knowledge proof generator</h2>
<button onClick="calcProof()">Test</button>
<button id="calcProof" onClick="calcProof()">Test</button>
<div id="time"></div>
<pre id="proof"></pre>

Expand Down
9 changes: 6 additions & 3 deletions example/websnark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,10 @@ function thread(self) {
while (i32[0] & 3) i32[0]++; // Return always aligned pointers
const res = i32[0];
i32[0] += length;
while (i32[0] > memory.buffer.byteLength) {
memory.grow(100);
}
i32 = new Uint32Array(memory.buffer);
return res;
}

Expand Down Expand Up @@ -2099,6 +2103,7 @@ class Groth16 {
pi_a: this.bin2g1(this.getBin(pi_a, 96)),
pi_b: this.bin2g2(this.getBin(pi_b, 192)),
pi_c: this.bin2g1(this.getBin(pi_c, 96)),
protocol: 'groth',
};

}
Expand Down Expand Up @@ -3378,7 +3383,6 @@ function fromByteArray (uint8) {
}

},{}],10:[function(require,module,exports){
(function (Buffer){
/*!
* The buffer module from node.js, for the browser.
*
Expand Down Expand Up @@ -5157,8 +5161,7 @@ function numberIsNaN (obj) {
return obj !== obj // eslint-disable-line no-self-compare
}

}).call(this,require("buffer").Buffer)
},{"base64-js":9,"buffer":10,"ieee754":11}],11:[function(require,module,exports){
},{"base64-js":9,"ieee754":11}],11:[function(require,module,exports){
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m
var eLen = (nBytes * 8) - mLen - 1
Expand Down
1 change: 1 addition & 0 deletions src/groth16.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ class Groth16 {
pi_a: this.bin2g1(this.getBin(pi_a, 96)),
pi_b: this.bin2g2(this.getBin(pi_b, 192)),
pi_c: this.bin2g1(this.getBin(pi_c, 96)),
protocol: 'groth',
};

}
Expand Down