Skip to content

refactor: remove DPP raw secp256k1 dependency - #5519

Open
lklimek wants to merge 32 commits into
v5.2-devfrom
chore/crypto-core-consumers
Open

lklimek wants to merge 32 commits into
v5.2-devfrom
chore/crypto-core-consumers

Conversation

@lklimek

@lklimek lklimek commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

Dash Platform's protocol library (DPP) stops depending on the raw secp256k1 crate. Its consumers use rust-dashcore's typed keys and signatures instead. Signature bytes and key-generation output stay the same.

Detailed discussion

Targets v5.2-dev. #5979 is stacked on this PR.

Issue being fixed or feature implemented

DPP exposed a raw secp256k1 backend (dpp::secp256k1) after the typed Core migration in #5514. Consumers imported it through DPP, which coupled protocol code to client encryption and low-level backend types.

What was done?

  • Move DPP's secp256k1 dependency to dev-dependencies and remove dpp::secp256k1.
  • Use Core typed keys for key derivation, private-key matching, seeded generators, fixtures and Core-signer recovery metadata.
  • Migrate SDK, wallet, simple-signer, scripts, Drive test helpers and native/WASM bindings.
  • Preserve non-grinding deterministic signature bytes, seeded RNG consumption and key-parser encoding acceptance.
  • Keep direct raw secp256k1 dependencies only at ECDH boundaries in SDK/wallet/bindings; the C++ binding's asset lock signer recovers its key through Core's typed EcdsaRecSignature/EcdsaPublicKey::recover. Neither the pinned nor the current Core typed API exposes ECDH; it is tracked in feat(pkc): typed ECDH on secp256k1 keys base-sdk#137. platform-encryption is unchanged.
  • Keep raw secp256k1 as a test oracle where byte compatibility is asserted.
  • Do the same for code that v5.2-dev added since the previous merge:
    • dpp::tests::utils::high_s_twin (fixtures-and-mocks) computes n - S over bytes, because the pinned Core API has no scalar negation;
    • the multiple-choice proposal builder takes rand from dpp::dashcore::key::rand.

Behavior changes beyond the type swap

  • Error messages from key parsing and signing come from Core's EcdsaError. This changes the text of FFI/JS errors and of ProtocolError::Generic errors, but not their codes or types.
  • None in accepted inputs. Core's typed verify accepts high-S signatures, so verify_auto_accept_proof_with_pubkey checks is_low_s() to keep refusing them as the raw backend did. A test covers it.

Non-mechanical changes to review

Everything else is a 1:1 type or path swap. Line links point to the PR diff.

ID Where What Behavior
N1 auto_accept.rs:244-253 Typed verify plus is_low_s() guard unchanged: high-S still refused
N2 key_type.rs:214, key_type.rs:240, public_key.rs:43-59, secp256k1_primitives.rs:28-44 Error text from EcdsaError message text only
N3 dip14.rs:119-131 DIP-14 IL check without the SecretKey→Scalar round trip; wrong-length IL maps to InvalidKey unchanged; the length path is unreachable
N4 key_generation.rs:90-97 Redundant scalar check removed; PrivateKey::from_byte_array already validates unchanged
N5 key_generation.rs:217-222 Signing via sign_recoverable().signature(), because Core's sign grinds low-R unchanged bytes (pinned by tests)
N6 auto_accept.rs:153-157 Same as N5 for auto-accept proofs unchanged bytes (64-case test)
N7 mod.rs:2320-2369 sign_with_core_signer recovery-id search rewritten on typed recovery; the byte-parity rationale comment is kept unchanged
N8 random_secret_key.rs:1-35, used by signer.rs:104 One helper, dpp::util::ecdsa::random_secret_key, does rejection sampling of a secret key from a seeded RNG (as raw SecretKey::new), with a TODO to switch to Core once rust-dashcore exposes an RNG-parameterized constructor. dpp's generators and drive-abci's test helpers call it too unchanged keys and RNG consumption (tested against raw SecretKey::new)
N9 utils.rs:192-198 WipingSecretKey removed; the typed key zeroizes on drop unchanged
N10 secp256k1_primitives.rs:116-123 Typed parse, then raw re-parse at the ECDH boundary unchanged
N11 invitation.rs:262-271, invitation.rs:257 non_secure_erase → zeroize; the typed key also zeroizes on drop, the explicit wipe clears it before an encode error propagates wipes with zeros
N12 utils.rs:277-280 Test oracle replaced by the known hash160 of 1·G test only
M1 mod.rs:289-315 high_s_twin fixture computes n - S over bytes (Core has no scalar negation) unchanged (tests)
M2 signer.rs:126-166 C++ asset lock signer recovers its key through Core's typed API unchanged (test)

In-place changes to shipped generations

IdentityPublicKeyV0::validate_private_key_bytes keeps the same behavior: scalar acceptance, compressed public-key derivation and HASH160 comparison. KeyType v0 generators keep the same scalar bytes, public-key/hash bytes and RNG consumption; differential tests cover 64 seeds and three key types. Drive edits inside v0 modules are test/helper changes. No version table, consensus rule, fee schedule, wire format or storage schema changes.

Breaking Changes

Rust API changes:

  • Removes the raw dpp::secp256k1 re-export.
  • ContactCryptoProvider::export_auto_accept_private_key and export_invitation_private_key, and AutoAcceptProofSource::SignWithKey.secret_key, use Core EcdsaSecretKey.
  • SDK ParsedInvitation.voucher_key and key arguments to encode_invitation_uri, voucher_output_index and voucher_credit_output use Core keys.
  • Wallet auto-accept derive/sign/encode/decode functions use Core secret keys; verify_auto_accept_proof_with_pubkey takes EcdsaPublicKey.

ECDH interfaces keep the same underlying raw types through direct dependencies. C ABI and JavaScript signatures are unchanged; error message text changes as described above.

How Has This Been Tested?

Compatibility coverage: 64 seeded identity/address-key cases, 64 auto-accept signing cases, 32 messages with both WIF encodings, and compressed/uncompressed/hybrid SEC1 parser contracts (dpp ecdsa_compatibility and historical_hash_compatibility, should_preserve* tests in simple-signer, platform-wallet, wasm-sdk and wasm-dpp2).

On the current head:

  • cargo test -p dpp --lib --test ecdsa_compatibility -- high_s ecdsa: 31 + 4 passed, including the new high_s_twin tests and the high-S refusal paths.
  • cargo test -p platform-wallet --lib auto_accept: 21 passed, including the high-S refusal.
  • cargo test -p dash-sdk-cxx --lib signer: 1 passed.
  • cargo test -p dpp --lib --test ecdsa_compatibility --features random-public-keys: the seeded generator tests pass, including random_secret_key against raw SecretKey::new.
  • cargo test -p simple-signer --lib --features state-transitions should_preserve: 1 passed.
  • cargo clippy -p dpp -p simple-signer -p drive-abci --all-targets -- --no-deps -D warnings and cargo clippy -p simple-signer --all-targets --features state-transitions -- --no-deps -D warnings: clean.
  • cargo clippy -p dpp -p dash-sdk -p wasm-dpp2 --all-targets -- -D warnings: clean.
  • cargo clippy -p dash-sdk-cxx --all-targets -- --no-deps -D warnings: clean.
  • cargo clippy -p platform-wallet --lib -- -D warnings: clean for platform-wallet. It reports dead code in dash-sdk and platform-wallet test targets under the reduced feature set, in files this PR does not touch.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title (consensus-breaking only; none here) and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

🤖 Generated with Claude Code

https://claude.ai/code/session_01WunYYijwZNbw3EjHtdMAHC

🤖 Co-authored by Claudius the Magnificent AI Agent

PR Hygiene · 1da375b

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals
    • files with no dedicated owner (Cargo.lock, packages/rs-scripts/src/bin/register_identity.rs, packages/rs-sdk-cxx/Cargo.toml and 7 more) — QuantumExplorer or shumkov
    • dpp (packages/rs-dpp/Cargo.toml, packages/rs-dpp/src/identity/identity_public_key/key_type.rs, packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs and 8 more) — QuantumExplorer or shumkov
    • rs-drive-abci (packages/rs-drive-abci/examples/generate_wasm_contract_cache_vectors.rs, packages/rs-drive-abci/examples/generate_wasm_state_transition_wait_vectors.rs, packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs and 4 more) — QuantumExplorer or shumkov
    • rs-platform-wallet-ffi (packages/rs-platform-wallet-ffi/Cargo.toml, packages/rs-platform-wallet-ffi/src/contact_request.rs, packages/rs-platform-wallet-ffi/src/dashpay.rs and 4 more) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • rs-platform-wallet (packages/rs-platform-wallet/Cargo.toml, packages/rs-platform-wallet/examples/dpns_marketplace_testnet.rs, packages/rs-platform-wallet/src/masternode/locator.rs and 12 more) — HashEngineering or ZocoLini or llbartekll or romchornyi
    • rust-sdk-ffi — you own it
    • rust-sdk — you own it
    • js-wasm-sdk (packages/wasm-sdk/Cargo.toml, packages/wasm-sdk/src/encrypted_for.rs, packages/wasm-sdk/src/private_contact_requests.rs and 3 more) — shumkov

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.

Summary by CodeRabbit

  • New Features
    • Added validation for batch token-pool nullifiers after fee checks.
    • Expanded public-key input handling to support compressed and uncompressed encodings, while rejecting invalid encodings.
  • Bug Fixes
    • Improved ECDSA key generation and signing compatibility, preserving legacy outputs for seeded key generation and compact signatures.
    • Invalid ECDSA private keys continue to be rejected, and malformed auto-accept proofs remain unverifiable.
    • Invitation voucher keys are securely cleared after use.

lklimek and others added 19 commits October 21, 2026 12:14
Prepare the dependency graph; consumer adaptations and validation follow before publication.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Co-Authored-By: Claude GPT-6 <noreply@anthropic.com>
Preserve compact signing and compressed public-key encodings at the FFI boundary.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Exercise multiple digests to detect accidental low-R signature grinding.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Preserve consensus ECDSA parsing, verification and error strings through DPP-owned validation using the unchanged secp256k1 backend. Adapt SDK and binding key ownership and add historical signature and malformed-input regressions.

Co-Authored-By: Claudius the Magnificent <claudius@users.noreply.github.com>
Co-Authored-By: Claude GPT-6 <noreply@anthropic.com>
Co-Authored-By: Claude GPT-6 <noreply@anthropic.com>
<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Remove the local compatibility adapter while preserving signature acceptance, key encodings and fee operations. Adopt upstream diagnostic text and error precedence; these descriptions are carried in ABCI info, outside the Tenderdash results hash.

Co-Authored-By: OpenAI Codex <noreply@openai.com>
Preserve non-grinding signatures, SEC1 parser acceptance and compressed encodings.
Keep direct secp256k1 dependencies only for ECDH primitives and compatibility tests.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
Use Core typed keys and signatures throughout non-ECDH consumers, retaining
raw primitives only at the encryption boundary and in compatibility tests.
Preserve seeded key generation, compact signature bytes, and validation
outcomes with differential and historical-vector coverage.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>

Co-Authored-By: Codex GPT-6 <noreply@openai.com>
@thepastaclaw

thepastaclaw commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 1da375b) · triage: critical

Take the committed preservation snapshot before releasing the SwiftData
container and context so their teardown cannot race the source read lock.
Keep the migration and all thirteen field-preservation assertions unchanged.

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

The pull request migrates ECDSA key operations across DPP, wallet, SDK, FFI, and WASM code to Dash Core ECDSA types. It retains direct secp256k1 types for ECDH boundaries and adds tests for key-generation and signature compatibility.

Changes: ECDSA API migration

Layer / File(s) Summary
DPP key handling and signing
packages/rs-dpp/...
DPP key generation, conversion, validation, and state-transition signing now use Dash Core ECDSA APIs. The public secp256k1 re-export is removed. Compatibility tests compare generated keys and RNG state with the prior path.
Random-key callers and Drive fixtures
packages/simple-signer/..., packages/rs-drive-abci/..., packages/rs-scripts/..., packages/strategy-tests/...
Random key generation and key fixtures use Dash Core ECDSA types. Drive identity-update and address-signing tests use compressed public keys and serialized secret-key bytes.
Wallet key and proof operations
packages/rs-platform-wallet/src/masternode/..., packages/rs-platform-wallet/src/wallet/identity/crypto/..., packages/rs-platform-wallet/src/wallet/shielded/...
Wallet key derivation and auto-accept proof operations use Dash Core ECDSA types. Tests compare proof signatures with historical compact signatures. Voucher-key cleanup uses zeroize().
Wallet contact and invitation interfaces
packages/rs-platform-wallet/src/wallet/identity/network/...
Contact-crypto interfaces use direct secp256k1 types for ECDH peers and Dash Core ECDSA types for exported private keys. Wallet call sites and test providers use the updated types.
FFI boundaries
packages/rs-platform-wallet-ffi/..., packages/rs-sdk-ffi/...
FFI key parsing and export use Dash Core ECDSA APIs. Direct secp256k1 types remain for ECDH operations. SDK FFI voting-key derivation uses Dash Core ECDSA types.
SDK and WASM key handling
packages/rs-sdk/..., packages/wasm-dpp2/..., packages/wasm-sdk/...
SDK imports and key conversions use Dash Core or direct secp256k1 APIs. Invitation voucher handling uses Dash Core ECDSA types and zeroize(). WASM key parsing and message signing use the updated APIs, with compatibility tests.

Estimated code review effort: 4 (Complex) | ~50 minutes

Change: Refactor

Suggested reviewers: quantumexplorer, shumkov, llbartekll

Merge Risk: Minimal · up to 6e697

The migration has no demonstrated merge-blocking regression. Remaining recommendations strengthen compatibility and witness tests and fix an existing public-key setter error path.

Pre-merge checks: Passed 4

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title is vague and generic. It does not say what is removed, where, or why. The PR is a refactor that removes DPP's raw secp256k1 dependency and re-export and migrates consumers to rust-dashcore's…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title is vague and generic. It does not say what is removed, where, or why. The PR is a refactor that removes DPP's raw secp256k1 dependency and re-export and migrates consumers to rust-dashcore's typed ECDSA keys and signatures. The title uses the correct subject, but it reads as a short label. A teammate scanning history can see the primary change. The title does not need to cover every detail, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 13c8b0a and 6e697a7.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 54

  • packages/rs-dpp/Cargo.toml
  • packages/rs-dpp/src/identity/identity_public_key/key_type.rs
  • packages/rs-dpp/src/identity/identity_public_key/v0/methods/mod.rs
  • packages/rs-dpp/src/lib.rs
  • packages/rs-dpp/src/state_transition/mod.rs
  • packages/rs-dpp/src/state_transition/traits/state_transition_identity_signed.rs
  • packages/rs-dpp/src/tests/fixtures/instant_asset_lock_proof_fixture.rs
  • packages/rs-dpp/tests/ecdsa_compatibility.rs
  • packages/rs-drive-abci/examples/generate_wasm_contract_cache_vectors.rs
  • packages/rs-drive-abci/examples/generate_wasm_state_transition_wait_vectors.rs
  • packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_create_from_addresses/tests.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs
  • packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/test_helpers.rs
  • packages/rs-drive-abci/tests/strategy_tests/strategy.rs
  • packages/rs-platform-wallet-ffi/Cargo.toml
  • packages/rs-platform-wallet-ffi/src/dashpay.rs
  • packages/rs-platform-wallet-ffi/src/invitation.rs
  • packages/rs-platform-wallet-ffi/src/secp256k1_primitives.rs
  • packages/rs-platform-wallet-ffi/src/utils.rs
  • packages/rs-platform-wallet/Cargo.toml
  • packages/rs-platform-wallet/examples/dpns_marketplace_testnet.rs
  • packages/rs-platform-wallet/src/masternode/locator.rs
  • packages/rs-platform-wallet/src/wallet/identity/crypto/auto_accept.rs
  • packages/rs-platform-wallet/src/wallet/identity/crypto/validation.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/contact_info.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/identity_handle.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/payments.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/sdk_writer.rs
  • packages/rs-platform-wallet/src/wallet/identity/network/seed_binding.rs
  • packages/rs-platform-wallet/src/wallet/shielded/wallet_drain_tests.rs
  • packages/rs-scripts/src/bin/register_identity.rs
  • packages/rs-sdk-ffi/Cargo.toml
  • packages/rs-sdk-ffi/src/contested_resource/transitions/cast_vote.rs
  • packages/rs-sdk-ffi/src/mnemonic_resolver_core_signer.rs
  • packages/rs-sdk/Cargo.toml
  • packages/rs-sdk/src/platform/dashpay/contact_request.rs
  • packages/rs-sdk/src/platform/dashpay/invitation.rs
  • packages/rs-sdk/src/platform/dashpay/profile.rs
  • packages/rs-sdk/src/platform/dpns_usernames/mod.rs
  • packages/rs-sdk/src/platform/encrypted_for.rs
  • packages/rs-sdk/src/platform/moderation_charters/requests.rs
  • packages/rs-sdk/src/platform/transition/put_document.rs
  • packages/simple-signer/Cargo.toml
  • packages/simple-signer/src/signer.rs
  • packages/strategy-tests/src/transitions.rs
  • packages/wasm-dpp2/src/public_key.rs
  • packages/wasm-sdk/Cargo.toml
  • packages/wasm-sdk/src/encrypted_for.rs
  • packages/wasm-sdk/src/state_transitions/contract/cache_tests.rs
  • packages/wasm-sdk/src/wallet/dip14.rs
  • packages/wasm-sdk/src/wallet/key_generation.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Base automatically changed from chore/rust-dashcore-crypto-migration to v5.1-dev October 21, 2026 17:05
@github-actions github-actions Bot added this to the v5.1.0 milestone Oct 21, 2026

@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 1 + Phase 2

The migration preserves the reviewed typed-key, signing, parsing, and seeded-generation behavior, and no blocking correctness or consensus defects were identified. Two non-blocking suggestions remain: track the missing typed ECDH capability upstream and avoid leaving an unzeroized raw ECDH key in the newly added test provider. Kotlin CI is passing; PR Hygiene remains pending, and no local builds or tests were run in this static-review lane.

🟡 2 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-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: architecture-layering); reviewer 5: gpt-6.1-sol (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.1-sol (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.1-sol (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.1-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.1-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.1-sol (effort low) — This is a large, cross-cutting cryptography and key-handling migration that changes signature generation, parsing, derivation, validation, and FFI/WASM consumers across protocol and wallet code.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • 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 — architecture-layering (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — ffi-engineer (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — platform-versioning (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — rust-quality (completed, effort xhigh); agent phase2-reviewer, gpt-6.1-sol — security-auditor (completed, effort xhigh); agent phase2-reviewer
🤖 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 `packages/rs-sdk/Cargo.toml`:
- [SUGGESTION] packages/rs-sdk/Cargo.toml:7-8: Track typed ECDH support in the upstream crypto owner
  The direct raw `secp256k1` dependency is a reasonable compatibility bridge because the pinned and current rust-dashcore/base-sdk revisions do not expose typed ECDH. However, this migration now leaves raw-key interfaces or scalar conversions across the SDK, wallet, and bindings without a linked upstream tracking issue. Create or link an issue in the owning crypto project for typed constant-time ECDH APIs covering both platform-encryption's hashed shared-secret convention and DashConnect's raw shared-X convention; the consumers can then migrate without exporting and reparsing scalars.

In `packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/contact_requests.rs:211-215: Erase the raw ECDH secret created by the test provider
  This newly added `SeedCryptoProvider` path converts the typed key's scalar into a raw `secp256k1::SecretKey` and passes it directly to ECDH. That raw key is not zeroized when the call returns, unlike the `WipingSecretKey` guards used by the other raw-ECDH paths. Although this provider is test-only, it introduces a secret-handling pattern that can be copied into production code; wrap the temporary raw key in the same erasure guard before calling `derive_shared_key_ecdh`.

Comment thread packages/rs-sdk/Cargo.toml Resolved
…ypto-core-consumers

Bring in v5.1-dev, which squash-merged the stacked parent #5514 as
3a731bf. Conflicts were resolved by re-merging with the #5514 tip
(d14aa58) as the merge base: the squash is byte-identical to that tip
apart from the rust-dashcore pin bump, so this applies exactly the #5519
delta on top of v5.1-dev.

Semantic fixes:
- A plain merge against the original fork point silently re-added the
  squash's `pub use secp256k1` re-export and production `secp256k1`
  dependency to rs-dpp, plus `dpp::secp256k1` imports in platform-wallet
  (masternode locator), rs-sdk-ffi (cast_vote, mnemonic resolver core
  signer) and wasm-sdk (encrypted_for). Those are dropped again, so DPP
  keeps no production raw secp256k1 dependency.
- rs-sdk dashpay/profile, dpns_usernames and put_document: keep base's
  new ResponseMetadata/ContextProvider/StateTransition imports and move
  the RNG imports from `dpp::secp256k1::rand` to `dpp::dashcore::key::rand`.
- Cargo.toml/Cargo.lock: base's dependency pins, plus only #5519's
  per-crate secp256k1 moves; cargo accepts the lock with --locked.

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

Claudius-Maginificent commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Update: #5643 and #5639 were closed in favour of #5637, so this PR now waits for #5637.

#5637 moves rust-dashcore to 7329126e and adds the dpp low-S guard (dpp::util::ecdsa). That guard uses the typed dashcore::crypto::ecdsa::EcdsaSignature::is_low_s, not raw secp256k1, so it does not conflict with removing raw secp256k1 from dpp. The earlier concern about #5643's secp256k1::ecdsa::Signature::from + normalize_s no longer applies.

Once #5637 merges, merge v5.1-dev into this branch, check that no raw secp256k1 use came back into dpp's production code, and remove the postponed label.

🤖 Co-authored by Claudius the Magnificent AI Agent

@github-actions github-actions Bot removed the waiting-bots Waiting for the review bots to report on this head label Nov 17, 2026
…-consumers

# Conflicts:
#	Cargo.lock
#	packages/rs-dpp/Cargo.toml
`high_s_twin` (dpp fixtures, built under `fixtures-and-mocks`) negated S
through the raw `secp256k1` crate, which dpp no longer depends on outside
tests; compute `n - S` over the big-endian bytes instead. The multiple
choice proposal builder imported `rand` through the removed
`dpp::secp256k1` re-export; use `dpp::dashcore::key::rand` like the other
SDK builders.

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

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 18, 2026
@lklimek lklimek changed the title refactor: remove DPP raw secp256k1 dependency refactor!: remove DPP raw secp256k1 dependency Nov 18, 2026
The asset lock signer parsed the wallet's compact signature and recovered
its key with raw `secp256k1` types, although Core exposes
`EcdsaRecSignature` and `EcdsaPublicKey::recover`. Use them; the header
check, recovered key and returned signature bytes are unchanged. Raw
`secp256k1` stays only for ECDH and as the test oracle.

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

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
…typed migration

Core's typed `EcdsaPublicKey::verify` normalizes S, so a third party could
turn a valid auto-accept proof into a second, high-S proof that verified.
The raw `secp256k1` verify this replaced refused it; check `is_low_s()`
first to keep the accepted set unchanged.

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

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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.

…d simple-signer

dpp's random key generators, drive-abci's test helpers and simple-signer
each re-implemented `secp256k1::SecretKey::new`'s rejection sampling to
keep seeded keys and RNG consumption unchanged. Keep one copy in
`dpp::util::ecdsa::random_secret_key`, with a test against the raw
constructor, until rust-dashcore exposes an RNG-parameterized one.

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

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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.

…er wipe comment

`sign_with_core_signer` lost the reason it searches recovery ids and keeps
the signer's bytes (non-grinding nonce, low-S). The invitation flow said
`EcdsaSecretKey` has no drop-time zeroize; it has one, and the explicit
wipe exists to clear the key before an encode error propagates.

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

<sub>🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent</sub>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — 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 changed the title refactor!: remove DPP raw secp256k1 dependency refactor: remove DPP raw secp256k1 dependency Nov 18, 2026
@lklimek

lklimek commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@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 1 + Phase 2

The typed ECDSA migration remains behavior-preserving across key generation, signatures, recovery, parsing, and low-S enforcement, with no in-scope blocking correctness or consensus issue identified. One non-blocking architecture suggestion remains: track the missing parameterized typed RNG constructor in rust-dashcore so the local compatibility sampler can eventually be removed. Available CI reports no failed code checks; the review check is queued and PR Hygiene is still pending.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: ffi-engineer); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 8: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The 73-file migration changes production signing and key handling, including DPP state-transition signing and high-S rejection in verify_auto_accept_proof_with_pubkey, where preserving exact bytes and accepted inputs requires careful review.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — ffi-engineer (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-dpp/src/util/ecdsa/random_secret_key.rs`:
- [SUGGESTION] packages/rs-dpp/src/util/ecdsa/random_secret_key.rs:4-8: Track the typed RNG constructor in rust-dashcore
  This helper locally reimplements secp256k1 rejection sampling because rust-dashcore exposes only a thread-RNG `EcdsaSecretKey::generate()`, while the underlying dash-pkc API already has a parameterized `generate(rng, compression)` constructor. The local implementation is currently needed to preserve seeded RNG output and consumption, but that compatibility logic belongs with the crypto owner and can drift from the upstream implementation. Add an upstream rust-dashcore issue or PR for exposing the parameterized constructor, then replace this helper with that API when available.
Out-of-scope follow-up suggestions (1)

These are valid observations, but they are outside this PR's scope and should be handled in separate issues or author/maintainer-requested PRs rather than blocking this review.

  • Make wasm-dpp2 public-key setter failure-atomic — The set_inner setter updates compressed before its fallible key parse, so an invalid input can leave the wrapper's encoding flag inconsistent with its unchanged key. This behavior predates #5519 and is not part of the mechanical migration, but it should be fixed because it can corrupt wrapper state after an error.

Comment on lines +4 to +8
/// Draws a secret key from `rng` exactly as `secp256k1::SecretKey::new` does: 32 bytes at a time
/// until they form a valid scalar. Seeded callers get the same keys, and leave `rng` in the same
/// state, as before the typed key migration.
// TODO: replace with Core's RNG-parameterized constructor once rust-dashcore exposes one
// (dash-pkc already has `EcdsaSecretKey::generate(rng, compressed)`).

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.

🟡 Suggestion: Track the typed RNG constructor in rust-dashcore

This helper locally reimplements secp256k1 rejection sampling because rust-dashcore exposes only a thread-RNG EcdsaSecretKey::generate(), while the underlying dash-pkc API already has a parameterized generate(rng, compression) constructor. The local implementation is currently needed to preserve seeded RNG output and consumption, but that compatibility logic belongs with the crypto owner and can drift from the upstream implementation. Add an upstream rust-dashcore issue or PR for exposing the parameterized constructor, then replace this helper with that API when available.

source: gpt-6.2-astra (phase2-reviewer: architecture-layering)

@github-actions

Copy link
Copy Markdown
Contributor

Ready for review — files with no dedicated owner: QuantumExplorer or shumkov · dpp: QuantumExplorer or shumkov · rs-drive-abci: QuantumExplorer or shumkov · rs-platform-wallet-ffi: HashEngineering or ZocoLini or llbartekll or romchornyi · rs-platform-wallet: HashEngineering or ZocoLini or llbartekll or romchornyi · js-wasm-sdk: shumkov.
Full checklist in the description.

@github-actions github-actions Bot added ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human. and removed waiting-bots Waiting for the review bots to report on this head labels Nov 18, 2026

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

priority: low Low priority — nice to have ready-for-human Bots have reported, the author has self-reviewed, and the build is green: this needs a human.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants