Skip to content

feat(platform)!: add SLH-DSA-SHA2-128s identity keys (PV16) - #6510

Open
QuantumExplorer wants to merge 7 commits into
feat/ml-kem-identity-keysfrom
feat/slh-dsa-identity-keys
Open

QuantumExplorer wants to merge 7 commits into
feat/ml-kem-identity-keysfrom
feat/slh-dsa-identity-keys

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

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_SECP256K1 ML_DSA_65 SLH_DSA_SHA2_128S
Key type 0 5 8
Public key (key data) 33 bytes 1,952 bytes 32 bytes
Signature 65 bytes 3,309 bytes 7,856 bytes
Private key 32 bytes 32 byte seed 32 byte seed

Everything else follows ML_DSA_65: it signs for AUTHENTICATION and TRANSFER, is refused for ENCRYPTION and DECRYPTION, 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>" }
Before After
Protocol version 16 The transition does not decode: 8 is no key type. The key is added. Checking each signature costs 300,000 credits.
Protocol version 15 and earlier The transition does not decode. Refused without a fee: StateTransitionNotActiveError (10603).
Signing a transition with such a key Not possible. Verified against the 32 byte key; a bad signature is InvalidStateTransitionSignatureError (20002), unpaid.
Proof of possession that does not verify n/a BasicSLHDSAError (20020), unpaid.
Key data that is not 32 bytes n/a InvalidIdentityPublicKeyDataError (10511).
Registered for ENCRYPTION or DECRYPTION n/a IdentityPublicKeyTypeNotAllowedForPurposeError (10540).

In Rust:

use dpp::util::slh_dsa_sha2_128s;

let seed = [7u8; 32];                                               // the private key
let public_key = slh_dsa_sha2_128s::public_key_from_seed(&seed);    // 32 bytes
let signature = slh_dsa_sha2_128s::sign(b"message", &seed)?;        // 7,856 bytes
slh_dsa_sha2_128s::verify_data_signature(b"message", &signature, &public_key)?;

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 for ML_DSA_65 (#6394).

What was done?

Scheme choices, the same ones ML_DSA_65 makes

  • The pure scheme (slh_sign / slh_verify), not the pre-hash one: the signature is over the signable bytes themselves.
  • The empty context string. No extra domain separation.
  • Signing is the deterministic variant, so a private key and a message always give the same signature and signing needs no random source. This is a wallet-side choice only: verification accepts a signature made either way.

Library

  • RustCrypto slh-dsa, pinned =0.2.0, the same family as ml-dsa. I read its source for this version instead of relying on memory.
  • It builds for wasm32-unknown-unknown (checked with cargo check -p dpp --target wasm32-unknown-unknown), and the crate together with the seed expansion checks for aarch64-apple-ios, aarch64-apple-ios-sim, aarch64-linux-android and x86_64-linux-android with the repository's toolchain. The full iOS and Android SDK builds were not run here.
  • Key generation, the public key and the deterministic signature of a seed are pinned in tests to what OpenSSL 4.1.0 gives for the same input, so a release of the crate that signed or verified differently cannot slip in.
  • Verification reads any 32 bytes as a key and any 7,856 bytes as a signature and answers with an error, never a panic. A test feeds it arbitrary and degenerate bytes.

Private key

  • A 32 byte seed, like every other key type. FIPS 205 generates a key pair from three 16 byte values and names no shorter form, so the seed is expanded with HKDF-SHA256 (no salt, info SLH-DSA-SHA2-128s) into SK.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_size is 20,480 bytes, which holds two signatures of this type and not three.
    • Signed by an SLH_DSA_SHA2_128S key: the transition can add one more key of the type (this is how such a master key is rotated). Two is refused.
    • Signed by an ECDSA key: it can add two. Three is refused.
    • Identity create: two keys of the type. Three is refused.
  • A transition past the limit already gets a proper consensus error, 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 in SystemLimits: 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.

Verify Sign Key pair from seed
ECDSA_SECP256K1 14 µs 44 µs
ML_DSA_65 94 µs 0.2 to 0.5 ms
SLH_DSA_SHA2_128S, with SHA-256 instructions 66 µs 75 ms 8.6 ms
SLH_DSA_SHA2_128S, SHA-256 in software 255 µs 320 ms not measured

The 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_VERSION1 is priced for that case: verify_signature_slh_dsa_sha2_128s: 300_000 credits (ECDSA is 15,000, ML_DSA_65 100,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 (wasm-dpp, wasm-dpp2, wasm-sdk), rs-sdk-ffi, Swift and Kotlin know the key type. As for ML_DSA_65, wallets neither derive nor sign with it yet: platform-wallet refuses to derive it, and Swift's KeychainSigner and Kotlin's KeystoreSigner refuse 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 exhaustive match on KeyType outside this repository needs a new arm.
  • New module dpp::util::slh_dsa_sha2_128s: constants PUBLIC_KEY_SIZE (32), SIGNATURE_SIZE (7856), SEED_SIZE (32), KEY_GENERATION_INFO; functions seed_from_private_key, key_generation_input_from_seed (returns a Zeroizing<[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 enum SlhDsaSha2128sError.
  • KeyType::initial_protocol_version(): the protocol version a key type exists from (1, or 16 for ML_DSA_65, ML_KEM_768, ML_KEM_1024 and SLH_DSA_SHA2_128S). The active version range of a key registration reads it.
  • StateTransition::deserialize_from_bytes_untrusted_in_version and its _exact twin, in a build of dpp without the validation feature: a transition registering a key of one of those four types is now refused below protocol version 16 with StateTransitionIsNotActiveError, 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.
  • New consensus error BasicSLHDSAError, code 20020, appended to SignatureError.
  • EmergencySwitch::KeyTypeSlhDsaSha2128s = 12, JSON name keyTypeSlhDsaSha2128s.
  • KeyType::signature_verify_cost, public_key_data_from_private_key_data, random_public_key_data, random_public_and_private_key_data, IdentityPublicKey::public_key_hash and validate_private_key_bytes, StateTransition::sign / sign_by_private_key / verify_identity_signed_signature, and PlatformMessageSignable handle the new type.
  • New dependencies of dpp: slh-dsa =0.2.0 and hkdf 0.12.4 (the latter was already in the lockfile). zeroize is no longer optional in dpp (it was already in every build through ml-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 an SLH_DSA_SHA2_128S or ML_DSA_65 master 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).
  • FeeSignatureVersion gains the public field verify_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; the BasicSLHDSAError consensus error is mapped.
  • wasm-dpp2: KeyTypeLike gains "slh_dsa_sha2_128s" and 8; EmergencySwitchName gains "keyTypeSlhDsaSha2128s".
  • wasm-sdk: DocumentCreateCostOptions.signatureKeyType accepts 'SLH_DSA_SHA2_128S'.

FFI, Swift, Kotlin

  • rs-sdk-ffi: key type byte 8 is accepted by dash_sdk_identity_create_from_components, dash_sdk_identity_public_key_create_from_data and dash_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) and dash_sdk_slh_dsa_sha2_128s_private_key_size() -> usize (dpp's seed size). No existing function, struct or callback layout changed.
  • Swift: KeyType.slhDsaSha2128s = 8 (name "SLH-DSA-SHA2-128s"). An exhaustive switch over KeyType in an app needs the case. KeychainSigner.refusesKeyType is true for it. KeySizeValidator reads this key type's private key size from Rust.
  • Kotlin: KeyType.SLH_DSA_SHA2_128S(8), with its name and label in the example app. New native SignerNative.storedKeySignerSupportsKeyType(keyType).
  • Kotlin KeystoreSigner, behaviour change for every key type that is not ECDSA: canSignWith is 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: SimpleSigner signs with the key type. New SingleKeySigner::signs_key_type(KeyType) -> bool, which its sign and can_sign_with now go through (same answers as before).
  • platform-wallet returns InvalidIdentityData when asked to derive one.

In-place changes to shipped generations

Protocol version 16 has not shipped: there is no v5.2 release or prerelease tag, the latest stable release is v5.1.1, and LATEST_VERSION on v5.1-dev is 15. So its tables and the generations only it selects are edited in place, including the switch list EMERGENCY_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.

Edited Selected by Change
validate_state_transition_identity_signed v0 (run by generations 1 and 2) every protocol version the set of key types that sign gains the type
validate_identity_public_keys_structure v1 14, 15, 16 the purpose rule and the 32 byte data rule for the type
verify_identity_signed_signature v0 every protocol version verifies a signature of the type
KeyType::signature_verify_cost 0 every protocol version reads the new fee entry
from_public_key_signed_external v0 every protocol version signs the proof of possession (client side)
FEE_SIGNATURE_VERSION1 every fee schedule the new entry, unread before 16

Two unversioned functions change the same way: PlatformMessageSignable::verify_signature, and active_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 for ML_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

  1. The fee: 300,000 credits per signature check, priced for a validator without SHA-256 instructions. 75,000 if we price for hardware SHA-256 only.
  2. The private key form: a 32 byte seed expanded with HKDF-SHA256 as described above. It is not consensus-visible, but every wallet has to agree on it for good. The alternative is to make the 48 byte key generation input the private key (what OpenSSL calls the seed), which means a private key that is not 32 bytes across dpp, the signers and the FFI.
  3. The crate's age: slh-dsa 0.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 tag slh-dsa/v0.2.0 in RustCrypto/signatures. The previous stable release, 0.1.0, is from 2024 and sits on the older digest 0.10 family, away from ml-dsa. The exact pin and the OpenSSL vectors are the guard.
  4. Key generation from a seed goes through the crate's slh_keygen_internal, which is FIPS 205's function of that name and is pub but hidden from its docs: the documented API only generates a key from a random source. The exact pin keeps it from moving.
  5. No new size limit, per the sizes section. If a dedicated early error is wanted for "more signatures of this type than fit", that is a new rule and a new consensus error.

Left to #6394

Review findings that are real, concern every key type and predate this PR. They are written up on #6394:

  • A disabled key the wallet did not derive is given the wallet's slot, and Android stores that slot's ECDSA scalar under it without comparing public keys. This PR makes the Android signer refuse such an entry when the key is not an ECDSA key; an ECDSA key another client added still gets the wrong scalar.
  • Swift's KeySizeValidator keeps its own table of private key sizes for the older key types (no caller uses it).
  • wasm-dpp2 signing takes an ECDSA PrivateKey, 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.
  • dpp: 1,998 tests under identity::, state_transition::, voting::, util::, signing and errors::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 and TryFrom<u8>.
  • drive-abci: the identity create and identity update tests for this key type, ML_DSA_65 and 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.
  • platform-version fee tests, simple-signer, the rs-sdk-ffi signer and crypto tests (the two new exports included), the wasm-dpp2 lib tests, the rs-sdk invitation tests.
  • The decoder of a build without 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 warnings on dpp, platform-version, drive-abci, simple-signer, platform-wallet, rs-sdk-ffi, wasm-dpp, wasm-dpp2 and wasm-sdk, and cargo fmt --all.

Not run locally, left to CI:

  • The Swift tests: they need the built xcframework. The Swift changes were only parsed with swiftc -parse and read for exhaustive switches.
  • The Kotlin unit test, the two instrumented Kotlin tests added for the signer (KeystoreSignerInstrumentedTest, FfiSmokeTest; the emulator job runs them) and the wasm-dpp2 mocha spec.
  • Note: while this PR is based on feat(platform)!: add ML-KEM-768 and ML-KEM-1024 identity keys (PV16) #6507's branch, CI runs the Kotlin job only. The Rust workspace tests, the Swift build and the wasm tests run once the base is v5.2-dev.
  • The full suites.

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 KeyType variant in Rust, Swift and Kotlin for code that matches exhaustively, the new field of FeeSignatureVersion, and the array length of KeyType::all_key_types().

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 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

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

QuantumExplorer and others added 2 commits December 4, 2026 16:50
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]>
@QuantumExplorer QuantumExplorer added this to the v5.2.0 milestone Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

📖 Book Preview built successfully.

Download the preview from the workflow artifacts.
To view locally: download the artifact, unzip, and open index.html.

Updated at 2026-12-04T11:18:08.932Z

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@thepastaclaw

thepastaclaw commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

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

@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

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 get AlreadyClaimed instead 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 of KeySizeValidator.isValidSize get 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: critical by gpt-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); 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/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::sign formats self into its missing-key error, and the existing Debug implementation prints private-key values in Base64. Logging that error can disclose loaded keys. Both behaviors predate this PR; the signer is also used by the register_identity tool.
    • 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.

- 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]>

@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

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 of KeySizeValidator.isValidSize get 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: critical by gpt-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); 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-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)

QuantumExplorer and others added 2 commits December 4, 2026 18:17
…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 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

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: critical by gpt-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); 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-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]>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants