Repository navigation
feat(crypto): CRP-2879 Add PocketIC keys to ic-secp256k1 and ic-ed25519 - #7148
Merged
Merged
Conversation
fspreiss
approved these changes
Oct 9, 2025
randombit
enabled auto-merge
October 10, 2025 18:06
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Oct 15, 2025
…pub-key (#7194) Split from #7148 because `ic-pub-key` depends on the published `ic-ed25519` and `ic-secp256k1`, so it was required first to add PocketIC support to those crates and publish new versions, prior to making this change. --------- Co-authored-by: IDX GitHub Automation <[email protected]>
basvandijk
pushed a commit
to Ocheretovich/ic
that referenced
this pull request
Oct 23, 2026
dfinity#11895) ### Why `ic-secp256k1` and `ic-ed25519` ship the mainnet and PocketIC master public keys of their algorithms, and `ic-pub-key` uses them to derive keys offline. The mainnet ECDSA keys `key_1` and `test_key_1` now also exist over secp256r1 (P-256), and PocketIC holds secp256r1 keys too (dfinity#11741). But `ic-secp256r1` has none of them. This PR adds the keys and bumps the version, so the crate can be released. `ic-pub-key` can only use the keys once that release is out (dfinity#11894). That's the same order as dfinity#7148 before dfinity#7194 for the secp256k1 and Ed25519 PocketIC keys. ### What * `PublicKey::mainnet_key(MasterPublicKeyId)` returns `key_1` and `test_key_1`. * `PublicKey::pocketic_key(PocketIcMasterPublicKeyId)` returns the keys PocketIC uses for `key_1`, `test_key_1` and `dfx_test_key`. * `PublicKey::derive_mainnet_key` and `PublicKey::derive_pocketic_key` derive a canister's public key from those master keys. They are offline equivalents of `ecdsa_public_key`. For their `&CanisterId` argument, the crate re-exports `ic_principal::Principal` as `CanisterId`, as `ic-secp256k1` and `ic-ed25519` do. * `hex-literal` becomes a regular dependency, to embed the keys, and `ic_principal` a new one. * The version goes from 0.2.0 to 0.3.0, with a dated changelog entry, for a release after merging. In-repo dependents use the crate by path without a version, so nothing else changes. * The `cup_explorer` README now lists `ic-secp256r1` among the crates with hardcoded master keys. Where the keys come from: * **Mainnet:** the CUPs of subnets uzr34 (`key_1`) and fuqsr (`test_key_1`). In that same output, the secp256k1, BIP340, Ed25519 and VetKD master keys match the values `ic-secp256k1`, `ic-ed25519` and `ic-vetkeys` already ship. * **PocketIC:** derived the way the StateMachine does it, from `PrivateKey::generate_insecure_key_for_testing(42)` and the key name. ### Tests * `mainnet_keys_round_trip`: the mainnet keys round-trip. * A test derives the PocketIC keys the StateMachine's way and compares them with the hardcoded ones. * `derive_mainnet_key` and `derive_pocketic_key` have known-answer tests for all five keys. The expected keys are what the replica's `derive_threshold_public_key` (the function that answers `ecdsa_public_key`) returns for the same master key, canister and path. * The SLIP-10 retry for nist256p1 (index 33941) is now tested. It's the only branch of the derivation the existing tests didn't reach: it runs when iL >= n, about once in 2^32 steps on P-256. The vector is the one the replica's own key derivation test uses. * Locally, in the dev container, all of these pass: `cargo check`, `cargo fmt`, `rust-lint.sh`, `bazel build //... --nobuild`, `//bazel:buildifier.check`, and the 37 tests from the depth-2 rdeps query (this package, `ic-pub-key`, `rs/crypto`, the P-256 basic-sig crate, `standalone-sig-verifier`, `rs/validator`). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The corresponding change to
ic-pub-keymust wait until this change is merged and new releases are created. Then we can roll forward the crates within the monorepo (in the toplevelCargo.toml) and then updateic-pub-key.This also fixes an issue building the tests with cargo.