Skip to content

nimiq/snark-setup-operator

 
 

Repository files navigation

SNARK setup operator

The operator is responsible for monitoring and verifying the operation of the coordinator.

Tools included:

  • contribute - run a contributor or a verifier.

  • monitor - checks the status of the setup:

    • Did any participants get stuck?
    • Did a new round start?
    • Did a participant start or finish contributing?
    • Did a chunk's verification timeout?
    • Did a chunk lock timeout?
    • Did all setups finish?
  • verify_transcript - given a coordinator state and participant IDs, verifies the entire setup as run by the coordinator:

    • Verify each contribution in each chunks, including signatures and the hash chain.
    • Combine and apply the beacon.
    • Verify ratios hold.
  • control - perform ceremony update operations:

    • add-participant - add a contributor.
    • add-verifier - add a verifier.
    • remove-participant - remove a contributor, release the locks they hold and delete contributions they were part of and their descendants.
    • remove-verifier - remove a verifier and release the locks they hold.
  • new_ceremony - initialize a ceremony.

Compilation

Native

On Linux and macOS, building directly with cargo build --release should work, as long as you have the usual build toolchain installed (e.g. build-essential on Ubuntu). To build without ADX and BMI2 support, use cargo build --release --no-default-features.

On Windows, you have to use the GNU toolchain to compile and have the following in your PATH:

Cross compilation

Requires Docker.

Use the cross_compile.sh script in scripts, with one of linux, windows, macos, macos-m1. This will create an out folder in build with the binaries for that OS.

For example, to build for windows, you run ./scripts/cross_compile.sh windows and you'll find contribute-windows.exe, generate-windows.exe, contribute-windows-noasm.exe and generate-windows-noasm.exe in ./build/out.

The no-asm binaries will run on CPUs without ADX and BMI2 support, which has been introduced around 2015.

Testing

Generate keys for verifier and contributor:

cargo run --release --bin generate -- -k nimiq-verifier.keys
cargo run --release --bin generate -- -k nimiq-contributor.keys

Sample test file:

{
    "version": 0,
    "maxLocks": 3,
    "round": 0,
    "shutdownSignal": false,
    "contributorIds": [
    ],
    "verifierIds": [
        "public key from nimiq-verifier.keys"
    ],
    "chunks": [
    ]
}

Contents of .env:

COORDINATOR_CONFIG_PATH=ceremony/test.json
COORDINATOR_AUTH_TYPE=celo

Initializing ceremony:

RUST_LOG=info cargo run --bin new_ceremony --release -- --server-url http://localhost:8080 --verifier $(cat nimiq-verifier.keys | jq .publicKey -r) --deployer $(cat nimiq-verifier.keys | jq .publicKey -r) --output-dir ~/snark-setup-coordinator/coordinator-service/.storage -k nimiq-verifier.keys

Initializing setup:

echo 1 | RUST_LOG=info cargo run --bin new_setup --release -- --version 1 --chunk-size 10 --powers 12 --upload-mode direct --circuit-filename circuit_2992c --server-url http://localhost:8080 --output-dir ~/snark-setup-coordinator/coordinator-service/.storage --unsafe-passphrase --keys-file $BASE_DIR/nimiq-verifier.keys

Add the test participant and verifier:

RUST_LOG=info cargo run --bin control --release -- --keys-file nimiq-verifier.keys add-participant --participant-id $(cat nimiq-contributor.keys | jq .publicKey -r)
RUST_LOG=info cargo run --bin control --release -- --keys-file nimiq-verifier.keys add-verifier --participant-id $(cat nimiq-verifier.keys | jq .publicKey -r)

Contribute:

RUST_LOG=info cargo run --bin contribute --release -- --keys-file nimiq-contributor.keys

Verify contribution:

RUST_LOG=info cargo run --bin contribute --release -- --participation-mode verify --keys-file nimiq-verifier.keys

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 86.2%
  • Shell 12.7%
  • Other 1.1%