Skip to content

test(consensus): cover secp256r1 ECDSA keys in system tests - #11762

Merged
eichhorl merged 2 commits into
masterfrom
eichhorl/ecdsa-secp256r1-system-tests
Oct 5, 2026
Merged

eichhorl merged 2 commits into
masterfrom
eichhorl/ecdsa-secp256r1-system-tests

Conversation

@eichhorl

@eichhorl eichhorl commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Why

#11573 added EcdsaCurve::Secp256r1 but 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:

  • The default (non-_head_nns) variant of every system_test_nns test installs the mainnet NNS canisters. The mainnet registry canister (237a41f) rejected protobuf curve 2 ("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_test and cup_compatibility_test run the mainnet replica (or its ic-replay / types-test binaries).

Both now support it: #11757 moved the mainnet registry canister to 98c898f, and every mainnet subnet in mainnet-icos-revisions.json runs d26cd03. Both contain #11573.

What

  • make_key_ids_for_all_schemes() and make_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 and rotate_ecdsa_idkg_key_test.
  • The secp256r1 key shares its name (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_id is renamed to make_ecdsa_secp256k1_key_id, next to the new make_ecdsa_secp256r1_key_id.
  • tecdsa_signature_life_cycle_test adds 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 EcdsaCurve returns all curves again. cup_compatibility_test therefore checks that the mainnet replica decodes CUPs naming a secp256r1 key.

Not in this PR

  • The secp256r1 arm of cast_ecdsa_key_id stays unimplemented!.
  • The signer canister's signer.did and the management canister bench's candid.did stay secp256k1-only.

Both canisters type their ECDSA arguments with ic-cdk-management-canister. Its latest release (0.2.0) still requires ic-management-canister-types ^0.10, and cdk-rs main pins 0.10. Version 0.11.0, the first with Secp256r1, was published only today. The only test that reaches this path is the manual tecdsa_performance_test_template, through large_ecdsa_method_and_payload.

Tests

Run locally in the dev container:

  • cargo check, cargo fmt and ci/scripts/rust-lint.sh are clean.
  • The CLAUDE.md depth-2 affected-test query (412 targets) misses most of the system tests: they reach the changed lib through their _bin target, one hop further, and cup_compatibility_test only uses types_test as data. So I added the _farm variants of every system test that calls the changed helpers or reads exhaustive.rs: 56 targets, covering both the mainnet-NNS and the _head_nns variant.

Of the 466 targets in one run, 456 passed, including all 58 system-test targets:

  • every tecdsa test
  • backup_manager_{up,down}grade_test
  • rotate_ecdsa_idkg_key_test
  • both upgrade_downgrade_*app_subnet_test targets
  • all sr_app_* subnet recovery tests
  • cup_compatibility_test
  • all four tecdsa_signature_life_cycle_test variants

The 10 failures are unrelated:

  • The 2 golden-state tests can't fetch the state snapshot without the SSH key they need.
  • 7 tests (4 timeouts, 3 failures) had run next to 55 Farm system tests, and passed when rerun alone with --local_test_jobs=2.
  • //rs/pocket_ic_server:external_types_tests also 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_test now has the mainnet types-test decode CUPs naming secp256r1 keys.

🤖 Generated with Claude Code

#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>
@eichhorl
eichhorl requested a balanced review from Copilot October 5, 2026 12:43
@github-actions github-actions Bot added the test label Oct 5, 2026
@eichhorl eichhorl added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eichhorl
eichhorl marked this pull request as ready for review October 5, 2026 14:22
@eichhorl
eichhorl requested a review from a team as a code owner October 5, 2026 14:22
@zeropath-ai

zeropath-ai Bot commented Oct 5, 2026

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to 4159842.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► rs/tests/consensus/tecdsa/tecdsa_performance_test_template.rs
    - Description: Update key ID creation for ECDSA secp256k1 to use make_ecdsa_secp256k1_key_id()
Enhancement ► rs/tests/consensus/tecdsa/tecdsa_signature_life_cycle_test.rs
    - Description: Replace make_ecdsa_key_id() with make_ecdsa_secp256k1_key_id(); add make_ecdsa_secp256r1_key_id(); include new key in later_key_ids
Enhancement ► rs/tests/consensus/tecdsa/utils/src/lib.rs
    - Description: Rename make_ecdsa_key_id() to make_ecdsa_secp256k1_key_id(); add make_ecdsa_secp256r1_key_id(); adjust key-id helpers and exports; update key-id usage across tests
Enhancement ► rs/types/types/src/exhaustive.rs
    - Description: Return full EcdsaCurve::iter() in ExhaustiveSet for EcdsaCurve (instead of restricting to Secp256k1)

@eichhorl
eichhorl added this pull request to the merge queue Oct 5, 2026
Merged via the queue into master with commit 37a383b Oct 5, 2026
40 of 41 checks passed
@eichhorl
eichhorl deleted the eichhorl/ecdsa-secp256r1-system-tests branch October 5, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants