当前位置:网站首页>Circom 2.0: A Scalable Circuit Compiler
Circom 2.0: A Scalable Circuit Compiler
2022-07-24 21:54:00 【mutourend】
1. introduction
This article is mainly from IDEN3 The team Albert Rubio stay Compiler and Composability in ZKP The speech on .

2. What is the Circom?
What is the Circom?==>circom
- For programming languages and compilers
- from Jordi Baylina Created , in the light of ZK The circuit design in the Protocol DSL Language
- by iden3 Part of the project
- circom 2.0 The compiler is mainly composed of UCM Team development in universities
- circom 2.0 The compiler is completely open source and is provided by Rust language , It provides faster circuit compilation and better security
- circom The community is rapidly carrying
- Community for circom The success of
One circom program There are mainly two purposes :
- 1) Provide a symbolic description of the corresponding circuit : There is a set of R1CS constraint .
- 2) Provide an efficient way to calculate based on input witness:
- There will be WebAssembly(wasm) Code and the JS Or mainstream browsers
- It provides C++ Code ( Such as ZK-Rollups for Layer 2)
circom Support developers to design from the bottom arithmetic circuit ( Similar to designing electronic circuits ).
stay circom in , All constraints must be explicitly added by the developer .
Constraints can be simplified , It can be removed at compile time signals, however Never introduce new signals.
stay circom, The actual circuit is called components, and component Is based on template Instantiated ,template For the parametric description of the circuit , Such as :
Above , circuit Multiplier receive 2 Inputs , Then the output signal Is the product of the two .
circom A key feature of is that it provides different instructions to :
- stay symbolic Layer defines new constraints :
Will generate constraintsout === in1 * in2; // symbolic level "only"in1 * in2 - out = 0. - stay computational Layer computing a signal:
Will generate something likeout<-- in1 * in2; // computational level onlyout := in1 * in2Code for . - Or with the help of
<==The operator :
Will generate constraintout <== in1 * in2; // symbolic and computational levelin1 * in2 - out = 0and Codeout := in1 * in2.
It is usually required to use <== The operator , But sometimes you don't need . Such as , Definition check input Is it 0 Circuit , Should be :
Use <-- and === The operator , There is no guarantee that the circuit is symbolic Layer and the computational Equivalence of layers , The developer should be responsible for realizing the corresponding equivalence .
Can be based on circomlib Library etc templates Make combinations to build circuits :
Above , Using variables sum To settle accounts loop Addition in a loop , Introduce parameters n To limit input signals The number of .
When building constraints , A variable is symbolic expression ; And calculation witness when , The variable corresponds to field The number .
circomlib The library contains some useful circuit implementations , It can be used as primitive templates, Specific have :
- Binary transformers and operations
- Comparators
- hash function :mimc、pedersen、sha256
- Elliptic curves:babyjubjub(twisted Edwards),Montgomery
- Sparse Merkle Trees
It fully shows Circom The power of language , And how to quadratic constraints To encode complex calculations .
3. Constraint simplification
Describing cryptographic protocols arithmetic circuits The resulting constraint system may contain millions of constraints , Many constraints can usually be removed from it . Simplifying the constraint system is an important work to improve efficiency in the next stage . The upper limit of the number of constraints that most constraint systems can handle is about 2 17 2^{17} 217.
Without modifying the circuit behavior and retaining R1CS In the case of expression ,Circom Support simplification of constraints .
Such as MultiAND() The constraint system of circuit generation is :
Can simplify its linear constraints, Only 2 individual R1CS Equivalent system of constraints :
circom Medium and efficient implementation of linear constraint Simplification of :
- Compiler Application clustering Parallelization simplifies work ;
- Use Gauss-Jordan remove To achieve linear simplify ;
- Iterate the whole process until there is nothing left linear constraints;
- Can be achieved about 80% Of reduction;
- During compilation, the most expensive Part of the :
- Super large circuits need about 750GB Of local memory( need swapping).
- Can make an appointment 6.5 Billion constraints reduce by 1.3 One hundred million .
- stay 64 nucleus 512GB RAM On the machine , The compilation time is about 3 Hours ( If you use the old version circom, It takes several days ).
- Including simplified R1CS The binary file size of is about 50GB.
- have 1 Thousands of constrained circuits are compiled on notebook computers ( And completely simplify ) Time usage 8 minute .
The above simplified technology :
- Will not introduce new signals,
- It should be possible to achieve ,
- Is a new type of code optimization
- circom The simplification technology in is much stronger than Zokrates Medium
- It can be used independently for R1CS Restraint system Simplification of
4. Summary
- circom To face the bottom arithmetic Circuit design DSL
- circom It supports developers to describe how to generate circuit constraints , It also supports developers to calculate efficiently according to any specified input witness
- stay circom in , The developer completely controls the circuit definition
- circomlib The library contains many circuit templates, It can reduce the workload of developers
- circom There is a large and active community
- circom But with iden3 proving system Use a combination of , Such as snarkjs/wasmsnark/rapidsnark
- zkREPL, by zkSNARKs Online development environment , Is based on circom Built
边栏推荐
- Which type of database migration is suitable for choosing the self built database access method on ECs?
- [e-commerce operation] teach you these tips to bid farewell to invalid preset replies
- Establishment of China Mobile Chain (EOS based) test environment
- Practical skills!!
- Binary search
- [image processing] pyefd.elliptic_ fourier_ How descriptors are used
- Metauniverse: technological evolution, industrial ecology and big country game
- Sqlserver BCP parameter interpretation, character format selection and fault handling summary
- Today's nft/ digital collection hotspot
- 小程序地理位置接口申请
猜你喜欢

Alibaba cloud and parallel cloud launched the cloud XR platform to support the rapid landing of immersive experience applications

Binary search

Es+redis+mysql, the high availability architecture design is awesome! (supreme Collection Edition)

Penetration test - command execution injection

Selenium test page content download function

Classical review: understanding the "knowledge consistency" of neural networks (ICLR 2020)

Today, there's a power failure for one day.... stop working for another day. Don't forget to study

2022 Tsinghua summer school notes L2_ 2 basic introduction of CNN and RNN

String matching (Huawei)

Documentary of the second senior brother
随机推荐
2022 Tsinghua summer school notes L1_ NLP and bigmodel Foundation
Class notes (4) (3) -573. Lecture hall arrangement (Hall)
陈春花与莫言,都有苦难言
Unity & facegood audio2face drives face blendshape with audio
HSPF (hydraulic simulation program FORTRAN) model
Maxcompute instance related operations
Jenkins introduction
Build Tencent cloud website server at low cost (build your own website server)
MQ release confirmation
Gather relevant knowledge points and expand supplements
Makefile basics -- extensions
损失函数之Diou和Ciou loss
2018mysql technology Q & a collection, hoping to give some help to students who like MySQL
【二分好题】
What should I do to select the method of mongodb instance accessing the database?
What technical knowledge is needed to build a personal blog independently besides ECS?
What are intelligent investment advisory products?
Composability and Recursion in snarkyJS
P2404 splitting of natural numbers
CAD sets hyperlinks to entities (WEB version)