Comments (3)
Hello,
A verifier can easily use runLibsnark() for verification
First, please note that runLibsnark() is not related to the verifier only. This method runs the jsnark-libsnark interface, which reads the files and computes the values of all variables, including the output variables, then calls libsnark::run_r1cs_ppzksnark or libsnark::run_r1cs_gg_ppzksnark which run all the three algorithms: key generation, proving and verification algorithms that are provided by libsnark. This all happens in a single call (just for demonstration and performance measurement purposes).
In practice, these algorithms will have to be separated, because key generation, proving and verification will be done at different times by different parties. The separation is not provided in this version of jsnark.
With respect to the outputs and all other intermediate variables, they are not written to a file. They are computed during execution in two places:
- In jsnark itself when the circuit is evaluated.
- They are computed internally in the jsnark-libsnark interface when calling run_libsnark(). This is done in the CircuitReader class, after which the assignment of all variables will be ready.
If you would like to generate a file with the output values, a method can be added to jsnark's CircuitEvaluator class.
public void writeOutputFile() {
try {
LinkedHashMap<Instruction, Instruction> evalSequence = circuitGenerator.getEvaluationQueue();
PrintWriter printWriter = new PrintWriter(circuitGenerator.getName() + ".out");
for (Instruction e : evalSequence.keySet()) {
if (e instanceof WireLabelInstruction) {
WireLabelInstruction inst = (WireLabelInstruction) e;
if (inst.getType() == LabelType.output) {
int id = ((WireLabelInstruction) e).getWire().getWireId();
printWriter.println(id + " " + valueAssignment[id].toString(16) + (inst.getDesc().length() > 0 ? (" \t\t# " + inst.getDesc()) : ""));
}
}
}
printWriter.close();
} catch (Exception e) {
e.printStackTrace();
}
}
This will also print any available labels for the output wires beside its value. The above will require adding another method in the WireLabelInstruction class
public String getDesc() {
return desc;
}
And finally add a call to circuitEvaluator.writeOutputFile(); to prepFiles() of the CircuitGenerator class.
The output values can also be provided to the verifier through other means. For example, the prover could call standard cryptographic libraries and send their outputs in the scenario you mentioned, i.e., the prover does not have to get that from the circuit. (We will need to be sure though that the circuit implements the same algorithm and to format the output properly).
Note that in order to use the above in a meaningful scenario, I think that the separation I referred to above might need to be implemented. For example, this could be done by adding support for a method, e.g., runLibsnarkVerifier, that will call a libsnark executable that takes public* input and output values and a verification key.
(* The .in file includes both public and prover private inputs. The verifier will only need the public inputs.)
from jsnark.
@akosba Thanks for your reply! This is very helpful, let me understand more about jsnark.
So if I want a prover to provide the public input(public key) and public output(proof value, cipherText) of a encryption process, and a verifier to verify these, I need to generate corresponding parameters and call libsnark?
I need to use jsnark to write circuit and generate files(.arith & .in) first, and then split prove/verify in the step of calling libsnark?
from jsnark.
Has anyone already implemented a runLibsnarkVerifier or runLibsnarkProver to avoid the execution of the three algorithms ?
from jsnark.
Related Issues (20)
- SHA 256 gadget's output wires have negative id HOT 2
- Questions about RSAEncryptionV1_5_Gadget HOT 2
- Using AES128CipherCircuitGenerator with plaintexts of size more than 16 bytes HOT 2
- Clarifying the use of the input parameter 'bitwidthPerInputElement' in SHA256 gadget HOT 3
- verifying proof on blockchain HOT 2
- toturial
- LongElement multiplication without creating prover witness wires. HOT 1
- HELP: how to implement a solution in practice?
- Change the curve HOT 2
- Computing scalar multiplication using a negated scalar, on the Elliptic Curve HOT 2
- How to initialize a number on the prime field? HOT 1
- cmake failed HOT 2
- libsnark fails for circuits with checkNonZero depending on execution order HOT 2
- Questions about RSAEncryptionCircuitGenerator HOT 2
- Floating point exception (core dumped)
- A Trivial Issue: setWireValue(Wire w, long v) HOT 2
- What License is this? HOT 1
- `make` fails for missing includes HOT 3
- JAVA Version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsnark.