This repository contains the code for the Near mpc node. It is a rewrite of Near mpc. This repository will be moved to Near mpc soon.
- Nearcore Node: This repository depends on the nearcore node, included as a submodule in the
/libs
directory. - Chain signatures: This repository contains squashed subtrees of the
contract
andcrypto-shared
folder from near/mpc/chain-signatures, required for integration tests. - Other Dependencies: All other dependencies are handled by Cargo.
There are two main parts of the binary: NEAR indexer and mpc signing:
-
NEAR Indexer: this is a NEAR node that tracks the shard where the signing smart contract is on. For mainnet, it is
v1.signer
. The indexer tracks incoming requests by looking at successful calls to thesign
function. Each request is hashed and gets mapped to a specific node in the mpc network, which is known as the leader for this specific request. The leader initiates the signing process and submits the final signature back to the smart contract. If the leader is offline, there is a secondary leader who can initiate the signing -
MPC signing: A threshold ecdsa implementation based on cait-sith. Each node does the following:
- Participates in Beaver triple generation in the background. Each node both initiates triple generation and passively participates in triple generation initiated by other nodes. This is constantly running until each node generates 1M Beaver triples.
- Presignature generation. It also runs in the background. Each presignature generation requires two Beaver triples.
- Signature generation. When a request comes in, a signature can be generated using a presignature and one round of communication.
One thing to note is that from Beaver triple generation to signature generation, the request denotes the participating set and it is guaranteed that if a Beaver triple is generated by a specific set of participants, presignatures and signatures using that Beaver triple is generated by the same set of participants.
- Unit Tests: Run with
cargo test --release
(--release
flag is advised for performance reasons). - integration Test : Located in the
/pytest
directory.
This repository uses rust-toolchain.toml
files, as some code sections may require specific compiler versions. Be aware of potential overrides from:
- Directory-specific toolchain overrides
- Environment variables
For more information, refer to the Rustup book on overrides.