Torus
This repo implements a Torus node. It acts as the backend for generation of private keys for Torus users in a threshold manner using publicly verifiable secret sharing (PVSS).
Node Lifecycle
Nodes communicate between one another using Tendermint, which is used for coordination, ordering key assignments, and publishing public information.
The phases of a node's operation are as follows:
- Selection
- Key Generation
- Distribution
- Decommission
These phases are then repeated for a new selection of nodes after an epoch ends. During the selection process, nodes consult a canoncial Ethereum smart contract to retrieve public key and connection details for other nodes in their epoch. They then broadcast their intent to start the key generation phase to other nodes. Upon receiving confirmation from all other nodes, nodes start generating keys using PVSS, and publish their public proofs to Tendermint. Nodes then verify their shares against these public proofs to ensure that they are verified, and flag discrepancies.
After nodes have generated an ordered batch of keys in this manner, they broadcast their intent to stop key generation and enter the distribution phase. During the distribution phase, nodes allow requests for key assignments, and ordering for such assignments across nodes is synchronised over Tendermint. This mapping is stored in the application state. When users request for their private key shares, they provide nodes with valid OAuth credentials, which is authenticated individually by nodes. Nodes should reject OAuth proofs that have been received before, to prevent transaction replay attacks.
When an epoch ends, nodes decommission by using proactive secret sharing (PSS) to reshare their secrets with nodes in the next epoch.
- Node List Smart Contract
- PVSS
- Key Assignments
- Intra-epoch Key Generation
- PSS
- Fraud Proofs
Node Setup
Local Development
Requirements:
- local Docker daemon running
- docker-compose installed
In the root directory, you will find docker-compose.yml
which will start the following containers:
- Ganache instance
- 5 Torus Nodes using default envs you can see here:
config/config.local.1.json
config/config.local.2.json
config/config.local.3.json
config/config.local.4.json
config/config.local.5.json
To start it, execute:
./scripts/localDockerTest.sh
Staging Environment / Testnet
https://nodeX.staging.dev.tor.us
Updating Dependencies
If you update dependencies in the repository, execute:
./scripts/updateDeps.sh
This script does the following 3 steps:
- Tidy it
go mod tidy
- Vendor it
go mod vendor
- Fix go mod not vendoring C libraries
go get -u github.com/ethereum/go-ethereum@v1.8.20
rm -rf vendor/github.com/ethereum/go-ethereum/crypto
cp -a $GOPATH/pkg/mod/github.com/ethereum/go-ethereum@v1.8.20/crypto vendor/github.com/ethereum/go-ethereum/crypto
chmod -R 755 vendor/github.com/ethereum/go-ethereum/crypto
If you wish to revendor all dependencies, please take note of the specific versions of github.com/torusresearch/* dependencies
before deleting the go.mod file, in order to ensure compatibility.
Linting
Use golangci-lint for linting, execute:
golangci-lint run
Additional Reading
Feldman's Scheme for Verifiable Secret Sharing (VSS)
Asynchronous Verifiable Secret Sharing (AVSS)
Secure Distributed Key Generation (DKG)