threshold-signatures
Threshold Signatures (Ed25519, Schnorr, ECDSA)
What This Is
A canister must never keep a private key in its state (node operators can read canister memory). It asks the management canister (aaaaa-aa) to sign instead: a signing subnet holds a master key in shares, and its nodes compute the signature together without any node seeing the key. Each canister gets its own key tree, derived from the master key and its canister ID; derivation_path selects any number of child keys. Only that canister can sign with its keys.
| Scheme | Methods | key_id |
*_public_key returns |
You pass | Signature |
|---|---|---|---|---|---|
| Ed25519 (EdDSA, RFC 8032) | schnorr_public_key, sign_with_schnorr |
record { algorithm = variant { ed25519 }; name } |
32 bytes | message, the raw message |
64 bytes R‖S |
| Schnorr BIP340 (secp256k1) | same | algorithm = variant { bip340secp256k1 } |
33-byte SEC1 compressed; drop byte 0 for the 32-byte x-only key | message; optional aux for Taproot (BIP341) |
64 bytes BIP340 |
| ECDSA secp256k1 | ecdsa_public_key, sign_with_ecdsa |
record { curve = variant { secp256k1 }; name } |
33-byte SEC1 compressed | message_hash, exactly 32 bytes |
64 bytes r‖s, low-s normalized, no recovery id |
| ECDSA secp256r1 (NIST P-256) | same | curve = variant { secp256r1 } |
33-byte SEC1 compressed | message_hash, exactly 32 bytes |
64 bytes r‖s, low-s normalized |
Only canisters can call these methods, from update contexts. *_public_key accepts canister_id = opt <other> to read another canister's keys. Signatures are randomized, Ed25519 included. BLS: see vetkeys.
Choosing the Scheme
Rule 1: the verifier decides. Use the scheme the standard, chain or library checking the signature requires. Rule 2: if free to choose, use Ed25519: it has the best threshold-signing throughput on ICP and is the simplest (no pre-hashing, 32-byte keys).