2019-09-27 17:58:08 +00:00
|
|
|
# `embark-snark`
|
2019-09-12 23:55:36 +00:00
|
|
|
|
2019-09-27 17:58:08 +00:00
|
|
|
> Snark plugin for Embark
|
2019-09-12 23:55:36 +00:00
|
|
|
|
2019-09-27 17:58:08 +00:00
|
|
|
Compiles circom circuits and generate solidity proofs in an Embark DApp.
|
|
|
|
|
|
|
|
## Installation
|
2019-09-12 23:55:36 +00:00
|
|
|
|
|
|
|
In your embark dapp directory:
|
2019-09-27 17:58:08 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
npm install embark-snark --save
|
|
|
|
```
|
|
|
|
|
|
|
|
Then add embark-snark to the plugins section in `embark.json`:
|
|
|
|
|
|
|
|
```json
|
|
|
|
"plugins": {
|
|
|
|
"embark-snark": {
|
|
|
|
"circuits": ["app/circuits/**"],
|
|
|
|
"inputs": {
|
|
|
|
"multiplier": {
|
|
|
|
"a": 3,
|
|
|
|
"b": 11
|
2019-09-12 23:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-27 17:58:08 +00:00
|
|
|
}
|
2019-09-12 23:55:36 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
You can defined where your circuits will be and what are the inputs.
|
|
|
|
|
2019-09-27 17:58:08 +00:00
|
|
|
Now you can create your first circuits, for example,
|
|
|
|
`app/circuits/multiplier.circom`:
|
2019-09-12 23:55:36 +00:00
|
|
|
|
|
|
|
```
|
2019-09-27 17:58:08 +00:00
|
|
|
template Multiplier() {
|
|
|
|
signal private input a;
|
|
|
|
signal private input b;
|
|
|
|
signal output c; c <== a*b;
|
|
|
|
}
|
2019-09-12 23:55:36 +00:00
|
|
|
|
2019-09-27 17:58:08 +00:00
|
|
|
component main = Multiplier();
|
2019-09-12 23:55:36 +00:00
|
|
|
```
|
|
|
|
|
2019-09-27 17:58:08 +00:00
|
|
|
Embark will now compile the circuits and generate a solidity contracts to
|
|
|
|
verify the proof as well as deploy it.
|
2019-09-12 23:55:36 +00:00
|
|
|
|
2019-09-27 17:58:08 +00:00
|
|
|
## Requirements
|
2019-09-12 23:55:36 +00:00
|
|
|
|
|
|
|
- Embark 5.0.0-alpha.0 or later
|
2019-09-27 17:58:08 +00:00
|
|
|
|
|
|
|
Visit [embark.status.im](https://embark.status.im/) to get started with
|
|
|
|
[Embark](https://github.com/embark-framework/embark).
|