• Stars
    star
    713
  • Rank 61,431 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created about 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Threshold Signature Scheme, for ECDSA and EDDSA

Multi-Party Threshold Signature Scheme

MIT licensed GoDoc Go Report Card

Permissively MIT Licensed.

Note! This is a library for developers. You may find a TSS tool that you can use with the Binance Chain CLI here.

Introduction

This is an implementation of multi-party {t,n}-threshold ECDSA (Elliptic Curve Digital Signature Algorithm) based on Gennaro and Goldfeder CCS 2018 1 and EdDSA (Edwards-curve Digital Signature Algorithm) following a similar approach.

This library includes three protocols:

  • Key Generation for creating secret shares with no trusted dealer ("keygen").
  • Signing for using the secret shares to generate a signature ("signing").
  • Dynamic Groups to change the group of participants while keeping the secret ("resharing").

โš ๏ธ Do not miss these important notes on implementing this library securely

Rationale

ECDSA is used extensively for crypto-currencies such as Bitcoin, Ethereum (secp256k1 curve), NEO (NIST P-256 curve) and many more.

EdDSA is used extensively for crypto-currencies such as Cardano, Aeternity, Stellar Lumens and many more.

For such currencies this technique may be used to create crypto wallets where multiple parties must collaborate to sign transactions. See MultiSig Use Cases

One secret share per key/address is stored locally by each participant and these are kept safe by the protocol โ€“ they are never revealed to others at any time. Moreover, there is no trusted dealer of the shares.

In contrast to MultiSig solutions, transactions produced by TSS preserve the privacy of the signers by not revealing which t+1 participants were involved in their signing.

There is also a performance bonus in that blockchain nodes may check the validity of a signature without any extra MultiSig logic or processing.

Usage

You should start by creating an instance of a LocalParty and giving it the arguments that it needs.

The LocalParty that you use should be from the keygen, signing or resharing package depending on what you want to do.

Setup

// When using the keygen party it is recommended that you pre-compute the "safe primes" and Paillier secret beforehand because this can take some time.
// This code will generate those parameters using a concurrency limit equal to the number of available CPU cores.
preParams, _ := keygen.GeneratePreParams(1 * time.Minute)

// Create a `*PartyID` for each participating peer on the network (you should call `tss.NewPartyID` for each one)
parties := tss.SortPartyIDs(getParticipantPartyIDs())

// Set up the parameters
// Note: The `id` and `moniker` fields are for convenience to allow you to easily track participants.
// The `id` should be a unique string representing this party in the network and `moniker` can be anything (even left blank).
// The `uniqueKey` is a unique identifying key for this peer (such as its p2p public key) as a big.Int.
thisParty := tss.NewPartyID(id, moniker, uniqueKey)
ctx := tss.NewPeerContext(parties)

// Select an elliptic curve
// use ECDSA
curve := tss.S256()
// or use EdDSA
// curve := tss.Edwards()

params := tss.NewParameters(curve, ctx, thisParty, len(parties), threshold)

// You should keep a local mapping of `id` strings to `*PartyID` instances so that an incoming message can have its origin party's `*PartyID` recovered for passing to `UpdateFromBytes` (see below)
partyIDMap := make(map[string]*PartyID)
for _, id := range parties {
    partyIDMap[id.Id] = id
}

Keygen

Use the keygen.LocalParty for the keygen protocol. The save data you receive through the endCh upon completion of the protocol should be persisted to secure storage.

party := keygen.NewLocalParty(params, outCh, endCh, preParams) // Omit the last arg to compute the pre-params in round 1
go func() {
    err := party.Start()
    // handle err ...
}()

Signing

Use the signing.LocalParty for signing and provide it with a message to sign. It requires the key data obtained from the keygen protocol. The signature will be sent through the endCh once completed.

Please note that t+1 signers are required to sign a message and for optimal usage no more than this should be involved. Each signer should have the same view of who the t+1 signers are.

party := signing.NewLocalParty(message, params, ourKeyData, outCh, endCh)
go func() {
    err := party.Start()
    // handle err ...
}()

Re-Sharing

Use the resharing.LocalParty to re-distribute the secret shares. The save data received through the endCh should overwrite the existing key data in storage, or write new data if the party is receiving a new share.

Please note that ReSharingParameters is used to give this Party more context about the re-sharing that should be carried out.

party := resharing.NewLocalParty(params, ourKeyData, outCh, endCh)
go func() {
    err := party.Start()
    // handle err ...
}()

โš ๏ธ During re-sharing the key data may be modified during the rounds. Do not ever overwrite any data saved on disk until the final struct has been received through the end channel.

Messaging

In these examples the outCh will collect outgoing messages from the party and the endCh will receive save data or a signature when the protocol is complete.

During the protocol you should provide the party with updates received from other participating parties on the network.

A Party has two thread-safe methods on it for receiving updates.

// The main entry point when updating a party's state from the wire
UpdateFromBytes(wireBytes []byte, from *tss.PartyID, isBroadcast bool) (ok bool, err *tss.Error)
// You may use this entry point to update a party's state when running locally or in tests
Update(msg tss.ParsedMessage) (ok bool, err *tss.Error)

And a tss.Message has the following two methods for converting messages to data for the wire:

// Returns the encoded message bytes to send over the wire along with routing information
WireBytes() ([]byte, *tss.MessageRouting, error)
// Returns the protobuf wrapper message struct, used only in some exceptional scenarios (i.e. mobile apps)
WireMsg() *tss.MessageWrapper

In a typical use case, it is expected that a transport implementation will consume message bytes via the out channel of the local Party, send them to the destination(s) specified in the result of msg.GetTo(), and pass them to UpdateFromBytes on the receiving end.

This way there is no need to deal with Marshal/Unmarshalling Protocol Buffers to implement a transport.

How to use this securely

โš ๏ธ This section is important. Be sure to read it!

The transport for messaging is left to the application layer and is not provided by this library. Each one of the following paragraphs should be read and followed carefully as it is crucial that you implement a secure transport to ensure safety of the protocol.

When you build a transport, it should offer a broadcast channel as well as point-to-point channels connecting every pair of parties. Your transport should also employ suitable end-to-end encryption (TLS with an AEAD cipher is recommended) between parties to ensure that a party can only read the messages sent to it.

Within your transport, each message should be wrapped with a session ID that is unique to a single run of the keygen, signing or re-sharing rounds. This session ID should be agreed upon out-of-band and known only by the participating parties before the rounds begin. Upon receiving any message, your program should make sure that the received session ID matches the one that was agreed upon at the start.

Additionally, there should be a mechanism in your transport to allow for "reliable broadcasts", meaning parties can broadcast a message to other parties such that it's guaranteed that each one receives the same message. There are several examples of algorithms online that do this by sharing and comparing hashes of received messages.

Timeouts and errors should be handled by your application. The method WaitingFor may be called on a Party to get the set of other parties that it is still waiting for messages from. You may also get the set of culprit parties that caused an error from a *tss.Error.

Security Audit

A full review of this library was carried out by Kudelski Security and their final report was made available in October, 2019. A copy of this report audit-binance-tss-lib-final-20191018.pdf may be found in the v1.0.0 release notes of this repository.

References

[1] https://eprint.iacr.org/2019/114.pdf

More Repositories

1

bsc

A BNB Smart Chain client based on the go-ethereum fork
Go
2,517
star
2

whitepaper

BNB Smart Chain
1,805
star
3

bsc-genesis-contract

The genesis contracts of BNB Smart Chain.
Solidity
630
star
4

BEPs

BNB Evolution Proposals
Solidity
518
star
5

bsc-ecosystem

A guide to available tools, components, and platforms for developing applications on BSC.
452
star
6

opbnb

Go
371
star
7

javascript-sdk

Javascript SDK to communicate with BNB Beacon Chain.
TypeScript
349
star
8

bnb-chain-tutorial

Detailed blockchain tutorials on BNB Chain.
JavaScript
232
star
9

bsc-snapshots

Shell
229
star
10

greenfield-whitepaper

Whitepaper for Greenfield, the decentralized data economy
217
star
11

zkbnb

A trustless and scaling solution for BNB Smart Chain
Go
211
star
12

go-sdk

Go
185
star
13

node-binary

Binaries for full nodes, light-weighted clients
Shell
179
star
14

bnb-chain.github.io

The official documentation for BNB Chain.
HTML
133
star
15

java-sdk

Java
121
star
16

greenfield

Greenfield is a decentralized storage platform.
Go
108
star
17

bsc-relayer

An implementation of relay service to relay cross chain packages from BNB Beacon Chain to BNB Smart Chain
Go
95
star
18

token-bind-tool

Tools and toturial for issuing BEP2 token on BNB Beacon Chain, deploying BEP20 token on BNB Smart Chain and binding the two tokens.
Go
84
star
19

node

Go
69
star
20

eth-bsc-swap-contracts

Solidity
64
star
21

opbnb-docs

JavaScript
54
star
22

awesome

A curated list of awesome projects in BNB Chain ecosystem
47
star
23

bsc-docker

Shell
45
star
24

bsc-eth-swap

Implementation of BSC and ETH swap
Go
43
star
25

tokens-info

Centralized repo for BEP2 token meta information (logo, website, social network, etc)
42
star
26

bsc-explorer

BNB Smart Chain Explorer based on Blockscout fork.
Elixir
41
star
27

greenfield-storage-provider

Greenfield Storage Provider is a storage infrastructure for Greenfield decentralized storage platform.
Go
40
star
28

canonical-upgradeable-bep20

Implement upgradeable bep20 contract
Solidity
40
star
29

zkbnb-contract

Solidity
39
star
30

op-geth

Go
38
star
31

peg-token-stats

37
star
32

bnc-cosmos-sdk

Go
35
star
33

bsc-erigon

A BNB Smart Chain client based on the erigon fork
Go
32
star
34

community-contributions

32
star
35

opbnb-node-docker

Shell
30
star
36

node-deploy

Shell
29
star
37

oracle-relayer

Oracle Relayer is responsible for relaying events of bsc to BNB Beacon Chain.
Go
27
star
38

greenfield-go-sdk

Go sdk for Greenfield
Go
24
star
39

validator-directory

validator-directory
23
star
40

greenfield-contracts

Smart contracts for Greenfield and BSC Cross-Chain communication.
Solidity
22
star
41

greenfield-docs

The official repository for the BNB Greenfield documentation website
JavaScript
22
star
42

greenfield-cmd

support cmd tool for Greenfield
Go
22
star
43

greenfield-cosmos-sdk

A cosmos-sdk fork for greenfield
Go
21
star
44

bsc-relayer-config

bsc-relayer cross chain protocol configuration
21
star
45

ledger-app-binance

application that enables Ledger hardware wallet to support Binance Chain.
C
21
star
46

greenfield-js-sdk

JS SDK for Greenfield
JavaScript
20
star
47

cplusplus-sdk

C
18
star
48

zkbnb-crypto

Go
18
star
49

greenfield-cometbft

Consensus layer, forked from CometBFT, for Greenfield blockchain
Go
18
star
50

greenfield-data-marketplace-frontend

Greenfield Data marketplace is a data exchange platform where users can freely create, list, trade, and sell data assets, including digital publications, scientific experimental data, and specific domain data, or even NFT can be treated as a kind of data.
TypeScript
16
star
51

zkbnb-js-sdk

TypeScript
15
star
52

zkbnb-setup

MPC Ceremony Tool for Groth16 setup of zkBNB circuits
Go
15
star
53

bnc-tendermint-iavl

Go
14
star
54

zkbnb-mpc-ceremony

13
star
55

avengerdao

13
star
56

bnc-tendermint

Go
13
star
57

cross-chain-transfer-sample

Samples for cross chain transfer between BNB Beacon Chain and BNB Smart Chain
Java
13
star
58

Kickstart

13
star
59

token-canal-project

Project Token Canal is a new initiative, similar to many existing โ€˜wrapped coinsโ€™ in the crypto community, Binance.com, the largest crypto token vault and exchange, will stand to issue and bind more token assets on Binance Chain, Binance Smart Chain and Ethereum, and guarantee the conversion from and to the original tokens with our own credibility and infrastructure.
Solidity
13
star
60

zkbnb-smt

Go
12
star
61

chain-tooling

Tools and ecosystem kits
Shell
11
star
62

bsc-go-client

Go
10
star
63

bep3-deputy

Go
10
star
64

bsc-smart-contract-tutorials

Solidity
10
star
65

zkbnb-go-sdk

Go
10
star
66

wallet-assets

Assets for Binance Wallet.
10
star
67

bnc-go-amino

Go
10
star
68

zkBNB-docs

JavaScript
9
star
69

bsc-double-sign-sdk

This is a complementary sdk to Binance Chain go-sdk, which can be used to submit BSC double sign proof
Go
9
star
70

greenfield-contracts-sdk

A library of smart contracts for the Greenfield
Solidity
9
star
71

bep3-smartcontracts

Smart Contracts for BEP3 implementation on different blockchains.
JavaScript
8
star
72

zkbnb-js-l1-sdk

TypeScript
7
star
73

zkbnb-reactjs-integration-example

TypeScript
7
star
74

bas-genesis-config

Solidity
7
star
75

juno

Go
7
star
76

bc-snapshots

6
star
77

opbnb-bridge-tokens

TypeScript
6
star
78

greenfield-cometbft-db

A cometbft-db fork for greenfield
Go
6
star
79

tss

Threshold Signature Scheme for ECDSA
Go
5
star
80

opbnb-snapshot

TypeScript
5
star
81

BSC-Truffle-Starter-Box

Boilerplate code for deploying smart contracts to the BNB Smart Chain network.
JavaScript
5
star
82

Grant-projects

BNB Smart Chain development grants program
5
star
83

bas-template-bsc

Go
4
star
84

zkbnb-eth-rpc

Go
4
star
85

bscSetUp

Go
4
star
86

bep20-issue-mirror-stats

Go
4
star
87

greenfield-challenger

Off-chain data availability challenge service for Greenfield
Go
4
star
88

greenfield-common

support common lib for Greenfield chain and Greenfiled Storage Provider
Go
4
star
89

greenfield-relayer

Greenfield and BSC bidirectional cross-chain package relaying tool
Go
4
star
90

greenfield-execution-provider

PoC of Greenfield executable
Go
4
star
91

wallet-core-carthage

Carthage support for wallet-core
Swift
4
star
92

greenfield-python-sdk

Python
3
star
93

bsc-tendermint-rs

Rust
3
star
94

developer-tools-list

3
star
95

BSC-State-Expiry

3
star
96

bas-devnet-setup

Shell
3
star
97

wallet-contract

JavaScript
3
star
98

greenfield-cosmos-types

JavaScript and TypeScript types relating to Protocol Buffers
TypeScript
3
star
99

zk-rollup-webui

TypeScript
3
star
100

greenfield-data-marketplace-contracts

Greenfield-data-marketplace is a marketplace protocol for safely and efficiently buying and selling data uploaded in Greenfield.
Solidity
3
star