This is a helper library to read r1cs binary files defined here
const readR1cs = require("r1csfile").readR1cs
readR1cs("myfile.r1cs").then((r1cs) => {
console.log(r1cs);
});
r1cs file format parser
License: GNU General Public License v3.0
This is a helper library to read r1cs binary files defined here
const readR1cs = require("r1csfile").readR1cs
readR1cs("myfile.r1cs").then((r1cs) => {
console.log(r1cs);
});
Grasping over the .r1cs documentation r1cs docs the section 2 explicitly tells:
But in the .r1cs file, the values are not stored like that, but as negative numbers instead, taking the header.prime as the max integer.
For example:
For this constrain:
The expected bytes would be:
[xx-xx-xx-xx][01000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000]
[xx-xx-xx-xx][01000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000]
[xx-xx-xx-xx][01000000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000]
but in the .r1cs they are stored as
[xx-xx-xx-xx][000000f, 093f5e14, 39170b97, 948e8332, 85d58818, 1b64550b, 829a031e, 1724e6430]
[xx-xx-xx-xx][000000f, 093f5e14, 39170b97, 948e8332, 85d58818, 1b64550b, 829a031e, 1724e6430]
[xx-xx-xx-xx][0100000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000]
If i substract headers.prime to these bytes, the result is actually the one that is described in the documentation.
Constants are also encoded as positive numbers, for example, taking the constraint
5 + a * b ==> c
The linearCombination will be produced as:
[xx-xx-xx-xx][0500000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000]
[xx-xx-xx-xx][000000f, 093f5e14, 39170b97, 948e8332, 85d58818, 1b64550b, 829a031e, 1724e6430]
[xx-xx-xx-xx][000000f, 093f5e14, 39170b97, 948e8332, 85d58818, 1b64550b, 829a031e, 1724e6430]
[xx-xx-xx-xx][0100000, 00000000, 00000000, 00000000, 00000000, 00000000, 00000000]
This behavior is not described in the documentation of the .r1cs.
If the explanation i make for this behavior is right (Can be wrong if the reasons of this behavior are others and not just, negative numbers)
I'm proposing myself to modify the .r1cs specification to add the explanation for this fields.
In the description of r1cs binary file format, the description of "Number of Labels" is unclear, because it is a verbatim copy of the description of "Number of private inputs".
Also, while at it, there is a typo in the description of the fields "Number of public outputs", "Number of public inputs", "Number of private inputs" and "Number of Labels", were the word "wire" is used twice. E.g., it reads:
Total Number of wires public output wires.
while it should read:
Total Number of public output wires.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.