Command Palette

Search for a command to run...

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

certified-variables

БесплатноБез исполняемых скриптовНе проверен

Serve cryptographically verified responses from query calls using Merkle trees and subnet BLS signatures. Covers the certified data API, RbTree/CertTree…

jiayaoqijiaот jiayaoqijia★ 81 звезда на GitHub

Об этом скилле

Certified Variables

A query call is answered by a single replica, without consensus, so a faulty or malicious replica can return fabricated data. Certification closes that gap: during update calls the canister stores a 32-byte hash (usually the root of a Merkle tree over its data) in the subnet's certified state, and query responses carry a certificate signed by the subnet's threshold BLS key. Clients verify the certificate and a Merkle witness, and get a fast query response that is as trustworthy as an update call.

Who Verifies What

Decide this first. Certification only helps if something checks it.

Response Verified by Client code needed
HTTP from a frontend canister or http_request, via <id>.icp.net or a custom domain the HTTP gateway none
The same, via <id>.raw.icp.net or your own HTTP client nobody @dfinity/response-verification (verifyRequestResponsePair)
Update call through an actor (agent.update) consensus; the agent checks the response certificate none
Candid query call through an actor only the answering node's signature certified data + @dfinity/certificate-verification (this skill)

The gateway never verifies Candid API calls (/api/...), even when the page came from a verifying host: on ic0.app, icp0.io or local origins the agent sends them through the page origin, and the gateway only proxies them. Certify a query when a client acts on its result: balances, permissions, prices, anything security-relevant. The alternative is to call the method as an update and accept consensus latency. Ledgers implementing ICRC-3 already certify their tip: icrc3_get_tip_certificate returns opt { certificate; hash_tree }, which verifies with verifyCertification like any witness below (labels last_block_index, a LEB128 number, and last_block_hash, so decode them instead of the helper's UTF-8 compare).

Static frontends served by the certified-assets canister (@dfinity/static-site recipe) are certified automatically: load the static-site skill for those.

Versions

Side Package Version Used for
Rust ic-cdk 0.20 certified_data_set / data_certificate
Rust ic-certification (feature serde) 4 RbTree Merkle map with witnesses
Rust ic-http-certification 4 certifying http_request responses
Motoko core 2.6 mo:core/CertifiedData
Motoko ic-certification (mops) 1.1 CertTree Merkle tree with witnesses
Motoko sha2 (mops) 0.2 hashing a single certified value
Frontend @icp-sdk/core ^6 agent, Certificate, lookup_path
Frontend @dfinity/certificate-verification ^4 witness verification (peers @icp-sdk/core ^6, takes Uint8Array)

ic-certified-map 0.4 exposes the same RbTree/AsHashTree API and still works, but ic-certification is maintained alongside ic-http-certification and is what the official examples use.

Root Key

Client-side verification needs the root key of the network the canister runs on:

  • Browser: safeGetCanisterEnv()?.IC_ROOT_KEY from the ic_env cookie (@icp-sdk/core/agent/canister-env), set by the frontend canister on local networks and mainnet alike. It is the key of the network serving the page; to verify a canister on another network (e.g. mainnet data from a local dev server), use that network's key. It is only as trustworthy as the page: on a verifying hostname the gateway verifies the cookie along with the page, but a page from a raw hostname can carry a forged key, so a client verifying raw responses needs an independently obtained key.
  • Node scripts and tests: root_key from icp network status --json, hex-decoded to bytes.
  • Mainnet: the agent's built-in default (agent.rootKey on an agent created without rootKey): 308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae

Never call fetchRootKey() in shipped code: it trusts whatever key the replica sends (see the canister-security skill).

Pitfalls

  1. Certifying more than 32 bytes. certified_data_set / CertifiedData.set accept at most 32 bytes. Build a Merkle tree over the data and certify its root hash; the tree provides per-key proofs.

  2. Setting certified data in a query, or not at install and after every change. certified_data_set can be called from canister_init, canister_post_upgrade, canister_pre_upgrade, update methods, reply/reject callbacks, and system tasks (heartbeat, global timer, low-Wasm-memory hook); it traps anywhere else, including any query (even one called as an update) and cleanup callbacks. Certified data starts empty on install, so certify the initial state i

Полный SKILL.md на GitHub

Установить certified-variables в Claude Code и Claude Desktop

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

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

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

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

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

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

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

LICENSESOURCE.mdTRUST.auto.yamlreferences/http-certification.md

FAQ

Что делает скилл certified-variables?

Serve cryptographically verified responses from query calls using Merkle trees and subnet BLS signatures. Covers the certified data API, RbTree/CertTree construction, witness generation, HTTP response certification for custom http_request canisters (ic-http-certification), and frontend certificate validation (@dfinity/certificate-verification). Use when query responses need verification, certified data, or response authenticity proofs. For static frontends served by the certified-assets canister, use the static-site skill instead: certification is automatic there.

Как установить скилл certified-variables?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл certified-variables запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

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

Сравнить certified-variables с