Skip to content

Stop a PQ key signing once its import fails or it is deleted - #1009

Open
tcoratger wants to merge 1 commit into
lambdaclass:pq-devnet-2from
tcoratger:fix/pq-unregister-on-failure
Open

tcoratger wants to merge 1 commit into
lambdaclass:pq-devnet-2from
tcoratger:fix/pq-unregister-on-failure

Conversation

@tcoratger

Copy link
Copy Markdown

Description / Motivation

Every leanXMSS signature spends a one-time leaf, and two messages signed at one leaf expose the key.
The PQ key registry in pq.rs only grew, and the duties sign PQ through it by handle, whatever the store holds.
A key stayed registered, and signing, in two cases:

  • A keymanager import registered the key, then failed: the keystore write failed, or the slashing-protection record could not be written.
  • A local key was deleted through DELETE /eth/v1/keystores.

Neither key is in the store, so a later POST /eth/v1/remotekeys of it is accepted.
The key then has two signers, each spending its leaves.

What Changed

  • pq.rs: unregister removes a key from the registry.
    It leaves the leaf record alone, so a key registered again in this process signs none of its spent leaves.
  • keystores.rs: an import that registered a key it did not hold, and then fails, unregisters it.
    This covers the persist step, the slashing-protection step and a key a remote signer holds.
    A failed re-import of a key the store holds leaves it signing.
  • keystores.rs: a delete through /eth/v1/keystores unregisters the key along with its removal from the store.
  • Two existing tests now use keys of their own: a delete test's keys were the ones the PQ preference tests register, and the PQ attestation test registered the EIP-2335 key that the keystores tests delete.

Interaction with open PRs

Tests Added / Run

  • an_unregistered_key_signs_nothing_and_keeps_its_leaves: after unregister the key signs nothing, and once it is registered again, a leaf it signed refuses another root.
  • a_failed_pq_import_leaves_its_key_unregistered: a failed keystore write, a failed slashing-protection write and a remote-held key each leave the key unregistered.
  • a_failed_pq_reimport_of_a_held_key_keeps_it_signing: both failure steps leave a held key registered.
  • a_deleted_pq_key_stops_signing_and_keeps_its_leaves: a deleted key signs nothing, and its spent leaf stays spent after a new import.
  • Removing any one of the unregister calls, or the held-key guard, fails one of these tests.
  • cargo test --profile release-fast -p ethlambda-validator --lib: 777 passed, 20 runs in a row.
  • cargo fmt --all --check and cargo clippy --profile release-fast -p ethlambda-validator --all-targets -- -D warnings: clean.

🤖 Generated with Claude Code

The PQ key registry only grew.
A key registered by an import that then failed, or deleted through the keymanager API, still signed every duty of its handle.
A remote signer given that key later would sign beside it, at the same one-time leaves.

An import that does not load a key it registered now unregisters it, and a delete unregisters the key.
The leaf record is left as it is, so a key registered again in this process signs none of its spent leaves.

The PQ attestation test and a keymanager delete test now use keys that no other test registers PQ keys under or deletes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant