Repository navigation
feat(platform)!: add SLH-DSA-SHA2-128s identity keys (PV16) - #6510
QuantumExplorer wants to merge 7 commits into
Conversation
Adds `KeyType::SLH_DSA_SHA2_128S` (8), the SLH-DSA-SHA2-128s signature scheme of FIPS 205, as an identity key type from protocol version 16. The scheme rests on SHA-256 alone, so it does not depend on the lattice problems ML_DSA_65 does. Its public key is 32 bytes and its signature 7,856 bytes, fast to check and slow to make: it is meant for master keys and other keys that sign seldom. The key type follows ML_DSA_65: a signing key for AUTHENTICATION and TRANSFER, refused for ENCRYPTION and DECRYPTION, unique to one identity, added with a proof of possession, signing in the pure scheme with the empty context string and the deterministic variant. A transition registering one is not active before protocol version 16. - `dpp::util::slh_dsa_sha2_128s` signs and verifies with the RustCrypto `slh-dsa` crate, pinned to 0.2.0. The private key is a 32 byte seed that HKDF-SHA256 expands into the three values a key pair is generated from; the key pair and signature of a seed are pinned to what OpenSSL 4.1.0 gives. - A failed proof of possession is `BasicSLHDSAError` (20020). - Checking a signature costs `verify_signature_slh_dsa_sha2_128s`, 300,000 credits, priced for a validator without SHA-256 instructions. - Emergency switch `KeyTypeSlhDsaSha2128s` (12) gates the key type alone. - No size limit is added: a state transition holds two signatures of the type and not three, and a larger one is refused unpaid by the existing size check. - wasm, FFI, Swift and Kotlin know the key type; wallets neither derive nor sign with it yet. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Takes the lower layer's fix that refuses two non-unique keys with one hash in a transition. One conflict, in the doc comment of key structure validation 1: both paragraphs are kept. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
📖 Book Preview built successfully. Download the preview from the workflow artifacts. Updated at 2026-12-04T11:18:08.932Z |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
✅ Final review complete — no blockers (commit b2f7b23) · triage: critical |
thepastaclaw
left a comment
There was a problem hiding this comment.
Final validation — Phase 1 + Phase 2
Changes requested: 3 blockers
- Android reports imported SLH-DSA keys as usable, then signs with ECDSA —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt:46-51(new)
Impact: An Android SDK caller using an imported SLH-DSA seed can pass signer preflight and receive a signature that cannot authorize the transition. - A repeated invitation claim can misreport the invitee's own SLH-DSA identity as already claimed —
packages/rs-dpp/src/identity/identity_public_key/key_type.rs:162-164(new)
Impact: A Rust SDK invitee whose first claim landed but whose retry passes a stale preflight can getAlreadyClaimedinstead of the funded identity their wallet should record. - Swift validates SLH-DSA seed length against its own copy of the Rust rule —
packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:255-256(new)
Impact: Swift callers ofKeySizeValidator.isValidSizeget a verdict from a separate length table that can disagree with the Rust signer and key derivation.
This PR adds SLH-DSA-SHA2-128s identity keys at protocol version 16, including proof-of-possession and transition signature verification, a fee entry, an emergency switch, and SDK bindings. The latest GitHub checks show the Kotlin SDK build and x86_64 emulator tests and the book preview passed; the automated review check is pending. This was a static review, with no local builds or tests run.
🔴 3 blocking | 🟡 7 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: FFI identity constructors maintain separate lists of recognized DPP key types
Impact: A future DPP key type can be accepted by signer preflight but rejected by an identity constructor if one of the extra mappings is missed.
packages/rs-sdk-ffi/src/identity/keys.rs:222-238
Both constructors accept type 8 today, but they can drift from the signer and from each other. This match and dash_sdk_identity_create_from_components each reimplement the complete byte-to-KeyType conversion, including rejection of unknown bytes. Use DPP's KeyType::try_from in both places, as signer preflight already does, and leave only InvalidParameter error translation at the boundary.
let key_type = match KeyType::try_from(key_type) {
Ok(key_type) => key_type,
Err(_) => {
return DashSDKResult::error(DashSDKError::new(
DashSDKErrorCode::InvalidParameter,
format!("Invalid key type: {}", key_type),
));
}
};
source: gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)
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.2-astra (agent: phase2-reviewer, role: general); 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:
criticalbygpt-6.2-sol(effort low) — This is a large, cross-cutting change that modifies consensus identity-key validation and activation, cryptographic signing and proof-of-possession code, signature verification, fee handling, and multiple FFI/WASM/SDK key boundaries, including packages/rs-dpp/src/util/slh_dsa_sha2_128s.rs and identity/state-transition validation paths. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt:46-51: Android reports imported SLH-DSA keys as usable, then signs with ECDSA
Impact: An Android SDK caller using an imported SLH-DSA seed can pass signer preflight and receive a signature that cannot authorize the transition.
A stored SLH-DSA key can be selected for signing even though the Android signer cannot use it. `WalletStorage.storePrivateKey` accepts caller-supplied bytes under the public-key hex, so this does not require wallet derivation. `KeystoreSigner.canSignWith` checks whether that entry is decryptable, then `dispatchSign` drops `keyType` and calls the stored-key signer. The JNI helper ultimately calls `dash_sdk_signer_sign`, which supplies an ECDSA key type to `SingleKeySigner`; a seed that also parses as a secp256k1 scalar returns a 65-byte ECDSA signature instead of the required 7,856-byte SLH signature. Preserve the identity key type across the native boundary and use the Rust signer's capability check for both preflight and signing, before requesting the stored secret. Leave the separate `0xFF` address route and custom signers intact.
In `packages/rs-dpp/src/identity/identity_public_key/key_type.rs`:
- [BLOCKING] packages/rs-dpp/src/identity/identity_public_key/key_type.rs:162-164: A repeated invitation claim can misreport the invitee's own SLH-DSA identity as already claimed
Impact: A Rust SDK invitee whose first claim landed but whose retry passes a stale preflight can get `AlreadyClaimed` instead of the funded identity their wallet should record.
The SDK discards the recovery result even when the fetched identity carries exactly the keys the invitee submitted. `Sdk::claim_invitation` accepts a caller-supplied key map and signer, so an SLH-DSA master does not require wallet derivation. If the retry passes preflight but Platform reports the outpoint consumed, `adopt_already_landed_claim` fetches the identity again. Its `identity_carries_keys` predicate in `rs-sdk/src/platform/dashpay/invitation.rs:1618` recognizes only ECDSA and BLS as proof of possession. An SLH master with no ECDSA or BLS key fails that test despite Platform having verified its proof. Use DPP's `is_unique_key_type()` predicate, as the identity-create builder does, while retaining the exact creation-field comparison and the refusal to adopt a set without a possession-backed key.
In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:255-256: Swift validates SLH-DSA seed length against its own copy of the Rust rule
Impact: Swift callers of `KeySizeValidator.isValidSize` get a verdict from a separate length table that can disagree with the Rust signer and key derivation.
The Swift validator can drift from the code that actually consumes the seed. This literal is not display metadata: `isValidSize` compares the input length against it. DPP already owns the same check in `slh_dsa_sha2_128s::seed_from_private_key`. The book's “Validation lives once” rule explicitly prohibits duplicating length checks in SDKs. Keep the existing Swift API but obtain the expected size or the validation result from DPP through FFI.
In `packages/rs-dpp/src/state_transition/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/state_transition/mod.rs:1169-1172: The default DPP decoder accepts SLH-DSA key registrations at protocol version 15
Impact: A Rust client using DPP's default features gets `Ok` from the version-aware decoder for an SLH-DSA registration that a PV15 node refuses.
A client relying on the public decoder's documented activation check can mistake a type-8 registration for one the selected network accepts. The new range is correct, but `decode_untrusted_in_version` applies it to every transition only with `validation` enabled. The default build enables `state-transitions` without `validation`, and all four key-registration transitions return through `carried_contract() == None` without checking the range. Before the PR, byte 8 failed enum decoding even in that build. Apply DPP's key activation rule in the shared path used by both version-aware decoders, preserving unrelated legacy behavior. Verify it from a default-feature consumer, since DPP's own dev-dependency enables `validation`. Node validation already enforces the gate.
- [SUGGESTION] packages/rs-dpp/src/state_transition/mod.rs:2333-2343: Signing an SLH-DSA transition generates the same key pair twice
Impact: Every successful `StateTransition::sign` with an SLH-DSA key pays for an extra key generation, which the PR measured at 8.6 ms on its hardware-accelerated machine.
Wallet signing does the key-generation work twice for the same seed. `public_key_from_seed` constructs a full signing key for the public-key comparison and drops it; `sign_by_private_key` then calls the SLH helper, which constructs it again. Reuse one signing key for the comparison and signature, preserving the existing `InvalidSignaturePublicKeyError` and leaving the transition unchanged on mismatch.
In `packages/rs-dpp/src/util/slh_dsa_sha2_128s.rs`:
- [SUGGESTION] packages/rs-dpp/src/util/slh_dsa_sha2_128s.rs:77-92: SLH-DSA key generation leaves expanded signing material without a wipe-on-drop guarantee
Impact: Wallets signing or deriving a public key can leave enough material in process memory to reconstruct the signing key after the original seed is erased.
Erasing the caller's seed does not erase the expanded secret. `key_generation_input_from_seed` writes `SK.seed || SK.prf || PK.seed` into an ordinary copyable array, which `signing_key_from_seed` drops without clearing. The `slh-dsa` dependency's `zeroize` feature does not cover this DPP-owned buffer. Expand directly into a zeroizing buffer and borrow its slices through key construction. If the helper remains public, return the guarded buffer and document that its contents are private-key material.
- [SUGGESTION] packages/rs-dpp/src/util/slh_dsa_sha2_128s.rs:36-37: Reusing an ECDSA scalar as an SLH-DSA seed undermines post-quantum migration
Impact: A wallet that reuses an old ECDSA scalar can lose control of its new SLH-DSA key if the old scalar is later recovered, even after the ECDSA key is disabled.
Different derived key material does not protect the new key if an old, recoverable secret is its input. The HKDF comment says that using the same bytes gives unrelated key material, but anyone who recovers the ECDSA scalar from the historical public key can reconstruct the SLH-DSA key from it. Clarify in this comment and the SDK key guide that wallets should use an independent random seed or a separately derived wallet subkey, not an existing signing scalar. The HKDF construction itself does not need to change.
In `packages/wasm-dpp2/src/enums/keys/key_type.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/enums/keys/key_type.rs:49: WASM rejects valid SLH-DSA seeds that are not secp256k1 scalars
Impact: JavaScript callers signing transitions with `wasm-dpp2` cannot import some 32-byte SLH-DSA seeds that native DPP accepts.
The new key type reaches DPP, but not all of its valid private inputs can get there. `StateTransition.sign` and `signByPrivateKey` both require a `PrivateKeyWasm`. Its constructors parse a Dash Core `PrivateKey`, whose `from_byte_array` requires a valid `EcdsaSecretKey`. For example, 32 bytes of `0xff` are accepted by DPP's SLH-DSA seed parser but rejected before WASM calls the signer. Offer a byte-oriented input for identity signing that passes the requested key type and bytes to DPP. Keep scalar validation on the existing ECDSA `PrivateKey` API.
In `packages/wasm-sdk/src/document_create_cost.rs`:
- [SUGGESTION] packages/wasm-sdk/src/document_create_cost.rs:180: PV14 and PV15 document estimates quote a fee for an inactive SLH-DSA signing key
Impact: A caller estimating document creation at PV14 or PV15 with an SLH-DSA signature sees an exact 300,000-credit signature charge for an operation that cannot use that key type on the selected network.
The estimator presents a price for an unavailable signing path. `documentCreateCost` accepts the new key type and forwards it as a caller-supplied assumption; Drive's `processing_costs` reads `signature_verify_cost` without looking up a registered key. Both historical snapshots inherit the signature fee table with the new entry, so the state-registration gate that protects block execution does not protect estimation. Have the Rust estimator reject inactive signing-key assumptions using the same DPP activation definition as registration so native and WASM callers agree.
In `packages/rs-sdk-ffi/src/identity/keys.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/identity/keys.rs:222-238: FFI identity constructors maintain separate lists of recognized DPP key types
Impact: A future DPP key type can be accepted by signer preflight but rejected by an identity constructor if one of the extra mappings is missed.
Both constructors accept type 8 today, but they can drift from the signer and from each other. This match and `dash_sdk_identity_create_from_components` each reimplement the complete byte-to-`KeyType` conversion, including rejection of unknown bytes. Use DPP's `KeyType::try_from` in both places, as signer preflight already does, and leave only `InvalidParameter` error translation at the boundary.
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.
- A missing-key error in SimpleSigner includes the signer's other private keys —
SimpleSigner::signformatsselfinto its missing-key error, and the existingDebugimplementation prints private-key values in Base64. Logging that error can disclose loaded keys. Both behaviors predate this PR; the signer is also used by theregister_identitytool.- Follow-up: Open a separate PR to redact private keys from
Debug, omit signer contents from lookup errors, and test that neither representation contains a known test secret.
- Follow-up: Open a separate PR to redact private keys from
…feat/slh-dsa-identity-keys
- sdk: a repeated invitation claim recognizes its own identity through any key Platform admits with a proof of possession (`is_unique_key_type`), not through ECDSA and BLS keys alone, so an SLH_DSA_SHA2_128S or ML_DSA_65 master counts. - dpp: `KeyType::initial_protocol_version` is the one definition of when a key type exists. The active version range of a key registration reads it, and a build without the `validation` feature now holds a transition registering a key type added after the first protocol version to that range, as the validating build does. - dpp: the 48 bytes an SLH_DSA_SHA2_128S seed expands into are wiped when dropped, and `StateTransition::sign` generates the key pair once for the public key comparison and the signature (`slh_dsa_sha2_128s::KeyPair`). - docs: the seed must be a secret of its own; one that is also an ECDSA private key gives no protection against a quantum computer. Co-Authored-By: Claude Fable 5.2 <[email protected]>
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
Updated after discussion: 2 finding(s) of this review were settled in the inline threads; 2 blocking finding(s) still stand.
- ✅ Withdrawn: 🟡 PV14 and PV15 document estimates quote a fee for an inactive SLH-DSA signing key
- ⏭️ Deferred (maintainer decision): 🟡 WASM rejects valid SLH-DSA seeds that are not secp256k1 scalars (tracked in #6394)
Changes requested: 2 blockers
- Android reports imported SLH-DSA keys as usable, then signs with ECDSA —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt:46-51(thread, carried)
Impact: An Android SDK app that stores an SLH-DSA transfer key can have that key selected for a credit transfer and receive an ECDSA signature that Platform cannot verify. - Swift validates SLH-DSA seed length against its own copy of the Rust rule —
packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:255-256(thread, carried)
Impact: Swift callers ofKeySizeValidator.isValidSizeget a verdict from a rule maintained separately from the DPP parser that consumes the seed.
New on this head: This revision applies the PV16 key-registration gate in default-feature DPP decoders, reuses the SLH-DSA key pair for checked signing, zeroizes the expanded seed material, documents the need for an independent seed, and updates invitation recovery to recognize possession-backed keys. The Kotlin SDK emulator build and tests and the book preview passed; no code check reported a failure.
🔴 2 blocking | 🟡 5 3 suggestion(s)
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: FFI identity constructors maintain separate lists of recognized DPP key types
Impact: A future DPP key type can be recognized by the C signer API but rejected by either identity constructor if its local table is not updated.
packages/rs-sdk-ffi/src/identity/keys.rs:222-238
The two public constructors can drift from DPP and from each other. dash_sdk_identity_public_key_create_from_data and dash_sdk_identity_create_from_components each enumerate bytes 0–8; they agree today because both were updated for type 8. The signer API already delegates the same conversion to KeyType::try_from(u8). Use that conversion in both constructors and retain their existing InvalidParameter response for unknown bytes.
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: general, architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)
Still open from earlier rounds (4)
- 🔴 Blocking: Android reports imported SLH-DSA keys as usable, then signs with ECDSA —
packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt:46-51(thread) - 🔴 Blocking: Swift validates SLH-DSA seed length against its own copy of the Rust rule —
packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:255-256(thread) - 🟡 Suggestion: PV14 and PV15 document estimates quote a fee for an inactive SLH-DSA signing key —
packages/wasm-sdk/src/document_create_cost.rs:180(thread) — settled: ✅ Withdrawn - 🟡 Suggestion: WASM rejects valid SLH-DSA seeds that are not secp256k1 scalars —
packages/wasm-dpp2/src/enums/keys/key_type.rs:49(thread) — settled: ⏭️ Deferred (maintainer decision)
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:
criticalbygpt-6.2-sol(effort low) — This is a large cross-cutting change that modifies consensus rules, protocol-version activation and fees, cryptographic signing and verification, identity key handling, and multiple FFI/WASM boundaries, including files such as packages/rs-dpp/src/util/slh_dsa_sha2_128s.rs and packages/rs-drive-abci/src/execution/validation/state_transition/state_transitions/identity_update/mod.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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-sdk-ffi/src/identity/keys.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/identity/keys.rs:222-238: FFI identity constructors maintain separate lists of recognized DPP key types
Impact: A future DPP key type can be recognized by the C signer API but rejected by either identity constructor if its local table is not updated.
The two public constructors can drift from DPP and from each other. `dash_sdk_identity_public_key_create_from_data` and `dash_sdk_identity_create_from_components` each enumerate bytes 0–8; they agree today because both were updated for type 8. The signer API already delegates the same conversion to `KeyType::try_from(u8)`. Use that conversion in both constructors and retain their existing `InvalidParameter` response for unknown bytes.
In `packages/rs-dpp/src/state_transition/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/state_transition/mod.rs:1372-1383: The default decoder can miss a new key-registration transition without a compiler error
Impact: Default-feature clients could accept a future registration before its key type activates even if maintainers update the emergency-switch check for the new transition.
The new default-feature decoder gate can silently skip a future registration variant. Its `keys_in_creation` repeats the four registration cases already handled by `public_keys_in_creation` in `emergency_switches.rs`, but ends in `_ => None`. The emergency-switch accessor is exhaustive, so adding a variant forces an edit there without forcing one in the decoder; the decoder can then return early as though no keys were registered. Move the exhaustive slice accessor into the shared `StateTransition` implementation and call it from both paths. The activation helper already returns `None` for an empty slice.
- [SUGGESTION] packages/rs-dpp/src/state_transition/mod.rs:2449-2453: Direct SLH-DSA signing serializes the transition twice
Impact: Each successful `StateTransition::sign_by_private_key` call for SLH-DSA, including through wasm-dpp2, unnecessarily allocates and encodes the signing payload twice.
Direct signing now does an extra serialization without changing the signed bytes. `sign_by_private_key` already calls `self.signable_bytes()` before the key-type match, but the new SLH-DSA arm does not use those bytes: `sign_with_slh_dsa_sha2_128s_key_pair` calls it again on the unchanged transition. Pass the encoded bytes to the helper, and have the public-key-checked path encode once after the comparison succeeds. Both paths will still generate the key pair only once.
In `packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt`:
- [BLOCKING] packages/kotlin-sdk/sdk/src/main/kotlin/org/dashfoundation/dashsdk/identity/IdentityUpdates.kt:46-51: Android reports imported SLH-DSA keys as usable, then signs with ECDSA
(carried; thread: https://github.com/dashpay/platform/pull/6510#discussion_r4798532637)
In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:255-256: Swift validates SLH-DSA seed length against its own copy of the Rust rule
(carried; thread: https://github.com/dashpay/platform/pull/6510#discussion_r4798532660)
In `packages/wasm-sdk/src/document_create_cost.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/wasm-sdk/src/document_create_cost.rs:180: PV14 and PV15 document estimates quote a fee for an inactive SLH-DSA signing key
(carried; thread: https://github.com/dashpay/platform/pull/6510#discussion_r4798532722)
In `packages/wasm-dpp2/src/enums/keys/key_type.rs`:
- [SUGGESTION → DEFERRED by a maintainer; not blocking, do not fix in this PR] packages/wasm-dpp2/src/enums/keys/key_type.rs:49: WASM rejects valid SLH-DSA seeds that are not secp256k1 scalars
(carried; thread: https://github.com/dashpay/platform/pull/6510#discussion_r4798532709)
…code the signable bytes once - The decoder of a build without `validation` reads a transition's keys through `public_keys_in_creation`, the exhaustive accessor the emergency switches use, in place of a second list ending in a wildcard: a transition added later cannot be left out of the key type activation check unnoticed. - Signing with an SLH_DSA_SHA2_128S key encodes the signable bytes once, in `sign_by_private_key` and in `sign`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…t sign for `KeystoreSigner` signs a stored key through Rust's single key signer, which signs ECDSA whatever it is handed, and answered `canSignWith` from whether the entry decrypts. An entry under a key of another type (a scalar re-derived for a disabled key another client added, an imported seed) was reported signable and came back signed with the wrong scheme. Rust now answers which key types that signer signs for (`SingleKeySigner::signs_key_type`, exported as `dash_sdk_signer_from_private_key_supports_key_type` and bridged as `SignerNative.storedKeySignerSupportsKeyType`). `KeystoreSigner` asks it in `canSignWith` and before signing, before anything is decrypted, and keeps no list of key types of its own. ECDSA_SECP256K1 and ECDSA_HASH160 keys sign as before; the platform address route is untouched. Co-Authored-By: Claude Fable 5.2 <[email protected]>
thepastaclaw
left a comment
There was a problem hiding this comment.
Re-review — Final validation — Phase 1 + Phase 2
New on this head: This incremental head removes the duplicated decoder key-registration accessor by sharing the exhaustive transition accessor, and changes SLH-DSA signing to reuse already encoded signable bytes while retaining a single generated key pair. All completed CI checks succeeded; the Kotlin SDK build and tests were still in progress at the captured state.
🟡 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.
1 finding(s) not shown inline (the lines are not part of this PR's diff)
🟡 Suggestion: FFI identity constructors maintain separate lists of recognized DPP key types
Impact: FFI callers can receive inconsistent constructor results when a future DPP key type is added to one numeric mapping but not the other.
packages/rs-sdk-ffi/src/identity/keys.rs:222-238
The two identity constructors still independently map the incoming key-type byte: this function and identity/create_from_components.rs each enumerate values 0 through 8 and reject everything else. They agree with DPP today, but a future KeyType addition can compile without requiring either table to change, allowing one constructor to accept the type while the other rejects it. dash_sdk_signer_can_sign already delegates to DPP's KeyType::try_from; both constructors should use the same conversion and translate its error to their existing InvalidParameter response.
source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality); gpt-6.2-astra (phase2-reviewer: architecture-layering, ffi-engineer, platform-versioning, rust-quality, security-auditor)
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.2-astra (agent: phase2-reviewer, role: general); 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:
criticalbygpt-6.2-sol(effort low) — This is a large, intricate change that modifies consensus protocol versioning and activation, peer-facing state-transition decoding and validation, cryptographic signing and proof-of-possession verification, and identity key handling in files such as packages/rs-dpp/src/util/slh_dsa_sha2_128s.rs and packages/rs-dpp/src/identity/identity_public_key/key_type.rs. - Phase 1 reviewers:
muse-spark-1.3-contributor— general (completed, effort xhigh); agentphase1-reviewer,muse-spark-1.3-contributor— rust-quality (completed, effort xhigh); agentphase1-reviewer - Phase 1 model:
muse-spark-1.3-contributor— not quota-gated; passed overgemini-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; agentsol-verifier - Phase 2 reviewers:
gpt-6.2-astra— general (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— architecture-layering (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— ffi-engineer (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— platform-versioning (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— rust-quality (completed, effort high); agentphase2-reviewer,gpt-6.2-astra— security-auditor (completed, effort high); agentphase2-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-sdk-ffi/src/identity/keys.rs`:
- [SUGGESTION] packages/rs-sdk-ffi/src/identity/keys.rs:222-238: FFI identity constructors maintain separate lists of recognized DPP key types
Impact: FFI callers can receive inconsistent constructor results when a future DPP key type is added to one numeric mapping but not the other.
The two identity constructors still independently map the incoming key-type byte: this function and `identity/create_from_components.rs` each enumerate values 0 through 8 and reject everything else. They agree with DPP today, but a future `KeyType` addition can compile without requiring either table to change, allowing one constructor to accept the type while the other rejects it. `dash_sdk_signer_can_sign` already delegates to DPP's `KeyType::try_from`; both constructors should use the same conversion and translate its error to their existing `InvalidParameter` response.
`KeySizeValidator` answered the size of an SLH_DSA_SHA2_128S private key from a number kept in Swift. The arm now asks Rust (`dash_sdk_slh_dsa_sha2_128s_private_key_size`, dpp's `SEED_SIZE`), so the rule has one owner. The older arms of the table are unchanged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Basic explanation
An identity can now hold a second kind of post-quantum signing key:
SLH_DSA_SHA2_128S, key type 8, the SLH-DSA-SHA2-128s scheme of FIPS 205.The post-quantum signing key we have,
ML_DSA_65, rests on lattice problems. SLH-DSA rests on a hash function only (SHA-256 at this parameter set), so an identity whose master key is of this type does not depend on lattices staying hard. The price is the signature: 7,856 bytes, quick to check and slow to make. It is meant for master keys and other keys that sign seldom, not for a key that signs documents all day.ECDSA_SECP256K1ML_DSA_65SLH_DSA_SHA2_128SEverything else follows
ML_DSA_65: it signs forAUTHENTICATIONandTRANSFER, is refused forENCRYPTIONandDECRYPTION, belongs to one identity (unique), needs a proof of possession when it is added, and exists from protocol version 16.This PR is stacked on #6507 (ML-KEM identity keys) and its base branch is
feat/ml-kem-identity-keys. #6507 merges first. The key type and emergency switch are encoded by their position in their enums, so the order of the stack is what makes 8 and 12 the numbers on the wire.Before and after
Registering a key of type 8, in an identity create or update:
{ "id": 1, "type": 8, "purpose": 0, "securityLevel": 1, "readOnly": false, "data": "<32 byte public key>", "signature": "<7,856 byte proof of possession>" }StateTransitionNotActiveError(10603).InvalidStateTransitionSignatureError(20002), unpaid.BasicSLHDSAError(20020), unpaid.InvalidIdentityPublicKeyDataError(10511).ENCRYPTIONorDECRYPTIONIdentityPublicKeyTypeNotAllowedForPurposeError(10540).In Rust:
Issue being fixed or feature implemented
Widens post-quantum support on identities with a signing scheme that makes a different security assumption from
ML_DSA_65. No issue is linked. Wallet derivation of the key from a wallet seed is left out, as it was forML_DSA_65(#6394).What was done?
Scheme choices, the same ones
ML_DSA_65makesslh_sign/slh_verify), not the pre-hash one: the signature is over the signable bytes themselves.Library
slh-dsa, pinned=0.2.0, the same family asml-dsa. I read its source for this version instead of relying on memory.wasm32-unknown-unknown(checked withcargo check -p dpp --target wasm32-unknown-unknown), and the crate together with the seed expansion checks foraarch64-apple-ios,aarch64-apple-ios-sim,aarch64-linux-androidandx86_64-linux-androidwith the repository's toolchain. The full iOS and Android SDK builds were not run here.Private key
SLH-DSA-SHA2-128s) intoSK.seed || SK.prf || PK.seed. Nodes never see this step: they handle public keys and signatures only.How many fit in a state transition
max_state_transition_sizeis 20,480 bytes, which holds two signatures of this type and not three.SLH_DSA_SHA2_128Skey: the transition can add one more key of the type (this is how such a master key is rotated). Two is refused.StateTransitionMaxSizeExceededError(10602), unpaid, in check tx and in a block, with the asset lock left unspent on a create. So no new limit and no new number inSystemLimits: the tests above pin each of these cases instead.max_field_value_size(5,120) is a limit on document fields and is never applied to a key's signature or a transition's signature. The untrusted decoder reads a 7,856 byte signature at protocol version 16 (tested).STATE_TRANSITION_MAX_ENCODED_BYTES(100,000) is above the size limit.Verification cost
Measured on this machine (Apple M5 Ultra, release build, through the dpp functions the node calls, fastest of 400 rounds). The machine was busy with other builds while I measured, so medians were noisy; the fastest rounds repeated to within a few percent across runs.
ECDSA_SECP256K1ML_DSA_65SLH_DSA_SHA2_128S, with SHA-256 instructionsSLH_DSA_SHA2_128S, SHA-256 in softwareThe time does not depend on the size of the transition in any way that matters (65 to 73 µs from 200 to 12,000 bytes). Nearly all of a check is SHA-256, so it follows the processor: 4.7 times an ECDSA check with SHA-256 instructions, 18 times without. A validator may run without them, so the fee in
FEE_SIGNATURE_VERSION1is priced for that case:verify_signature_slh_dsa_sha2_128s: 300_000credits (ECDSA is 15,000,ML_DSA_65100,000, BLS 300,000). Priced for hardware SHA-256 alone it would be 75,000.Wallets: one signature takes about 75 ms on this processor and about 320 ms with software SHA-256. I did not measure a phone.
Emergency switch
KeyTypeSlhDsaSha2128s, id 12: a transition signed with a key of the type, or adding one, is refused while the switch is paused or off.Bindings
wasm-dpp,wasm-dpp2,wasm-sdk),rs-sdk-ffi, Swift and Kotlin know the key type. As forML_DSA_65, wallets neither derive nor sign with it yet:platform-walletrefuses to derive it, and Swift'sKeychainSignerand Kotlin'sKeystoreSignerrefuse to sign with it, since every path there signs ECDSA.Public interface changes
rs-dpp
KeyType::SLH_DSA_SHA2_128S = 8.KeyType::all_key_types()now returns[KeyType; 9]. Any exhaustivematchonKeyTypeoutside this repository needs a new arm.dpp::util::slh_dsa_sha2_128s: constantsPUBLIC_KEY_SIZE(32),SIGNATURE_SIZE(7856),SEED_SIZE(32),KEY_GENERATION_INFO; functionsseed_from_private_key,key_generation_input_from_seed(returns aZeroizing<[u8; 48]>, private key material that is wiped on drop),public_key_from_seed,sign,verify_data_signature;KeyPair(from_seed,public_key,sign) for a caller that needs the public key and a signature and should generate the pair once; error enumSlhDsaSha2128sError.KeyType::initial_protocol_version(): the protocol version a key type exists from (1, or 16 forML_DSA_65,ML_KEM_768,ML_KEM_1024andSLH_DSA_SHA2_128S). The active version range of a key registration reads it.StateTransition::deserialize_from_bytes_untrusted_in_versionand its_exacttwin, in a build of dpp without thevalidationfeature: a transition registering a key of one of those four types is now refused below protocol version 16 withStateTransitionIsNotActiveError, as the validating build refuses it. Before the key types existed their number did not decode at all; with them it decoded at every version in that build. A key set without such a key decodes as before.BasicSLHDSAError, code 20020, appended toSignatureError.EmergencySwitch::KeyTypeSlhDsaSha2128s = 12, JSON namekeyTypeSlhDsaSha2128s.KeyType::signature_verify_cost,public_key_data_from_private_key_data,random_public_key_data,random_public_and_private_key_data,IdentityPublicKey::public_key_hashandvalidate_private_key_bytes,StateTransition::sign/sign_by_private_key/verify_identity_signed_signature, andPlatformMessageSignablehandle the new type.dpp:slh-dsa =0.2.0andhkdf 0.12.4(the latter was already in the lockfile).zeroizeis no longer optional indpp(it was already in every build throughml-dsa).rs-sdk
Sdk::claim_invitation: a repeated claim whose first attempt landed recognizes its own identity through any key Platform admits with a proof of possession (KeyType::is_unique_key_type), so anSLH_DSA_SHA2_128SorML_DSA_65master counts. It used to count ECDSA and BLS keys only and reported such an identity as already claimed.rs-platform-version
SLH_DSA_SHA2_128S_KEY_INITIAL_PROTOCOL_VERSION(16).FeeSignatureVersiongains the public fieldverify_signature_slh_dsa_sha2_128s. Code that builds the struct with a literal needs the field.FeeSignatureVersionFieldsBeforeVersion4, the form old stored states are read with, is unchanged.wasm
wasm-dpp:KeyType.SLH_DSA_SHA2_128S = 8; theBasicSLHDSAErrorconsensus error is mapped.wasm-dpp2:KeyTypeLikegains"slh_dsa_sha2_128s"and8;EmergencySwitchNamegains"keyTypeSlhDsaSha2128s".wasm-sdk:DocumentCreateCostOptions.signatureKeyTypeaccepts'SLH_DSA_SHA2_128S'.FFI, Swift, Kotlin
rs-sdk-ffi: key type byte 8 is accepted bydash_sdk_identity_create_from_components,dash_sdk_identity_public_key_create_from_dataanddash_sdk_signer_can_sign. Two new exports:dash_sdk_signer_from_private_key_supports_key_type(key_type) -> bool(which key types a signer made from one private key signs for: the ECDSA ones) anddash_sdk_slh_dsa_sha2_128s_private_key_size() -> usize(dpp's seed size). No existing function, struct or callback layout changed.KeyType.slhDsaSha2128s = 8(name "SLH-DSA-SHA2-128s"). An exhaustiveswitchoverKeyTypein an app needs the case.KeychainSigner.refusesKeyTypeis true for it.KeySizeValidatorreads this key type's private key size from Rust.KeyType.SLH_DSA_SHA2_128S(8), with its name and label in the example app. New nativeSignerNative.storedKeySignerSupportsKeyType(keyType).KeystoreSigner, behaviour change for every key type that is not ECDSA:canSignWithis false and signing completes with an error for a stored key of type BLS12_381, BIP13_SCRIPT_HASH, EDDSA_25519_HASH160, ML_DSA_65, ML_KEM_768, ML_KEM_1024 or SLH_DSA_SHA2_128S, on Rust's answer and before the entry is decrypted. Such a key used to be reported signable and came back with an ECDSA signature Platform refuses. ECDSA_SECP256K1 and ECDSA_HASH160 keys and platform addresses behave as before.Other crates
simple-signer:SimpleSignersigns with the key type. NewSingleKeySigner::signs_key_type(KeyType) -> bool, which itssignandcan_sign_withnow go through (same answers as before).platform-walletreturnsInvalidIdentityDatawhen asked to derive one.In-place changes to shipped generations
Protocol version 16 has not shipped: there is no
v5.2release or prerelease tag, the latest stable release is v5.1.1, andLATEST_VERSIONonv5.1-devis 15. So its tables and the generations only it selects are edited in place, including the switch listEMERGENCY_SWITCHES_V0.The generations below are also selected by shipped protocol versions. Each gains an arm for the new key type and nothing else. The reason consensus cannot change there is the same for all of them: a key of the type cannot exist before protocol version 16, because a transition carrying one is not active there and is refused while it is decoded, and a transition is the only way a key reaches an identity.
validate_state_transition_identity_signedv0 (run by generations 1 and 2)validate_identity_public_keys_structurev1verify_identity_signed_signaturev0KeyType::signature_verify_cost0from_public_key_signed_externalv0FEE_SIGNATURE_VERSION1Two unversioned functions change the same way:
PlatformMessageSignable::verify_signature, andactive_version_range, which now answers 16 onwards for a transition carrying the key type. At protocol version 15 and earlier such bytes were refused unpaid as undecodable and are now refused unpaid as not active, as forML_DSA_65. Nothing is stored either way.Tests run the refusal at protocol version 15 for identity create and identity update, in check tx and in a block.
Decisions for Sam
slh-dsa0.2.0 was published on 2026-12-03, the day before this PR, and its README says it has never been independently audited. I checked that the published crate matches the signed tagslh-dsa/v0.2.0in RustCrypto/signatures. The previous stable release, 0.1.0, is from 2024 and sits on the olderdigest0.10 family, away fromml-dsa. The exact pin and the OpenSSL vectors are the guard.slh_keygen_internal, which is FIPS 205's function of that name and ispubbut hidden from its docs: the documented API only generates a key from a random source. The exact pin keeps it from moving.Left to #6394
Review findings that are real, concern every key type and predate this PR. They are written up on #6394:
KeySizeValidatorkeeps its own table of private key sizes for the older key types (no caller uses it).wasm-dpp2signing takes an ECDSAPrivateKey, so a seed that is not a valid secp256k1 scalar cannot be passed.How Has This Been Tested?
Run locally, on the merged stack:
cargo check --workspace --all-targets.identity::,state_transition::,voting::,util::,signinganderrors::consensus. New ones cover the helper module (round trip, determinism, wrong key, wrong message, wrong sizes, every part of the signature altered, arbitrary bytes, the OpenSSL vectors), the key hash, signing and verifying a transition, the active version range and decoding at protocol versions 15 and 16, key structure validation, the emergency switch, the fee entry, and the key type's byte in bincode (both decoders), JSON andTryFrom<u8>.ML_DSA_65and ML-KEM, and the emergency switch tests (69 tests before the last merge of the base branch, the 35 key type tests again after it). For this key type: adding a key with its proof of possession and finding the identity by the key's hash, an update signed by a master key of the type, a bad signature, a bad proof of possession, wrong data size, wrong purpose, refusal at protocol version 15, and each of the size cases listed above.validation, from a crate outside the workspace on dpp's default features: an identity update adding a key of each post-quantum type is refused at 1, 14 and 15 and decodes at 16; one adding an ECDSA key decodes at 1, 13, 15 and 16.cargo clippy --all-targets --all-features --locked -- --no-deps -D warningson dpp, platform-version, drive-abci, simple-signer, platform-wallet, rs-sdk-ffi, wasm-dpp, wasm-dpp2 and wasm-sdk, andcargo fmt --all.Not run locally, left to CI:
swiftc -parseand read for exhaustive switches.KeystoreSignerInstrumentedTest,FfiSmokeTest; the emulator job runs them) and the wasm-dpp2 mocha spec.v5.2-dev.Breaking Changes
Consensus: from protocol version 16 a new key type, a new consensus error code (20020), a new fee table entry and a new emergency switch (12). Protocol version 15 and earlier validate nothing differently.
API: see "Public interface changes". The ones that can break a build are the new
KeyTypevariant in Rust, Swift and Kotlin for code that matches exhaustively, the new field ofFeeSignatureVersion, and the array length ofKeyType::all_key_types().Checklist:
structure.rs, regeneratedgrovedb-structure.json, and checked the structure viewer link posted on this pull requestFor repository code-owners and collaborators only
🤖 Generated with Claude Code