yarn
yarn dev
0xparc / zkrepl Goto Github PK
View Code? Open in Web Editor NEWAn online playground for zero knowledge circuits
Home Page: https://zkrepl.dev/
License: GNU General Public License v3.0
An online playground for zero knowledge circuits
Home Page: https://zkrepl.dev/
License: GNU General Public License v3.0
yarn
yarn dev
I was generating the plonkVerifier contract for the default multiplier example and it generated a contract with type "uint4" in the first line which is not an existing solidity type. Also, even by manually correcting this into an "uint32", I wasn't able to successfully verify my proof inside that contract
Here's the line that generates the wrong solidity type =>
https://github.com/0xPARC/zkrepl/blob/main/src/data/plonk.sol#L26
template test(n) {
signal input c[n]; // Constants
signal output out[n];
for (var i=0; i<n; i++) {
out[i] <== c[i];
}
}
component main = test(1);
/* INPUT = {
How could I write array input c[n]?
} */
I have been grappling with handling negative numbers in circom and came across this issue. As I understand it circom divides the finite field so that negative numbers span p / 2
and p - 1
. When confirming some of this behaviour in zkrepl I saw unexpected results for negative input values:
https://zkrepl.dev/?gist=c9691b5e248e1b080cc6ea0c532b5c38
pragma circom 2.1.4;
template Example () {
signal input a;
log("a", a);
signal input p_minus_one;
log("p_minus_one", p_minus_one);
signal output c;
assert(-1 == p_minus_one);
assert(-1 == a);
}
component main { public [a] } = Example();
/* INPUT = {
"a": "-1",
"p_minus_one": "21888242871839275222246405745257275088548364400416034343698204186575808495616"
} */
The resulting log is:
a 4294967295
p_minus_one 21888242871839275222246405745257275088548364400416034343698204186575808495616
and the compilation fails on assert(-1 == a);
Is this expected behaviour?
When compiling
pragma circom 2.1.6;
include "circomlib/poseidon.circom";
include "https://github.com/zkemail/zk-email-verify/blob/main/packages/twitter-verifier-circuits/twitter.circom";
component main { public [ address ] } = TwitterVerifier(1024, 1536, 121, 17, 31, 0, 0);
/*
INPUT = {"in_padded":["100","97","116","101","58","87","101","100","44","32","48","49","32","78","111","118","32","50","48","50","51","32","48","56","58","52","48","58","50","49","32","43","48","48","48","48","13","10","102","114","111","109","58","84","119","105","116","116","101","114","32","60","105","110","102","111","64","120","46","99","111","109","62","13","10","116","111","58","122","107","95","112","114","97","99","116","105","99","101","32","60","122","107","101","109","97","105","108","118","101","114","105","102","121","64","103","109","97","105","108","46","99","111","109","62","13","10","115","117","98","106","101","99","116","58","80","97","115","115","119","111","114","100","32","114","101","115","101","116","32","114","101","113","117","101","115","116","13","10","109","105","109","101","45","118","101","114","115","105","111","110","58","49","46","48","13","10","99","111","110","116","101","110","116","45","116","121","112","101","58","109","117","108","116","105","112","97","114","116","47","97","108","116","101","114","110","97","116","105","118","101","59","32","98","111","117","110","100","97","114","121","61","34","45","45","45","45","61","95","80","97","114","116","95","52","50","57","54","57","48","52","95","49","54","50","50","52","54","52","56","52","57","46","49","54","57","56","56","50","56","48","50","49","52","57","52","34","13","10","109","101","115","115","97","103","101","45","105","100","58","60","56","68","46","50","68","46","48","49","54","48","51","46","53","70","69","48","50","52","53","54","64","120","46","99","111","109","62","13","10","100","107","105","109","45","115","105","103","110","97","116","117","114","101","58","118","61","49","59","32","97","61","114","115","97","45","115","104","97","50","53","54","59","32","99","61","114","101","108","97","120","101","100","47","114","101","108","97","120","101","100","59","32","100","61","120","46","99","111","109","59","32","115","61","100","107","105","109","45","50","48","50","51","48","56","59","32","116","61","49","54","57","56","56","50","56","48","50","49","59","32","98","104","61","66","105","104","69","65","71","54","107","102","74","110","105","119","54","90","43","88","114","103","47","101","90","66","83","81","86","78","84","54","121","111","119","81","43","52","111","71","100","118","51","103","116","73","61","59","32","104","61","68","97","116","101","58","70","114","111","109","58","84","111","58","83","117","98","106","101","99","116","58","77","73","77","69","45","86","101","114","115","105","111","110","58","67","111","110","116","101","110","116","45","84","121","112","101","58","77","101","115","115","97","103","101","45","73","68","59","32","98","61","128","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","15","104","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"pubkey":["2042675158572422735167009601580549693","2318426925121163447366268266877478490","1147774667595934040844400996565450529","2585846613753899425173314975383472766","1729550870628631316824527689749144826","1409688764733787577291119235590636170","2653526314989005305308617746718530524","737602834602272445014721319074990651","1108223552850320351953361145401433110","196998911671740026740284042198980922","1810975214051689602006218559773860466","1356973725008685867134185890101517745","1741745429950802523929336578157878155","322242294656712334589977633789887989","1317445847036079731092233939335794482","1737308978482248574701598258817218345","3883364526267798178367189328134785"],"signature":["985450202199492610812943491641790784","1137993534281404383694795433082544385","190970174361732984775905483489605159","735168193306732361053791456813220587","30752125817231734339027088308266571","776556181008712945238920868703888000","1267247526385136659088282385012569754","1718964435762695678130391654061474258","682643652492480109999158584520299670","1554417776101376658264178429398026028","779754796921599346149743103428556027","680700483536035236479905515371633377","1686724334298279291567069619435769975","1972950227112051626669940187863792449","2007912233402477893245977667655257455","622319187270779929757983927519002067","1587373965204314940114266699008378"],"in_len_padded_bytes":"512","precomputed_sha":["92","160","241","225","55","117","25","80","181","47","114","181","210","160","122","73","111","225","159","40","215","104","52","201","59","191","250","168","73","176","140","101"],"body_hash_idx":"384","in_body_padded":["98","107","105","116","61","13","10","45","102","111","110","116","45","115","109","111","111","116","104","105","110","103","58","97","110","116","105","97","108","105","97","115","101","100","59","34","62","32","84","104","105","115","32","101","109","97","105","108","32","119","97","115","32","109","101","97","110","116","32","102","111","114","32","64","122","107","116","101","115","116","101","109","97","105","108","32","60","47","115","112","97","110","61","13","10","62","32","60","47","116","100","62","13","10","60","47","116","114","62","13","10","60","116","114","62","13","10","60","116","100","32","104","101","105","103","104","116","61","51","68","34","54","34","32","115","116","121","108","101","61","51","68","34","104","101","105","103","104","116","58","54","112","120","59","108","105","110","101","45","104","101","105","103","104","116","58","49","112","120","59","102","111","110","116","45","115","105","122","101","58","49","112","120","59","112","97","100","100","105","110","103","58","61","13","10","48","59","109","97","114","103","105","110","58","48","59","108","105","110","101","45","104","101","105","103","104","116","58","49","112","120","59","102","111","110","116","45","115","105","122","101","58","49","112","120","59","34","62","60","47","116","100","62","13","10","60","47","116","114","62","13","10","60","116","114","62","13","10","60","116","100","32","97","108","105","103","110","61","51","68","34","99","101","110","116","101","114","34","32","115","116","121","108","101","61","51","68","34","112","97","100","100","105","110","103","58","48","59","109","97","114","103","105","110","58","48","59","108","105","110","101","45","104","101","105","103","104","116","58","49","112","120","59","102","111","110","116","45","115","105","122","101","58","61","13","10","49","112","120","59","34","62","32","60","115","112","97","110","32","99","108","97","115","115","61","51","68","34","97","100","100","114","101","115","115","34","62","32","60","97","32","104","114","101","102","61","51","68","34","35","34","32","115","116","121","108","101","61","51","68","34","116","101","120","116","45","100","101","99","111","114","97","116","105","111","110","58","110","111","110","101","61","13","10","59","98","111","114","100","101","114","45","115","116","121","108","101","58","110","111","110","101","59","98","111","114","100","101","114","58","48","59","112","97","100","100","105","110","103","58","48","59","109","97","114","103","105","110","58","48","59","102","111","110","116","45","102","97","109","105","108","121","58","39","72","101","108","118","101","116","105","99","97","78","101","117","101","39","44","61","13","10","32","39","72","101","108","118","101","116","105","99","97","32","78","101","117","101","39","44","32","72","101","108","118","101","116","105","99","97","44","32","65","114","105","97","108","44","32","115","97","110","115","45","115","101","114","105","102","59","45","119","101","98","107","105","116","45","102","111","110","116","45","115","109","111","111","116","104","105","110","103","58","97","110","116","105","61","13","10","97","108","105","97","115","101","100","59","99","111","108","111","114","58","35","56","56","57","57","65","54","59","102","111","110","116","45","115","105","122","101","58","49","50","112","120","59","112","97","100","100","105","110","103","58","48","112","120","59","109","97","114","103","105","110","58","48","112","120","59","102","111","110","116","45","119","101","105","103","104","116","58","110","111","114","61","13","10","109","97","108","59","108","105","110","101","45","104","101","105","103","104","116","58","49","50","112","120","59","99","117","114","115","111","114","58","100","101","102","97","117","108","116","59","34","62","88","32","67","111","114","112","46","32","49","51","53","53","32","77","97","114","107","101","116","32","83","116","114","101","101","116","44","32","83","117","105","116","101","32","57","48","48","61","13","10","32","83","97","110","32","70","114","97","110","99","105","115","99","111","44","32","67","65","32","57","52","49","48","51","60","47","97","62","32","60","47","115","112","97","110","62","32","60","47","116","100","62","13","10","60","47","116","114","62","13","10","60","116","114","62","13","10","60","116","100","32","104","101","105","103","104","116","61","51","68","34","55","50","34","32","115","116","121","108","101","61","51","68","34","104","101","105","103","104","116","58","55","50","112","120","59","112","97","100","100","105","110","103","58","48","59","109","97","114","103","105","110","58","48","59","108","105","110","101","45","104","101","105","103","104","116","58","49","112","120","59","102","61","13","10","111","110","116","45","115","105","122","101","58","49","112","120","59","34","62","60","47","116","100","62","13","10","60","47","116","114","62","13","10","60","47","116","98","111","100","121","62","13","10","60","47","116","97","98","108","101","62","13","10","60","33","45","45","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","32","101","110","100","32","102","111","111","116","101","114","32","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","47","45","45","62","32","60","47","116","100","62","13","10","60","47","116","114","62","13","10","60","47","116","98","111","100","121","62","13","10","60","47","116","97","98","108","101","62","13","10","60","47","98","111","100","121","62","13","10","60","47","104","116","109","108","62","13","10","45","45","45","45","45","45","61","95","80","97","114","116","95","52","50","57","54","57","48","52","95","49","54","50","50","52","54","52","56","52","57","46","49","54","57","56","56","50","56","48","50","49","52","57","52","45","45","13","10","128","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","1","187","56","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"in_body_len_padded_bytes":"1088","twitter_username_idx":"64","address":"1"}
*/
on repl.prove.email (a deployment of #15), I get this:
memory allocation of 66568 bytes failed
STDOUT:
template instances: 230
Compiled in 449.09s
FAIL:
ENOENT: no such file or directory, open 'main_js/main.wasm'
Without the input, it's faster, compiled in 333.96s
.
with this in console:
hover err Error: ENOENT: no such file or directory, open 'main.sym'
Using zkrepl to compile code on Chrome on Windows, I see a variable number of invalid characters (appearing as rectangles) show up in the output before the normal output of the compiler. If I scroll down past them, the output is otherwise correct:
I'm not a web expert, but I think the Chrome dev tools are telling me that these are null characters:
This happens for any input, including the initial example zkrepl comes up with. I've seen this in Chrome and Edge on Windows10, but I don't see it on Firefox. I've seen the issue on two different machines with the same OS version, but I don't have any other platforms handy. A friend tried this in Chrome on Linux and Mac and didn't see the issue. Noting that Chrome and Edge share the Chromium rendering engine, I suspect this might be a specific behavior of that engine when running on Windows.
With major syntax changes, would be great to support circom 2.1.0
https://github.com/iden3/circom/releases/tag/v2.1.0
Currently, it is on circom 2.1.4, but 2.1.5 adds a bunch of helpful features like signal declaration inside if blocks.
On the currently deployed zkrepl.dev,
include "circomlib/poseidon.circom";
include "circomlib/circuits/poseidon.circom";
hangs forever. Resolved in #15
hi
i'm trying to figure out what's going on here:
template Array () {
signal input in[3];
signal input index;
signal output out;
signal a;
assert(index==3);
a <-- in[index];
out <== a;
}
component main {public [in, index]} = Array();
/* INPUT = {
"in": ["5", "3", "2"],
"index": "3"
} */
in zkrepl this compiles and out = 3
, even though that index
position is out of bounds of the array. when i use a <-- in[3];
instead, the compiler correctly throws an error. assigning index
to higher numbers returns various other values.
can someone help me understand if i'm doing something wrong?
thanks
I'm using a dummy constraint which exists to ensure a signal doesn't get removed by the compiler. It looks like this:
signal watermarkSquared <== watermark * watermark;
This gets a warning with a message which seems incomplete, saying "The intermediate signal watermarkSquared
is declared here."
I'd guess that it's warning me that watermarkSquared is unused, which is intentional and unavoidable here, but I can't be sure as it's not actually saying so.
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.