This file provides guidance to code agents when working in this repository.
# Build
cargo build -p mpc-node --release # Build MPC node
cargo near build non-reproducible-wasm --features abi --profile=release-contract --manifest-path crates/contract/Cargo.toml --locked # Build contract
# Test - warning, many tests are currently slow, prefer to run specific tests during development
cargo nextest run --cargo-profile=test-release --all-features # With nextest
# Run single test
cargo nextest run --cargo-profile=test-release test_name
# Linting and checks
cargo make check-all-fast # Fast checks (no tests)
cargo make check-all # All checks including tests
cargo clippy --all-targets --locked -- -D warnings
cargo fmt -- --checkcd pytest
pytest # Run all tests
pytest -m "not slow" # Skip slow tests
pytest --non-reproducible tests/path/test.py::test_name # Single testThis is a Threshold Signature Scheme (TSS) implementation on NEAR blockchain. Users submit signature requests to an on-chain contract, and MPC nodes collaboratively generate signatures without any single party possessing the complete key.
- NEAR Indexer: Monitors the signer contract (
v1.signeron mainnet) for incomingsignrequests - MPC Signing: Threshold ECDSA based on cait-sith library with:
- Background Beaver triple generation (up to 1M per node)
- Presignature generation (requires 2 triples each)
- Signature generation (1 round using a presignature)
| Crate | Purpose |
|---|---|
mpc-node |
Main node binary: indexer, coordinator, P2P networking, signature protocols |
mpc-contract |
NEAR smart contract: manages requests, participant set, protocol state |
contract-interface |
DTOs for contract communication |
mpc-primitives |
Core domain types (domain IDs, signature schemes) |
mpc-tls |
TLS transport for secure P2P communication |
test-utils |
Testing utilities for integration tests |
providers/: Signature implementations (ECDSA, EdDSA, CKD)coordinator.rs: Main state machine watching contract state, spawning MPC jobsprotocol.rs: Generic threshold protocol runnernetwork.rs: Mesh network with task-based multiplexingp2p.rs: TLS-based persistent connectionsindexer/: Blockchain monitoring, transaction submissiondb.rs: RocksDB persistence for keyshares, triples, presignatures
NotInitialized → Running ↔ Initializing/Resharing
- Running: Normal operation (signing, CKD requests)
- Initializing: Key generation across multiple domains
- Resharing: Key redistribution after participant changes
- User calls
sign()on contract - Indexer detects receipt, adds to SignRequestStorage
- Coordinator spawns signature provider job
- Provider acquires triple/presignature, runs FROST protocol
- Nodes exchange partial signatures via P2P
- Final signature submitted back to contract
- Unit test: Rust test in
/srcfolder - Integration test: Rust test in
/testsfolder - System test: pytest in
/pytestfolder