threshold-signatures
БесплатноБез исполняемых скриптовНе проверенSign from a canister with ICP threshold (chain-key) keys: Ed25519 and BIP340 Schnorr through sign_with_schnorr, and ECDSA on secp256k1 or secp256r1 (P-256)…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
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).
| Verifier / standard | Scheme |
|---|---|
| Bitcoin P2PKH, P2WPKH, P2SH; Dogecoin; Ethereum and EVM chains; Cosmos SDK chains | ECDSA secp256k1 |
| Bitcoin Taproot (P2TR), Ordinals/Runes; Nostr events (NIP-01) | Schnorr BIP340 |
Solana, Stellar, TON, NEAR, Aptos, Sui, Cardano, Polkadot (ed25519 accounts); JWT alg: EdDSA; SSH; your own verifier |
Ed25519 |
JWT/JWS/COSE ES256, X.509 certificates and CSRs, mdoc/EUDI-style credentials, any NIST/FIPS-only verifier |
ECDSA secp256r1 |
You may not need a threshold signature at all:
- Only ICP canisters verify it: inter-canister calls already authenticate the caller, and certified data (
certified-variables) has no fee or throughput limit. - Unique or BLS signatures, encryption, end-user keys:
vetkeysskill. - Per-user Bitcoin/Ethereum keys for a web app without a backend: the Chain Fusion Signer canister
grghe-syaaa-aaaar-qabyq-cai, paid in cycles via ICRC-2.
Keys, Environments and Cost
| Key name | Where | Use | Fee per sign_with_* |
|---|---|---|---|
key_1 |
mainnet (34-node fiduciary subnet pzp6e), local |
production | 26_153_846_153 cycles (~$0.036) |
test_key_1 |
mainnet (13-node subnet fuqsr), local |
development; never for anything of value | 10_000_000_000 cycles (~$0.014) |
dfx_test_key |
local / PocketIC only | legacy tests | n/a on mainnet |
- Both names exist for all four schemes.
*_public_keycalls are free; rejected signing requests are refunded. - The signing subnet sets the fee. Let the helpers attach it (Rust
ic-cdk-management-canister, Motokomo:ic/Call; both useic0.cost_sign_with_ecdsa/ic0.cost_sign_with_schnorr). Too few cycles:sign_with_ecdsa request sent with N cycles, but M cycles are required. - The icp-cli local network always provides
key_1,test_key_1anddfx_test_keyfor all four schemes, but its master keys are not mainnet's: every local public key and address differs from mainnet. - The key name is permanent configuration: another name means other keys and addresses, stranding funds at the old ones. Read it from one place (below: the
THRESHOLD_KEY_NAMEcanister environment variable, defaultkey_1) and never change it for a deployed canister.
Throughput and Latency: Design for Them
- Plan for about 10 signatures per second per key, shared by every canister on ICP using that key. Short bursts somewhat above it are served from pre-computed pre-signatures; sustained excess fills the key's queue and new requests are rejected immediately:
sign_with_schnorr request failed: request queue for key <key> is full.(reject codeCANISTER_REJECT= 4, cycles refunded). Ed25519 has the highest throughput. - A signature takes seconds (a round trip to the signing subnet plus consensus there).
- Design accordingly:
- Sign less. Sign one hash over a batch (a Merkle root) instead of every item; reuse long-lived signatures (JWTs, certificates) until they expire.
- Queue in your canister. Store requests, drain them from a timer with
Установить threshold-signatures в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл threshold-signatures?
Sign from a canister with ICP threshold (chain-key) keys: Ed25519 and BIP340 Schnorr through sign_with_schnorr, and ECDSA on secp256k1 or secp256r1 (P-256) through sign_with_ecdsa. Explains how to pick the scheme the verifier needs and why Ed25519 is the default when the choice is free. Also covers key names and fees, the budget of about 10 signatures per second, derivation paths, public keys and offline derivation, and the formats that Bitcoin, Ethereum, Solana and JWTs expect, with Rust and Motoko code. Use when a canister must hold a key, derive an address or sign transactions, tokens or attestations, or when ecdsa_public_key, schnorr_public_key, sign_with_ecdsa or sign_with_schnorr fails. Do NOT use for BLS signatures or encryption (vetkeys), ckBTC/ckETH/ckSOL deposits and withdrawals (ckbtc, cketh, cksol) or EVM RPC calls (evm-rpc).
Как установить скилл threshold-signatures?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл threshold-signatures запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic