Browse Source

Added JS style syntaxing to README

master
Ghilia Weldesselasie 6 years ago
committed by GitHub
parent
commit
280cdd7787
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      README.md

+ 7
- 7
README.md

@ -8,7 +8,7 @@ This library uses the compiled circuits generated by the jaz compiler.
## Install. ## Install.
```
```sh
npm install zksnark npm install zksnark
``` ```
@ -16,13 +16,13 @@ npm install zksnark
### Import. ### Import.
```
```js
const zkSnark = require("zksnark"); const zkSnark = require("zksnark");
``` ```
### Load a circuit. ### Load a circuit.
```
```js
// "myCircuit.cir" is the output of the jaz compiler // "myCircuit.cir" is the output of the jaz compiler
const circuitDef = JSON.parse(fs.readFileSync("myCircuit.cir", "utf8")); const circuitDef = JSON.parse(fs.readFileSync("myCircuit.cir", "utf8"));
@ -31,7 +31,7 @@ const circuit = new zkSnark.Circuit(circuitDef);
### Inspect the circuit. ### Inspect the circuit.
```
```js
// `signalId` can always be a number or an alias string // `signalId` can always be a number or an alias string
circuit.nConstraints; // number of constraints circuit.nConstraints; // number of constraints
@ -77,7 +77,7 @@ const circuit = new zkSnark.Circuit(circuitDef);
### Trusted setup. ### Trusted setup.
```
```js
const setup = zkSnark.setup(circuit); const setup = zkSnark.setup(circuit);
fs.writeFileSink("myCircuit.vk_proof", JSON.stringify(setup.vk_proof), "utf8"); fs.writeFileSink("myCircuit.vk_proof", JSON.stringify(setup.vk_proof), "utf8");
fs.writeFileSink("myCircuit.vk_verifier", JSON.stringify(setup.vk_verifier), "utf8"); fs.writeFileSink("myCircuit.vk_verifier", JSON.stringify(setup.vk_verifier), "utf8");
@ -86,7 +86,7 @@ setup.toxic // Must be discarded.
### Generate proof. ### Generate proof.
```
```js
const circuitDef = JSON.parse(fs.readFileSync("myCircuit.cir", "utf8")); const circuitDef = JSON.parse(fs.readFileSync("myCircuit.cir", "utf8"));
const circuit = new zkSnark.Circuit(circuitDef); const circuit = new zkSnark.Circuit(circuitDef);
const input = { const input = {
@ -101,7 +101,7 @@ const {proof, publicSignals} = zkSnark.genProof(vk_proof, witness);
### Verifier. ### Verifier.
```
```js
const vk_verifier = JSON.parse(fs.readFileSync("myCircuit.vk_verifier", "utf8")); const vk_verifier = JSON.parse(fs.readFileSync("myCircuit.vk_verifier", "utf8"));
if (zkSnark.isValid(vk_verifier, proof, publicSignals)) { if (zkSnark.isValid(vk_verifier, proof, publicSignals)) {

Loading…
Cancel
Save