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

@cmdcode/frost

v1.0.5

Published

Flexible, round-optimized schnorr threshold signatures for Bitcoin.

Downloads

20

Readme

FROST

Flexible round-optimized schnorr threshold signatures for Bitcoin.

How to Use

The FROST protocol specifies two rounds for producing a threshold signature.

Initial setup of parameters (using a trusted dealer):

This repository use a trusted dealer method for demonstration purposes. Feel free to use your own DKG protocol for generating and distributing shares.

import { create_key_group } from '@cmdcode/frost/lib'
import { random_bytes }     from '@cmdcode/frost/util'

// Generate a random secret key and message.
const seckey  = random_bytes(32).hex
const message = random_bytes(32).hex

// Configure the paramaters of the group.
const secrets   = [ seckey ]
const threshold = 2
const share_max = 3

// Generate a group of secret shares.
const group = create_key_group(secrets, threshold, share_max)

Round 1 Example (nonce commitments):

Each member that is participating in the signing round must first create a nonce commitment:

import { create_commit_pkg } from '@cmdcode/frost/lib'

// Select a threshold (t) amount of shares and create nonce commitments.
const shares  = group.shares.slice(0, threshold)
const commits = shares.map(e => create_commit_pkg(e))

Each member then distributes their nonce commitment to other members.

Round 2 Example (signing with secret shares):

Once all participating member commitments have been collected, we can now produce a partial signature:

import {
  get_commit_pkg,
  get_session_context,
  sign_msg,
  verify_partial_sig
} from '@cmdcode/frost/lib'

// Compute the context data for the signing session.
const ctx = get_session_ctx(group.pubkey, commits, message)

// Convert the share indices into iterable numbers.
const idx = ctx.indexes.map(i => Number(i) - 1)

// Collect a partial signature from each share.
const psigs = idx.map(i => {
  const share  = shares[i]
  const commit = get_commit_pkg(commits, share)
  const sig    = sign_msg(ctx, share, commit)
  if (!verify_partial_sig(ctx, commit, sig.pubkey, sig.psig)) {
    throw new Error('sig share failed validation')
  }
  return sig
})

When the partial signatures have been collected, we can aggregate them into a full signature:

import { combine_partial_sigs, verify_final_sig } from '@cmdcode/frost/lib'

// Aggregate the partial signatures into a single signature.
const signature = combine_partial_sigs(ctx, psigs)

// Check that the signature is valid.
const is_valid  = verify_final_sig(ctx, message, signature)

console.log('is valid:', is_valid)

Development and Testing

To run the test suite, use the following commands:

yarn test    # For yarn.
npm run test # For NPM.

The test suite comes bundled with Bitcoin Core (located in test/bin) for testing purposes. Depending on your computer architecture, you may have to replace these binaries with another version, or change the default configuration in test/tape.ts.

There are code examples located in test/examples for performing various protocols via FROST and DKG. You can run a test file via the following command:

yarn load test/example/<example_name>.ts

Feel free to check them out!

Resources

ZF FROST Book
A guide to the FROST protocol.
https://frost.zfnd.org/index.html

FROST draft specification
A draft specification of the FROST protocol from the IETF.
https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-15.html

ZCash FROST GitHub
A rust implementation of the IETF FROST draft spec, in rust.
https://github.com/ZcashFoundation/frost

FROST BIP340
A draft implemenation of the FROST protocol for BIP340.
https://github.com/jesseposner/FROST-BIP340

Draft BIP for Secure DKG
A draft proposal for secure DKG in FROST, provided by Blockstream Research.
https://github.com/BlockstreamResearch/bip-frost-dkg

ROAST GitHub
A naive implementation of the ROAST protocol, written in rust.
https://github.com/robot-dreams/roast

FROST Whitepaper
The white-paper for FROST: Flexible Round-Optimized Schnorr Threshold Signatures
https://eprint.iacr.org/2020/852.pdf

ROAST Whitepaper
A white-paper for ROAST: Robust Asynchronous Schnorr Threshold Signatures.
https://eprint.iacr.org/2022/550.pdf