BIP322

BIP322

new BIP322()

Description:
  • BIP322 Message Signing

Source:

Methods

(static) createToSign(toSpendTxid, scriptPubKey) → {Object}

Description:
  • Create "to_sign" virtual transaction

Source:
Parameters:
Name Type Description
toSpendTxid Buffer

Txid of to_spend transaction

scriptPubKey Buffer

Script of signing address

Returns:

Virtual transaction to sign

Type
Object

(static) createToSpend(scriptPubKey, messageHash) → {Object}

Description:
  • Create "to_spend" virtual transaction

Source:
Parameters:
Name Type Description
scriptPubKey Buffer

Script of the signing address

messageHash Buffer

Hashed message

Returns:

Virtual transaction

Type
Object

(static) hashMessage(message) → {Buffer}

Description:
  • Create message hash for signing

Source:
Parameters:
Name Type Description
message string | Buffer

Message to sign

Returns:

32-byte message hash

Type
Buffer

(async, static) sign(message, privateKey, addressType) → {Promise.<Buffer>}

Description:
  • Sign a message using BIP322 (simple format)

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

Message to sign

privateKey Buffer | string

Private key

addressType string p2wpkh

Address type (p2wpkh, p2tr)

Returns:

BIP322 signature (witness serialized)

Type
Promise.<Buffer>

(static) signLegacy(message, privateKey) → {Object}

Description:
  • Legacy Bitcoin message signing (for compatibility)

Source:
Parameters:
Name Type Description
message string | Buffer

Message to sign

privateKey Buffer | string

Private key

Returns:

Signature {signature, recovery}

Type
Object

(async, static) verify(message, signature, scriptPubKey) → {Promise.<boolean>}

Description:
  • Verify a BIP322 signature

Source:
Parameters:
Name Type Description
message string | Buffer

Original message

signature Buffer

BIP322 signature (serialized witness)

scriptPubKey Buffer

Address scriptPubKey

Returns:

True if valid

Type
Promise.<boolean>

(static) verifyLegacy(message, signature, publicKey) → {boolean}

Description:
  • Verify legacy Bitcoin message signature

Source:
Parameters:
Name Type Description
message string | Buffer

Original message

signature Object

Signature object

publicKey Buffer | string

Public key

Returns:

True if valid

Type
boolean