[ZKP]Nova Scotia: Middleware to compile Circom circuits to Nova prover

Nova Scotia: Middleware to compile Circom circuits to Nova prover

[Reference: https://github.com/nalinbhardwaj/Nova-Scotia]

My device: Macbook Pro 2020 with Intel chip

git clone https://github.com/nalinbhardwaj/Nova-Scotia.git
cd Nova-Scotia
cargo build
cargo run --example toy_bn254 #Available examples: bitcoin, toy_bn254, toy_pasta

toy_bn254.rs

fn main() {
    let group_name = "bn254";

    let circuit_filepath = format!("examples/toy/{}/toy.r1cs", group_name);
    for witness_gen_filepath in [
        format!("examples/toy/{}/toy_cpp/toy", group_name),
        format!("examples/toy/{}/toy_js/toy.wasm", group_name),
    ] {
        run_test(circuit_filepath.clone(), witness_gen_filepath);
    }
}

toy_circuit

pragma circom 2.0.3;

// include "https://github.com/0xPARC/circom-secp256k1/blob/master/circuits/bigint.circom";

template Example () {
    signal input step_in[2];

    signal output step_out[2];

    signal input adder;

    step_out[0] <== step_in[0] + adder;
    step_out[1] <== step_in[0] + step_in[1];
}

component main { public [step_in] } = Example();

/* INPUT = {
    "step_in": [1, 1],
    "step_out": [1, 2],
    "adder": 0
} */

example = toy_bn254

Running test with witness generator: examples/toy/bn254/toy_cpp/toy and group: halo2curves::bn256::curve::G1
Number of constraints per step (primary circuit): 9987
Number of constraints per step (secondary circuit): 10536
Number of variables per step (primary circuit): 9982
Number of variables per step (secondary circuit): 10518
Creating a RecursiveSNARK...
RecursiveSNARK creation took 13.224248261s
Verifying a RecursiveSNARK...
RecursiveSNARK::verify: Ok(([0x0000000000000000000000000000000000000000000000000000000000000014, 0x0000000000000000000000000000000000000000000000000000000000000046], [0x0000000000000000000000000000000000000000000000000000000000000000])), took 3.157009284s
Generating a CompressedSNARK using Spartan with IPA-PC...
CompressedSNARK::prove: true, took 70.214257205s
Verifying a CompressedSNARK...
CompressedSNARK::verify: true, took 2.716456417s
Adding steps to our RecursiveSNARK...
Adding 2 steps to our RecursiveSNARK took 6.124253293s
Verifying a RecursiveSNARK...
RecursiveSNARK::verify: Ok(([0x000000000000000000000000000000000000000000000000000000000000001f, 0x0000000000000000000000000000000000000000000000000000000000000073], [0x0000000000000000000000000000000000000000000000000000000000000000])), took 3.17058345s
Running test with witness generator: examples/toy/bn254/toy_js/toy.wasm and group: halo2curves::bn256::curve::G1
Number of constraints per step (primary circuit): 9987
Number of constraints per step (secondary circuit): 10536
Number of variables per step (primary circuit): 9982
Number of variables per step (secondary circuit): 10518
Creating a RecursiveSNARK...
RecursiveSNARK creation took 13.44364122s
Verifying a RecursiveSNARK...
RecursiveSNARK::verify: Ok(([0x0000000000000000000000000000000000000000000000000000000000000014, 0x0000000000000000000000000000000000000000000000000000000000000046], [0x0000000000000000000000000000000000000000000000000000000000000000])), took 3.164956873s
Generating a CompressedSNARK using Spartan with IPA-PC...
CompressedSNARK::prove: true, took 71.255975254s
Verifying a CompressedSNARK...
CompressedSNARK::verify: true, took 2.705070478s
Adding steps to our RecursiveSNARK...
Adding 2 steps to our RecursiveSNARK took 6.359241709s
Verifying a RecursiveSNARK...
RecursiveSNARK::verify: Ok(([0x000000000000000000000000000000000000000000000000000000000000001f, 0x0000000000000000000000000000000000000000000000000000000000000073], [0x0000000000000000000000000000000000000000000000000000000000000000])), took 3.185926252s

example = toy_pasta

Running test with witness generator: examples/toy/pasta/toy_cpp/toy and group: pasta_curves::curves::Ep
Number of constraints per step (primary circuit): 9819
Number of constraints per step (secondary circuit): 10347
Number of variables per step (primary circuit): 9814
Number of variables per step (secondary circuit): 10329
Creating a RecursiveSNARK...
RecursiveSNARK creation took 4.414209623s
Verifying a RecursiveSNARK...
RecursiveSNARK::verify: Ok(([0x0000000000000000000000000000000000000000000000000000000000000014, 0x0000000000000000000000000000000000000000000000000000000000000046], [0x0000000000000000000000000000000000000000000000000000000000000000])), took 370.838978ms
Generating a CompressedSNARK using Spartan with IPA-PC...
CompressedSNARK::prove: true, took 32.915398792s
Verifying a CompressedSNARK...
CompressedSNARK::verify: true, took 345.546614ms
Running test with witness generator: examples/toy/pasta/toy_js/toy.wasm and group: pasta_curves::curves::Ep
Number of constraints per step (primary circuit): 9819
Number of constraints per step (secondary circuit): 10347
Number of variables per step (primary circuit): 9814
Number of variables per step (secondary circuit): 10329
Creating a RecursiveSNARK...
RecursiveSNARK creation took 4.407457827s
Verifying a RecursiveSNARK...
RecursiveSNARK::verify: Ok(([0x0000000000000000000000000000000000000000000000000000000000000014, 0x0000000000000000000000000000000000000000000000000000000000000046], [0x0000000000000000000000000000000000000000000000000000000000000000])), took 266.348024ms
Generating a CompressedSNARK using Spartan with IPA-PC...
CompressedSNARK::prove: true, took 32.952874742s
Verifying a CompressedSNARK...
CompressedSNARK::verify: true, took 332.043144ms

Some Error and solution:

stdout: stderr: dyld[3280]: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib

  Referenced from: <70F76335-7705-34A9-B709-6DD492286528> /path/to/Nova-Scotia/examples/toy/pasta/toy_cpp/toy
  Reason: tried: /some/possible/paths/
brew update && brew install gmp
brew ls gmp
cp /opt/homebrew/Cellar/gmp/6.3.0/lib/libgmp.10.dylib /one/of/the/possible/paths/

Notes: Cannot run on the MacOS with m1/m2 chips 😦
(Error: have ‘arm64’, need ‘x86_64’)

  • 11
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值