ThresholdSignatureScheme

ThresholdSignatureScheme

Threshold Signature Scheme class

Implements a (t+1, n) threshold signature scheme where:

  • n participants hold key shares
  • t+1 participants can reconstruct the secret (but we don't)
  • 2t+1 participants are required to create a signature (due to INVSS)

This follows the nChain whitepaper's protocol exactly.

Constructor

new ThresholdSignatureScheme(n, t)

Description:
  • Create a threshold signature scheme

Source:
Parameters:
Name Type Description
n number

Total participants (N)

t number

Threshold degree (t+1 shares to reconstruct, 2t+1 to sign)

Methods

clear()

Description:
  • Clear all sensitive data

Source:

generateEphemeralKeys(count)

Description:
  • Section 4.2: Generate ephemeral key shares Pre-compute (r, k_i^-1) tuples for efficient signing

Source:
Parameters:
Name Type Default Description
count number 1

Number of ephemeral keys to generate

generateSharedPrivateKey() → {Buffer}

Description:
  • Section 4.1: Generate shared private key using JVRSS All participants run JVRSS to create shared private key a

Source:
Returns:

Shared public key

Type
Buffer

getConfig() → {Object}

Description:
  • Get configuration details

Source:
Returns:

Configuration

Type
Object

getNextEphemeralKey() → {Object|null}

Description:
  • Get next unused ephemeral key

Source:
Returns:

Next ephemeral key

Type
Object | null

getPublicKey() → {Buffer}

Description:
  • Get the shared public key

Source:
Returns:

Shared public key

Type
Buffer

sign(messageHash, participantIndices) → {Object}

Description:
  • Section 4.3: Generate threshold signature

Source:
Parameters:
Name Type Default Description
messageHash Buffer | string

32-byte message hash (e)

participantIndices Array.<number> null

Indices of signing participants (1-indexed)

Returns:

Signature

Type
Object

signMessage(message, participantIndices) → {Object}

Description:
  • Sign a message (with Bitcoin message prefix and double SHA256)

Source:
Parameters:
Name Type Default Description
message string | Buffer

Message to sign

participantIndices Array.<number> null

Signing participants

Returns:

Signature

Type
Object

verify(messageHash, signature, publicKey) → {boolean}

Description:
  • Verify a signature using standard ECDSA verification

Source:
Parameters:
Name Type Default Description
messageHash Buffer | string

32-byte message hash

signature Object | Buffer

Signature to verify

publicKey Buffer null

Public key (optional, uses shared key if not provided)

Returns:

True if signature is valid

Type
boolean