Skip to content

fix(security)!: sign with the self-erasing EcdsaSecretKey - #1127

Merged
lklimek merged 32 commits into
v1.0-devfrom
fix/erase-secp256k1-key-copies
Oct 26, 2026
Merged

lklimek merged 32 commits into
v1.0-devfrom
fix/erase-secp256k1-key-copies

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

Every place DET built a plain secp256k1::SecretKey from its self-zeroizing key material now uses the upstream self-erasing EcdsaSecretKey (dash-pkc, re-exported as dashcore::ecdsa::EcdsaSecretKey). DIP-15 ECDH is the one exception: EcdsaSecretKey has no ECDH API, so that site uses a small private wrapper that erases the key on drop. This is defense in depth. Message signatures and ECDH output keep their exact bytes. Non-recoverable signatures (Core transactions, single-key signing, auto-accept proofs) are now low-R. They are still valid and deterministic, but their bytes differ from earlier builds (see below).

User story / Scenario

Not applicable. This is internal hardening with no user-visible change.

Detailed discussion

Stacked atop #1114 (Platform pin bump). That PR moves DET to the new rust-dashcore crypto stack with secp256k1 0.33. In that version SecretKey is Copy and has no Drop. DET's key sources (EcdsaSecretKey, Zeroizing<[u8; 32]>, the JIT vault plaintext) wipe themselves. The secp256k1::SecretKey copies built from them did not, so those copies stayed in freed stack memory after each operation.

EcdsaSecretKey erases its scalar on drop. It covers signing (sign, sign_recoverable), public_key and add_tweak, so most sites switch to it directly:

Site Change
wallet_backend/det_signer.rs HD signing signs with the derived ExtendedPrivKey's own EcdsaSecretKey, with no copy at all. Single-key signing parses the held bytes into an EcdsaSecretKey. DetSignerError::Sign now carries EcdsaError
backend_task/wallet/mod.rs (dash_signed_message) Takes &EcdsaSecretKey and uses sign_recoverable. The envelope is rebuilt with the caller's compression flag
backend_task/wallet/mod.rs (with_identity_secret_key) Lends &EcdsaSecretKey to its closure
backend_task/wallet/sign_message_with_key.rs Signs with the derived PrivateKey's own key, with no copy
backend_task/wallet/derive_identity_key_for_display.rs Builds the WIF from a clone of the key. The clone erases itself too
ui/identity/keys/key_info_screen.rs Local signing with a key whose plaintext is held in the UI
model/qualified_identity/mod.rs HASH160 key-match check before signing
backend_task/dashpay/auto_accept_proof.rs Auto-accept proof signing
model/dashpay_derivation/dip14.rs Range check of the DIP-14 I_L tweak. The DerivationError::Secp256k1 variant was used only here, so it is removed
backend_task/dashpay/encryption.rs DIP-15 ECDH uses a private EcdhSecretKey wrapper, because dash-pkc has no ECDH. It implements Zeroize (secp256k1's volatile non_secure_erase) and ZeroizeOnDrop, and is deliberately not Clone/Copy

All other SecretKey::from_secret_bytes calls are in #[cfg(test)] code.

Signature bytes: low R

EcdsaSecretKey::sign grinds the nonce until R is low, as Dash Core and Bitcoin Core do, so DER signatures are at most 70 bytes. Plain RFC 6979 secp256k1::ecdsa::sign gives a high R about half the time. As a result, these signatures now differ from earlier builds for roughly half of all digests:

  • Core transaction signing through DetSigner::sign_ecdsa. Low-R, low-S signatures are standard and relayed by Dash Core.
  • Single-key signing (DetSigner::sign_single_key_ecdsa). This path has no production caller yet.
  • DashPay auto-accept proofs. The verifier is a plain ECDSA verify, which accepts these signatures.

Signatures stay deterministic for a given key and digest. Recoverable signatures are not ground, so signed-message envelopes stay byte-identical.

The erase is best effort: the compiler may already have moved the bytes elsewhere before the erase runs.

DIP-14's HMAC output, which holds I_L, is kept in Zeroizing.

Testing

  • det_signer::hd_signer_parity_with_reference: the independent reference now signs with secp256k1::ecdsa::sign_low_r instead of ecdsa::sign, because the signer grinds a low R. The comment in the test says why. The pinned public-key vector is unchanged.
  • New det_signer::hd_signer_signatures_are_valid_and_standard: signs 32 digests and checks that each signature verifies against the reported public key, is low-S, has a low R, and has a DER encoding of at most 70 bytes. Before the switch it failed on the second digest (high R).
  • det_signer::single_key_signer_signs_raw_and_rejects_path now also checks that the single-key signature is valid and standard.
  • New auto_accept_proof::proof_signature_verifies_and_has_low_r: checks the proof layout, and checks that the signature verifies the way verify_auto_accept_proof checks it and is low-S and low-R, for 32 account references.
  • New encryption::ecdh_secret_key_zeroize_overwrites_the_key and ecdh_secret_key_rejects_invalid_scalar cover the ECDH wrapper. The first runs the zeroize() that Drop calls, because reading a value after its drop has run is UB.
  • These tests still pass unchanged, which shows those bytes did not change: the_envelope_keeps_its_byte_layout (the reference uses raw secp256k1 recoverable signing), recovers_signer_pubkey_*, ecdh_shared_key_matches_pinned_vector, the DashPay golden-blob decrypt tests, and the DIP-14 test vectors.
  • Targeted run (det_signer, backend_task::dashpay, backend_task::wallet, key_info_screen, qualified_identity, dashpay_derivation): 288 passed. cargo clippy --all-features --all-targets -- -D warnings is clean, and cargo fmt --all has been run.

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q

PR Hygiene · 116b1b1

  • Bots — coderabbitai skipped after its own rate limit · thepastaclaw ✓
  • Self-review — not asked of a bot author
  • Build green
  • Approvals
    • files with no dedicated owner (src/backend_task/dashpay/auto_accept_proof.rs, src/backend_task/dashpay/encryption.rs, src/backend_task/wallet/derive_identity_key_for_display.rs and 8 more) — approved by lklimek

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

lklimek and others added 24 commits October 24, 2026 18:21
Pin dash-sdk, rs-sdk-trusted-context-provider, platform-wallet and
platform-wallet-storage to dashpay/platform v5.1-dev 063589bf
(5.0.0-rc.8). The lockfile moves only the Platform packages.

The upstream V019 wallet-storage migration adds a nullable asset-lock
operation id; V001-V018 are unchanged. The compatibility bridge gets the
033ecae destination snapshot it compares against, and the pin guard
records the new revision with an unchanged migration fingerprint.

BREAKING CHANGE: the wallet storage upgrade to V019 is forward only. An
older build cannot open upgraded storage; going back needs a copy of the
data directory taken before the upgrade.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new rust-dashcore wraps secp256k1 keys in EcdsaSecretKey and
EcdsaPublicKey, returns secret bytes as Zeroizing, and drops the
Secp256k1 context argument. Signers, single-key wallets, DashPay
derivation, address and QR handling, migrations and their tests follow
the new types. Signing stays on the non-grinding dpp::secp256k1 path,
and a parity test pins the BLS signature bytes the previous SDK made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Handle the dpp and SDK types the new pin adds, keeping today's behaviour:

- Document replace keeps moderated_at and moderated_by; new documents
  start without them.
- The document editor refuses typed-array fields instead of dropping
  their contents, and keeps referenced key ids as numbers.
- Shielded token events show read-only in group actions, and the
  shielded pool token settings are refused before anything is signed.
- Contested document creation states the protocol's base contest fund,
  so the SDK never auto-quotes a larger one.
- Masternode vote reads use ResourceVoteWithCount, the SDK's new vote
  type; the vote count is not used yet.
- New query fields, wallet events, wallet error variants and asset-lock
  funding modes are handled where the SDK now requires them.
- Entropy-only document ids are documented as placeholders from
  protocol 14, and deferred upstream features link to their issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK was pinned to the protocol 13 table, so it could not build any
protocol 14 transition or follow the versioned identity lookup. It now
starts at upstream's per-network minimum and ratchets to what proven
responses report.

- System contracts are cached per protocol version and served through
  accessors. The context provider serves them at the version the proof
  verifier asks for and fails rather than serve another version's.
- A proved epoch sets the fee multiplier and raises the protocol version.
  An older epoch than the adopted one is ignored.
- Rebuilding the connection resets the protocol version, fee multiplier
  and adopted epoch under one lock before the new SDK is published, and
  drops reads begun on the old connection.
- Capabilities read the network's version through a helper that stays
  closed for a version this build does not define.
- Contest timing reads the live version; retired vote schedules keep the
  protocol 13 notice window they were created under.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Compare the protocol 13 client tables with a recorded snapshot, so an
upstream change to them is reviewed, and check that keys and documents
DET builds on a protocol 13 network use encodings protocol 13 decodes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Map the refusals the new protocol adds to flows DET already offers to
dedicated TaskError variants: a full username contest, a vote choice the
contest does not allow, a name someone else asked for first, a token
that cannot be moved, a changed immutable document field, a reference to
a document type that cannot be deleted, and a moderators' fee on a
contract without moderation. Names supplied by the node stay in the
typed source only, never in the message.

Token operations that fail inside the wallet runtime keep their SDK
cause, so they are classified like any SDK error; an unclassified one
names the operation that did not complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Add a dated design note for the pin, the protocol version sources, the
connection state rules and the protocol 13 guards, and point AGENTS.md
at From<SdkError> for TaskError as the SDK error reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…it refusals

Protocol version 14 refusals that flows already in DET can hit get
dedicated, actionable messages, each keeping the SDK error as its source:

- an identity banned or suspended (until when) on a moderated contract;
- a gas sponsor short of credits, a gas payer the document type does not
  offer, and mixed gas payers in one batch;
- pre-programmed token distributions of one time over the limit.

An overflowing shielded note total is logged at warn: it means corrupt or
hostile sync data, not routine noise.

Tests cover contracts saved at protocol 12 loading unchanged at 13 and 14,
and contracts saved at 14 decoding at 13 and in full again at 14.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A lookup at another version, as the proof verifier makes at a response's
version, swapped out the app's set, so each such lookup reloaded the
system contracts and the next app read reloaded them again. Each
version now keeps its own set; the app's reads keep the set they last
got for a failed reload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…poch

When the epoch cannot be read, the proved DPNS fallback confirmed the
SDK's version, which starts at the network's upstream minimum (14 on
devnet), as the network's. It now confirms the version of the responses
the SDK verified, and nothing before any.

Restores the completed-withdrawal status list with the reason sending
FAILED to a protocol 13 network is safe, and its test, now comparing the
protocol 13 schema with the latest one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The derived key DET signs with is copied into secp256k1's own type,
which keeps its bytes after use. Wrap it so it is erased on drop, as the
derived key it comes from would be; signatures stay byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
… protocol 13

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The new refusals sent users to another document editor or token client.
They now say the app cannot edit this field type, sign this action or
change this token setting yet, in one wording, and the shielded setting
refusal sits with the token contract errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Also corrects the platform compatibility fixtures README: no code reads
e3cd7cf.sql any more; it is the V001-V018 checksum reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The protocol version fallback takes only a version the SDK verified, and
a mock expectation's metadata is never recorded as verified, so the three
headless refresh tests saw the version stay unconfirmed. The mock now has
the SDK accept the version from metadata treated as proved, as after a
live network's signed response, and a new test pins that a response the
SDK never verified leaves the version unconfirmed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK picks each transition's encoding from the platform version DET
passes in, so these tests checked dpp's version tables rather than DET.
The mainnet start version and the contest fund cap stay covered by the
platform_info and fee_estimation tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The SDK at this pin already tracks the version the network has proven:
it records the version of every response whose proof and quorum
signature it verified, and a rebuilt connection is a new SDK that starts
from nothing. DET's own copy, raised from proved epochs and DPNS reads
and reset on every rebuild, duplicated that state. The app now reads the
current SDK's verified version; capabilities still stay closed before a
version is proven and for one this build does not define, and network
info shows the proven number or says none is confirmed. Proved epochs
still set the fee multiplier, in epoch order and only on the current
connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A connection rebuild never changes the chain, the multiplier changes once
per epoch and feeds only fee estimates, so ordering epoch reads and
dropping those begun before a rebuild guarded against nothing worth the
machinery. A proved epoch read sets the multiplier directly again; an
unavailable epoch still keeps the last known value and labels it as
such. A rebuild still reads the epoch, so the new SDK proves the
network's version again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
A released protocol's tables and each network's minimum version are
upstream's to keep fixed; DET's start is covered by
platform_version_starts_at_the_network_minimum.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The proof verifier asks for contracts at the version it verifies with,
which can be newer than the SDK's. System contracts were already served
at that version; a saved user contract was decoded at the SDK's version
instead, dropping newer-protocol settings such as action fees. The
fallback now decodes it at the version asked for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…king

Building the recoverable-signature envelope returns an error upstream;
it is now reported as the existing message-signing failure, with the
detail logged, instead of aborting the signing path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
secp256k1 0.33's `SecretKey` is `Copy` with no `Drop`, so each plain copy
DET built from its self-zeroizing key material outlived the operation in
freed memory. Move `DetSigner`'s `ErasedSecretKey` into
`model::erased_secret_key` and use it wherever DET turns key bytes into a
`secp256k1::SecretKey`: wallet- and identity-key message signing, local
key signing on the key info screen, the HASH160 key check, auto-accept
proof signing, DashPay ECDH, and the DIP-14 tweak validation.

`with_identity_secret_key` lends the key to its closure as `&SecretKey`
so the closure can no longer take an un-erased copy. Signatures and ECDH
output are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 1d9d710 and 116b1b1.

Files selected for processing: 11
  • src/backend_task/dashpay/auto_accept_proof.rs
  • src/backend_task/dashpay/encryption.rs
  • src/backend_task/wallet/derive_identity_key_for_display.rs
  • src/backend_task/wallet/mod.rs
  • src/backend_task/wallet/sign_message_with_identity_key.rs
  • src/backend_task/wallet/sign_message_with_key.rs
  • src/model/dashpay_derivation/dip14.rs
  • src/model/dashpay_derivation/mod.rs
  • src/model/qualified_identity/mod.rs
  • src/ui/identity/keys/key_info_screen.rs
  • src/wallet_backend/det_signer.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 116b1b1) · triage: critical · Phase 2 only (no Phase 1 for this repository)

Base automatically changed from chore/bump-platform-063589bf to v1.0-dev October 26, 2026 11:17
lklimek and others added 2 commits October 26, 2026 11:18
…y-copies

The squash commit's tree equals #1114's final head, which this branch
already contains, so the tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
Replace DET's local `ErasedSecretKey` with the upstream `EcdsaSecretKey`
(dash-pkc via dashcore), which erases its scalar on drop, at every site
that signs, derives a public key, or range-checks a scalar. HD signing in
`DetSigner` and wallet-key message signing now sign with the derived
key itself, so no copy is made at all.

DIP-15 ECDH is the one site `EcdsaSecretKey` cannot serve, so it keeps a
private `EcdhSecretKey` wrapper in the encryption module. The shared
`model::erased_secret_key` module and the now-unused
`DerivationError::Secp256k1` variant are removed.

`EcdsaSecretKey::sign` grinds a low R as Dash Core does, so
non-recoverable signatures (Core transactions, single-key signing,
auto-accept proofs) change bytes for about half of all digests. They
stay valid, low-S and deterministic. Recoverable message signatures and
ECDH output are byte-identical. The DetSigner parity reference now signs
with `sign_low_r`, and new tests check that signatures verify and are in
standard low-S, low-R form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@Claudius-Maginificent Claudius-Maginificent changed the title fix(security): erase every secp256k1 secret key copy after use fix(security)!: sign with the self-erasing EcdsaSecretKey Oct 26, 2026
@lklimek
lklimek marked this pull request as ready for review October 26, 2026 12:54
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Oct 26, 2026
lklimek and others added 2 commits October 26, 2026 13:00
…4's I_L in Zeroizing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…into fix/erase-secp256k1-key-copies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw requested changes — dismiss the review or push a fix, 1 thread unresolved — resolve it. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 2 only (no Phase 1 for this repository)

The PR's ECDH wrapper still leaves one non-erasing secp256k1::SecretKey copy behind during construction. Because the wrapper is intended to close the exact residual-key gap addressed by this change, the constructor must explicitly erase the source copy after initializing the wrapper. The Test Suite check was still in progress in the supplied CI snapshot.

🔴 1 blocking

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6-astra (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — The diff is intricate and directly changes cryptographic signing, ECDH key handling, and private-key material lifetime in src/wallet_backend/det_signer.rs and src/backend_task/dashpay/encryption.rs.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — general (completed, effort xhigh); agent phase2-reviewer, gpt-6-astra — rust-quality (completed, effort xhigh); agent phase2-reviewer
  • Model comparison: every Phase-2 reviewer also ran on gpt-6-astra; the verifier weighed both sets without knowing which model wrote which
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `src/backend_task/dashpay/encryption.rs`:
- [BLOCKING] src/backend_task/dashpay/encryption.rs:27: ECDH constructor leaves the source SecretKey copy unerased
  `secp256k1::SecretKey` is `Copy` and has no `Drop`, so `map(Self)` copies the scalar into `EcdhSecretKey` while the source value passed through the `Result` remains an ordinary non-erasing copy. `EcdhSecretKey::Drop` only erases its tuple field; the source copy is discarded without calling `non_secure_erase`, leaving residual key material in memory. This contradicts the PR's defense-in-depth goal of erasing the raw ECDH key. Construct the wrapper explicitly, then erase the source `SecretKey` copy before returning it.

Comment thread src/backend_task/dashpay/encryption.rs Resolved
secp256k1::SecretKey is Copy, so wrapping it left the source copy unerased.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — coderabbitai not yet · thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@lklimek
lklimek enabled auto-merge (squash) October 26, 2026 13:51

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 2 only (no Phase 1 for this repository)

The current head consistently routes production signing and key-construction paths through self-erasing EcdsaSecretKey values, while the ECDH exception explicitly erases both the wrapped key and the constructor-local SecretKey copy. The reviewed changes preserve recoverable message-signature bytes, produce valid low-R signatures where intended, and the supplied Test Suite and Clippy checks passed for this exact head.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 3: gpt-6.1-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is an intricate cryptographic and key-handling change affecting ECDSA signing, recoverable signatures, ECDH, identity keys, and transaction-signing behavior in files including src/wallet_backend/det_signer.rs and src/backend_task/dashpay/encryption.rs.
  • Phase 1 reviewers: not run (disabled for this repository)
  • Fresh final gate: an independent Phase-2 review ran after iterative findings were reconciled
  • Fresh verifier: gpt-6.1-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — general (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot added bot-review-skipped A required review bot did not report; it was skipped by the window or by a person. and removed waiting-bots Waiting for the review bots to report on this head labels Oct 26, 2026
@lklimek
lklimek merged commit 88ef7e2 into v1.0-dev Oct 26, 2026
11 checks passed
@lklimek
lklimek deleted the fix/erase-secp256k1-key-copies branch October 26, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-review-skipped A required review bot did not report; it was skipped by the window or by a person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants