npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@kzen-networks/thresh-sig

v0.4.2

Published

Threshold signatures based on two-party ECDSA

Downloads

61

Readme

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 the KZen Research Telegram for discussions on code and research.