forked from iden3/circomlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request iden3#92 from victorcrrd/plonk-custom-gates-doc
Added some documentation regarding custom templates
- Loading branch information
Showing
4 changed files
with
38 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Custom templates in [snarkjs](../index.md#snarkjs) | ||
|
||
[snarkjs](https://github.com/iden3/snarkjs) provides an implementation of the PLONK's zkSNARK. An extension of the scheme, [turbo-PLONK](https://docs.zkproof.org/pages/standards/accepted-workshop3/proposal-turbo_plonk.pdf), allows the definition of the so called custom gates: more general transition gates than the ones defined by default for the regular PLONK zkSNARK, that allows the circuit's designer to, maybe, reduce the number of used gates, probably resulting in shorter proofs size or verification times. This document will contain a list of the custom gates implemented in snarkjs that can me used in the circom language. Note that the list may grow over time with the new implementations from the iden3 collaborators or thanks to contributions from the community. | ||
|
||
## List of custom gates implemented in snarkjs | ||
At the moment there are no custom gates implemented in snarkjs yet. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
# Pragma | ||
|
||
All files with .circom extension should start with a first `pragma`instruction specifying the compiler version, like this: | ||
## Version pragma | ||
|
||
All files with .circom extension should start with a first `pragma` instruction specifying the compiler version, like this: | ||
|
||
```text | ||
pragma circom xx.yy.zz; | ||
``` | ||
|
||
This is to ensure that the circuit is compatible with the compiler version indicated after the `pragma` instruction. Otherwise, the compiler throws a warning. | ||
This is to ensure that the circuit is compatible with the compiler version indicated after the `pragma` instruction. Otherwise, the compiler throws a warning. | ||
|
||
If a file does not contain this instruction, it is assumed that the code is compatible with the latest compiler's version and a warning is thrown. | ||
|
||
## Custom templates pragma | ||
|
||
Since circom 2.0.6, the language allows the definition of custom templates (see [this](../circom-language/templates-and-components.md#custom-templates) for more information). This `pragma` allows the circom programmer to easily tell if it's using custom templates: if any file declaring a custom template or including a file declaring any custom template doesn't use this `pragma`, the compiler will produce an error. Moreover, it will inform the programmer about which files should include this pragma. | ||
|
||
To use it simply add the following instruction at the beginning (and after the version `pragma`) of the .circom files that needs it: | ||
|
||
```text | ||
pragma custom_templates; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters