• Stars
    star
    110
  • Rank 316,770 (Top 7 %)
  • Language
    TypeScript
  • License
    GNU General Publi...
  • Created over 5 years ago
  • Updated almost 2 years ago

Reviews

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

Repository Details

Javascript threshold signatures SDK

Build Status NPM

Two Party signatures JS SDK

Supports:

Algorithm Curve Compatible blockchains
ECDSA Secp256k1 Bitcoin, Ethereum
Schnorr Secp256k1 Zilliqa
EdDSA Curve25519 Tezos, Libra

Installation:

  1. If on Linux, install needed packages:
$ sudo apt-get update
$ sudo apt-get install libgmp3-dev pkg-config libssl-dev clang libclang-dev
  1. Install Node.js
    (tested on Node 10)
  2. Install nightly Rust
    (tested on rustc 1.38.0-nightly (0b680cfce 2019-07-09))
  3. Install the package:
$ npm install @kzen-networks/thresh-sig

Alternatively, clone it:

$ git clone https://github.com/KZen-networks/thresh-sig-js
$ cd thresh-sig-js
$ npm install
$ npm run build

Usage:

Start party one's server (acts as the co-signer in the two-party signature scheme):

const { Party1 } = require('@kzen-networks/thresh-sig');
const p1 = new Party1();
p1.launchServer();

ECDSA party two:

const { EcdsaParty2 } = require('@kzen-networks/thresh-sig');
const crypto = require('crypto');

const P1_ENDPOINT = 'http://localhost:8000';

(async () => {
    const party2 = new EcdsaParty2(P1_ENDPOINT);
    const party2MasterKeyShare = await party2.generateMasterKey();
    const party2ChildShare = party2.getChildShare(party2MasterKeyShare, 0, 0);
    const msgHash = crypto.createHash('sha256').update('some message').digest();
    const signature = await party2.sign(msgHash, party2ChildShare, 0, 0);
    console.log(JSON.stringify(signature));
    // {"r": <32-bytes-hex>,"s": <32-bytes-hex>,"recid": <0 or 1>}
})();

Schnorr party two:

const { SchnorrParty2 } = require('@kzen-networks/thresh-sig');
const crypto = require('crypto');

const P1_ENDPOINT = 'http://localhost:8000';

(async () => {
    const party2 = new SchnorrParty2(P1_ENDPOINT);
    const party2Share = await party2.generateKey();
    const msgHash = crypto.createHash('sha256').update('some message').digest();
    const signature = await party2.sign(msgHash, party2Share);
    console.log(JSON.stringify(signature));
    // {"e": <32-bytes-hex>,"s": <32-bytes-hex>}
})();

EdDSA party two:

const { Ed25519Party2 } = require('@kzen-networks/thresh-sig');
const crypto = require('crypto');

const P1_ENDPOINT = 'http://localhost:8000';

(async () => {
    const party2 = new Ed25519Party2(P1_ENDPOINT);
    const party2Share = await party2.generateKey();
    console.log(party2Share.getAggregatedPublicKey().apk.bytes_str);
    // <32-bytes-hex>
    const msgHash = crypto.createHash('sha256').update('some message').digest();
    const signature = await party2.sign(msgHash, party2Share);
    console.log(JSON.stringify(signature));
    // {"R":{"bytes_str":<32-bytes-hex>},"s":<32-bytes-hex>}
})()

Demo:

You can run a command line demo and see the two-party signing protocol in action.
Party one:

$ node ./demo/party1.js
πŸ”§ Configured for production.
    => address: 0.0.0.0
    => port: 8000
    => log: critical
    => workers: 24
    => secret key: generated
    => limits: forms = 32KiB
    => keep-alive: 5s
    => tls: disabled
πŸš€ Rocket has launched from http://0.0.0.0:8000

Party two (separate shell) -

  1. ECDSA:
$ node ./demo/ecdsa-party2.js
{"r":"b3d6168cc8ab6da64697b9e81c55863078da65cac7bbebc3d3f747dae0c6ac16","s":"449052412e20e510f8d4e31d721b3ef42199a9886a58a058c42d142b5850a177","recid":0}
  1. Schnorr:
$ node ./demo/schnorr-party2.js
{"e":"d960b3fe66d2dc1c2115c93b3e674344d73063c22148ff3bc8d67493ffb19814","s":"ed2ecaa8882ccaac946bf951835033d4326aaff2e1e466ecf1fdda32a6fc762b"}
  1. EdDSA:
$ node ./demo/eddsa-party2.js
{"R":{"bytes_str":"d86c5da0a257fd66acd007776f28d9f7a5083f84c66a41c98104c11cc5e9eaa3"},"s":"9964b5053843d6f6ddfaa25977f14f55676ae8a0e6bf89eafb412f417257abc"}

Contact

Feel free to reach out or join ZenGo X Telegram for discussions on code and research.

More Repositories

1

multi-party-ecdsa

Rust implementation of {t,n}-threshold ECDSA (elliptic curve digital signature algorithm).
Rust
975
star
2

awesome-tss

A curated list of distributed key generation and threshold signatures implementations
271
star
3

curv

Rust language general purpose elliptic curve cryptography.
Rust
264
star
4

gotham-city

Gotham city is a fully functional project to demonstrate real-life example of minimalist Bitcoin decentralized HD wallet using 2 party ECDSA
Rust
192
star
5

multi-party-schnorr

Rust implementation of multi-party Schnorr signatures over elliptic curves.
Rust
170
star
6

multi-party-eddsa

Rust implementation of multi party Ed25519 signature scheme.
Rust
132
star
7

zk-paillier

A collection of Paillier cryptosystem zero knowledge proofs
Rust
113
star
8

white-city

Network layer for MPC (Secure Multi-Party Computation) based on Tendermint
Rust
103
star
9

mnemonic-recovery

Bitcoin and Ethereum mnemonic phrase recovery tool
HTML
81
star
10

kms-secp256k1

Multi Party Key Management System (KMS) for Secp256k1 Elliptic curve based digital signatures.
Rust
72
star
11

bulletproofs

Bulletproofs and Bulletproofs+ Rust implementation for Aggregated Range Proofs over multiple elliptic curves
Rust
71
star
12

multi-party-bls

Threshold BLS signatures in Rust
Rust
69
star
13

class

Rust library for building IQC: cryptography based on class groups of imaginary quadratic orders
C
63
star
14

mpc-over-signal

Secure transport for running MPC protocols backed by Signal
Rust
62
star
15

binance-thresh-wallet

Wallet for Binance chain powered by two-party ECDSA
TypeScript
51
star
16

ShareLock

ShareLock: mixing for cryptocurrencies from multiparty ECDSA
JavaScript
50
star
17

multi-hop-locks

ECDSA based construction for Anonymous Multi-Hop Locks (https://eprint.iacr.org/2018/472.pdf)
Rust
43
star
18

big-spender

A tool for checking BigSpender vulnerability in your Bitcoin wallet
JavaScript
38
star
19

JugglingSwap

Scriptless atomic cross-chain (and cross-curve) swap protocol based on a fair exchange of secrets.
TypeScript
33
star
20

fs-dkr

FS-DKR: One Round Distributed Key Rotation
Rust
32
star
21

solana-tss

PoC of TSS in Solana blockchain
Rust
27
star
22

round-based-protocol

Driver for round-based protocols in Rust
Rust
23
star
23

vdf

Simple RSA VDF in Rust
Rust
19
star
24

thresh-rust-u2f

U2f implementation with threshold signatures
Rust
16
star
25

terra-multisend

A multisend smart contract for the Terra blockchain using CosmWasm
Rust
16
star
26

inspirational-crypto

A list of exceptionally good cryptography libraries that inspire our work
16
star
27

emerald-city

WASM/HW-friendly lightweight client application for threshold ECDSA
Rust
15
star
28

zengo-will

Rust
15
star
29

vice-city

distributed RSA modulus generation in Rust
Rust
15
star
30

rust-elgamal

Rust implementation of ElGamal encryption
Rust
14
star
31

compound-playground

Basic interaction with the Compound suite of smart contracts
TypeScript
13
star
32

paradise-city

Rust implementation of Zcash multi-signautres
Rust
13
star
33

two-party-ecdsa

Rust
13
star
34

dlog-verifiable-enc

JS Implementation of Practical Verifiable Encryption and Decryption of Discrete Logarithms
Rust
13
star
35

two-party-musig2-eddsa

Rust
12
star
36

centipede

A scheme for instantiating KMS's with recovery
Rust
12
star
37

tss-bugs

supplement material for BlackHat2020 talk: Multiple Bugs in Multi-Party Computation: Breaking Cryptocurrency's Strongest Wallets
12
star
38

flippable-operator-filterer

Solidity
11
star
39

Ethereum2.0-Resources

A succinct list of the best Ethereum 2.0 resources
10
star
40

silent-ecdsa

Rust
10
star
41

extra-ordinaire

Inscription trading implementation in Rust
Rust
9
star
42

badger_dao_script_analysis

An ongoing analysis of Badger Dao's script
JavaScript
7
star
43

ZenGo

Repository related to ZenGo: Bitcoin & Crypto Wallet
6
star
44

signature-simulation

Solidity
6
star
45

cosmos-thresh-wallet

Cosmos full featured wallet working with 2 party ECDSA
TypeScript
5
star
46

random-beacon

Rust
5
star
47

terra-thresh-wallet

A new implementation for Terra wallet using the new sdk
TypeScript
5
star
48

crypto-key-calculator

This project is based on a paper by Ittai Eyal et al. that looked into different key configurations used for crypto wallets and their probability of being compromised.
JavaScript
5
star
49

two-party-eddsa-wrapper

Client-server wrapper for Two-Party EdDSA
Rust
4
star
50

taquito-taquito

TypeScript
4
star
51

gotham-engine

Traits for abstracting 2MPC signing infrastructure of gotham-city server
Rust
4
star
52

TLS-masterkey-recovery

Python
4
star
53

pps-gc

Rust
3
star
54

rust-utils

Utilities and documentation for coding in Rust
3
star
55

libs-core-bindings

Rust
2
star
56

CHILL-STORAGE-TM-bitcoin-export-privkey

Export a ZenGo constructed private key to WIF & address
JavaScript
2
star
57

pps

Stealth addresses based on inner product FE
Go
2
star
58

klaytn-thresh-wallet

Klaytn wallet powered by Two-Party ECDSA
JavaScript
2
star
59

Bad_randomness_tls_client_handshake_pure_python

Python
2
star
60

anchor-playground

Playground for basic functionality and explanation about the Anchor protocol
TypeScript
1
star
61

spec-multi-party-ecdsa

This project is a Haskell implementation of multi-party ECDSA protocol spec.
1
star
62

crypto-gmp

Rust
1
star
63

walletconnect-premint-test

TypeScript
1
star
64

smart-contracts-workshop

JavaScript
1
star
65

foundry-workshop

Solidity
1
star
66

public-docs

Zengo's repository of public docs, white papers, etc.
1
star
67

walletconnect-tokenproof-test

TypeScript
1
star