Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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от 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: vetkeys skill.
  • 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_key calls are free; rejected signing requests are refunded.
  • The signing subnet sets the fee. Let the helpers attach it (Rust ic-cdk-management-canister, Motoko mo:ic/Call; both use ic0.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_1 and dfx_test_key for 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_NAME canister environment variable, default key_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 code CANISTER_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:
    1. Sign less. Sign one hash over a batch (a Merkle root) instead of every item; reuse long-lived signatures (JWTs, certificates) until they expire.
    2. Queue in your canister. Store requests, drain them from a timer with
Полный SKILL.md на GitHub

Установить threshold-signatures в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

LICENSESOURCE.mdTRUST.auto.yamlreferences/chain-formats.mdreferences/motoko.mdreferences/public-keys.md

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), без исполняемых скриптов.

Похожие скиллы

Сравнить threshold-signatures с