Code Monkey home page Code Monkey logo

zk-email-test's Introduction

zk-email-test

使用步骤

  1. 根据自己本机环境选择是否需要提供的脚本进行各种依赖的安装(node、yarn、git、rust、circom、snarkjs)

  2. install:

    yarn install
  3. 进入 packages 目录:

    cd packages
    chmod +x *.sh
  4. 进行setup:

    ./setup.sh
    ./setup.sh pick-two demo-zk-email-two build-two
    ./setup.sh pick-three demo-zk-email-three build-three
  5. 使用官方snarkjs生成proof(单进程、多进程):

    ./generate-proof.sh
    ./generate-proof.sh pick-one demo-zk-email-one build-one proofs-one 10 parallel 3
    ./generate-proof.sh pick-two demo-zk-email-two build-two proofs-two 1 serial
    ./generate-proof.sh pick-two demo-zk-email-two build-two proofs-two 10 parallel 3
    ./generate-proof.sh pick-three demo-zk-email-three build-three proofs-three 1 serial
    ./generate-proof.sh pick-three demo-zk-email-three build-three proofs-three 10 parallel 3
  6. 安装rapidsnark:

    ./rapidsnark-install.sh
  7. 使用rapidsnark生成pick-one电路的proof:

    ./generate-proof-with-rapidsnark.sh
  8. 使用官方snarkjs生成proof(多线程):

    npx ts-node generate-proof-parallel.ts
    npx ts-node generate-proof-parallel.ts --working-dir pick-one --thread-num 2 --iteration-num 2
    npx ts-node generate-proof-parallel.ts --working-dir pick-two --circuit-name demo-zk-email-two   --build-dir build-two --output-dir proofs-two-parallel --thread-num 2 --iteration-num 2
    npx ts-node generate-proof-parallel.ts --working-dir pick-three --circuit-name demo-zk-email-three --build-dir build-three --output-dir proofs-three-parallel --thread-num 2 --iteration-num 2
  9. 其他电路请参考脚本开头注释

问题

yarn 报错

yarn install v1.22.22
info No lockfile found.
[1/4] Resolving packages...
error Error: certificate has expired
    at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
    at TLSSocket.emit (node:events:519:28)
    at TLSSocket._finishInit (node:_tls_wrap:1085:8)
    at ssl.onhandshakedone (node:_tls_wrap:871:12)

禁用SSL检查即可,因为是临时测试demo,无需严格SSL yarn config set strict-ssl false

内存不足

snarkjs g16s demo-zk-email-six-big.r1cs ../../powersOfTau28_hez_final_24.ptau demo-zk-email-six-big_0000.zkey
[INFO]  snarkJS: Reading r1cs
[INFO]  snarkJS: Reading tauG1
[INFO]  snarkJS: Reading tauG2
[INFO]  snarkJS: Reading alphatauG1
[INFO]  snarkJS: Reading betatauG1
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

先限制 node 进程使用的内存大小 NODE_OPTIONS=--max_old_space_size=32768 再设置系统内核参数,调整进程能创建的内存映射区域数量,将默认值放大10倍吧 sysctl -w vm.max_map_count=655300 && sysctl -p 引用:https://hackmd.io/V-7Aal05Tiy-ozmzTGBYPA?view

zk-email-test's People

Contributors

yehanlong avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.