Signing Specifications
Technical specifications for Spark wallet signing mechanisms
Core Concepts
Please note that the signing functions are not exported from the SDK and are not intended to be used directly by developers. They are used internally by the SDK to sign messages and transactions. They are described here for information purposes.
FROST (Flexible Round-Optimized Schnorr Threshold Signatures)
FROST is a threshold signature scheme that allows a group of signers to collectively generate a signature without revealing their individual private keys. In Spark, we modified FROST to have a required participant.
KeyPackage
The KeyPackage
struct holds the secret key, public key and the verifying key.
SigningCommitment
The SigningCommitment
struct is a crucial component of the FROST protocol. It contains two public keys:
- hiding: A public key used for hiding the signer’s nonce.
- binding: A public key used for binding the commitment to the message being signed.
SigningNonce
The SigningNonce
struct are used to sign a message, and is made of two private keys:
- binding: A random private key used to ensure the nonce is unique to the binding key.
- hiding: A random private key used to hide the signer’s nonce.
Key Operations
1. frost_nonce(key_package: KeyPackage): NonceResult
Generates a signing nonce and the associated signing commitment.
Parameters
key_package
: TheKeyPackage
containing the secret key, public key, and verifying key.
Returns
NonceResult
: An object containing the generatedSigningNonce
andSigningCommitment
.
Usage
2. signFrost(params: SignFrostParams): Uint8Array
Generates a signature share using the FROST signing protocol.
Parameters
SignFrostParams
: An object containing:msg
: The message to be signed (as aUint8Array
).keyPackage
: The secret and public keys to derive a signing key and verifying key.nonce
: The signing nonce.selfCommitment
: The signing commitment.statechainCommitments
: An optional object mapping statechain IDs to their respective signing commitments.adaptorPubKey
: An optional adaptor public key (as aUint8Array
).
Returns
Uint8Array
: The generated signature share.
Usage
3. aggregateFrost(params: AggregateFrostParams): Uint8Array
Aggregates multiple signature shares into a single, complete signature.
Parameters
AggregateFrostParams
: An object containing:msg
: The message that was signed (as aUint8Array
).statechainCommitments
: An object mapping statechain IDs to their respective signing commitments.selfCommitment
: The signing commitment.statechainSignatures
: An object mapping statechain IDs to their respective signature shares.selfSignature
: The user’s signature share.statechainPublicKeys
: An object mapping statechain IDs to their respective public keys.selfPublicKey
: The user’s public key.verifyingKey
: The verifying key.adaptorPubKey
: An optional adaptor public key (as aUint8Array
).
Returns
Uint8Array
: The aggregated signature.
Usage
Usage in Spark SDK
The signing functions are integrated into the SparkWallet
class and are used internally by various services like TransferService
, DepositService
, and LightningService
. These functions provide the low-level cryptographic operations required for secure and private transactions within Spark.