Repository navigation
test(consensus): cover secp256r1 ECDSA keys in system tests - #11762
Merged
Merged
Conversation
#11573 added `EcdsaCurve::Secp256r1` but left the system tests and the CUP compatibility test on secp256k1. A secp256r1 key could not be decoded yet by the mainnet registry canister, which the default variant of every `system_test_nns` test installs, nor by the mainnet replica, which the upgrade/downgrade, backup and CUP compatibility tests run. Both now can: the mainnet registry canister is at 98c898f (#11757) and the mainnet replica at d26cd03, and both contain #11573. * `make_key_ids_for_all_schemes` and `make_key_ids_for_all_idkg_schemes` also return a secp256r1 key. It shares its name with the secp256k1 key, as keys of both curves would on mainnet, so code that tells ECDSA keys apart by name alone fails the tests. `make_ecdsa_key_id` becomes `make_ecdsa_secp256k1_key_id`, next to `make_ecdsa_secp256r1_key_id`. * `tecdsa_signature_life_cycle_test` enables the secp256r1 key later, on a subnet that already holds the secp256k1 key of the same name. * `ExhaustiveSet for EcdsaCurve` returns all curves again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The helper migration is complete, and the new curve follows existing signing, verification, and lifecycle paths without unresolved issues.
Review effort: Balanced
Findings: None
What changed in this PR
Extends consensus system-test coverage to secp256r1 ECDSA keys alongside secp256k1.
Changes:
- Adds secp256r1 to shared key sets and lifecycle tests.
- Renames the secp256k1-specific helper for clarity.
- Restores exhaustive ECDSA curve generation for compatibility tests.
| File | Description |
|---|---|
rs/types/types/src/exhaustive.rs |
Generates all ECDSA curves. |
rs/tests/consensus/tecdsa/utils/src/lib.rs |
Adds secp256r1 key helpers and shared coverage. |
rs/tests/consensus/tecdsa/tecdsa_signature_life_cycle_test.rs |
Exercises the secp256r1 key lifecycle. |
rs/tests/consensus/tecdsa/tecdsa_performance_test_template.rs |
Uses the renamed secp256k1 helper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
✅ No security or compliance issues detected. Reviewed everything up to 4159842. Security OverviewDetected Code Changes
|
pierugo-dfinity
approved these changes
Oct 5, 2026
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.
Why
#11573 added
EcdsaCurve::Secp256r1but left the system tests and the CUP compatibility test on secp256k1, because a secp256r1 key could not yet be decoded by the mainnet versions they run:_head_nns) variant of everysystem_test_nnstest installs the mainnet NNS canisters. The mainnet registry canister (237a41f) rejected protobuf curve2("Unable to convert 2 to an EcdsaCurve"), so any proposal adding a secp256r1 key failed.upgrade_downgrade_*_app_subnet_test,backup_manager_{up,down}grade_testandcup_compatibility_testrun the mainnet replica (or itsic-replay/types-testbinaries).Both now support it: #11757 moved the mainnet registry canister to 98c898f, and every mainnet subnet in
mainnet-icos-revisions.jsonruns d26cd03. Both contain #11573.What
make_key_ids_for_all_schemes()andmake_key_ids_for_all_idkg_schemes()also return a secp256r1 key. The tests that use them now cover it too: the tecdsa tests, subnet recovery, backup, upgrade/downgrade androtate_ecdsa_idkg_key_test.some_ecdsa_key) with the secp256k1 key, as keys of both curves would on mainnet. Code that tells ECDSA keys apart by name alone therefore fails the tests.make_ecdsa_key_idis renamed tomake_ecdsa_secp256k1_key_id, next to the newmake_ecdsa_secp256r1_key_id.tecdsa_signature_life_cycle_testadds the secp256r1 key to the keys enabled later, on a subnet that already holds the secp256k1 key of the same name. This is how it would be rolled out on mainnet. The test checks that requests for the key are rejected before it is enabled, signs with it, reshares it to a new subnet and disables it.ExhaustiveSet for EcdsaCurvereturns all curves again.cup_compatibility_testtherefore checks that the mainnet replica decodes CUPs naming a secp256r1 key.Not in this PR
cast_ecdsa_key_idstaysunimplemented!.signer.didand the management canister bench'scandid.didstay secp256k1-only.Both canisters type their ECDSA arguments with
ic-cdk-management-canister. Its latest release (0.2.0) still requiresic-management-canister-types ^0.10, and cdk-rsmainpins0.10. Version 0.11.0, the first withSecp256r1, was published only today. The only test that reaches this path is the manualtecdsa_performance_test_template, throughlarge_ecdsa_method_and_payload.Tests
Run locally in the dev container:
cargo check,cargo fmtandci/scripts/rust-lint.share clean._bintarget, one hop further, andcup_compatibility_testonly usestypes_testas data. So I added the_farmvariants of every system test that calls the changed helpers or readsexhaustive.rs: 56 targets, covering both the mainnet-NNS and the_head_nnsvariant.Of the 466 targets in one run, 456 passed, including all 58 system-test targets:
backup_manager_{up,down}grade_testrotate_ecdsa_idkg_key_testupgrade_downgrade_*app_subnet_testtargetssr_app_*subnet recovery testscup_compatibility_testtecdsa_signature_life_cycle_testvariantsThe 10 failures are unrelated:
--local_test_jobs=2.//rs/pocket_ic_server:external_types_testsalso fails on master e8fd3a6: Internet Identity's candid gained fields with the release bump in chore: Update Mainnet IC revisions canisters file #11757.Serializing the exhaustive CUP set here and on master shows 22 ECDSA key ids switching from curve 1 to curve 2. So
cup_compatibility_testnow has the mainnettypes-testdecode CUPs naming secp256r1 keys.🤖 Generated with Claude Code