Skip to content

feat(platform)!: add hashed ML-DSA-65 identity keys (PV16) - #6504

Open
QuantumExplorer wants to merge 9 commits into
feat/slh-dsa-identity-keysfrom
feat/ml-dsa-65-hash-identity-keys
Open

QuantumExplorer wants to merge 9 commits into
feat/slh-dsa-identity-keysfrom
feat/ml-dsa-65-hash-identity-keys

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

Stacked on #6510 (SLH-DSA-SHA2-128s keys), which is stacked on #6507 (ML-KEM keys). This pull request is the top of the three and shows only its own commit.

What this does: Identities can register a second form of the post-quantum ML_DSA_65 key, ML_DSA_65_HASH256 (key type 9), from protocol version 16. The identity stores only the 32 byte SHA-256 of the ML-DSA-65 public key instead of the 1,952 byte key. When the key signs a state transition, the transition carries the public key in front of the signature, and Platform checks the key against the stored hash before it verifies the signature.

Value: A key that seldom signs costs 32 bytes on the identity instead of 1,952, as ECDSA_HASH160 does for an ECDSA key. It is also the form masternode owner and voting keys could map to later; that mapping is not part of this pull request.

Risks: Low to medium. No new scheme: the signature is ML-DSA-65, verified with the library ML_DSA_65 already uses in protocol version 16, after one SHA-256 and under a context string of its own. A transition signed this way is 1,952 bytes larger than one signed with the full key. The key type has its own emergency switch. Nothing changes for protocol versions up to 15, where a transition carrying the key type is refused as before. Seven choices in this pull request are consensus-visible and are listed under "Decisions to confirm".

Issue being fixed or feature implemented

#6354 added ML_DSA_65 identity keys, which store the whole 1,952 byte public key. The classical key types already have hashed forms (ECDSA_HASH160, EDDSA_25519_HASH160, BIP13_SCRIPT_HASH) for keys that are stored cheaply and shown only when used. The post-quantum key type had none.

What was done?

The key type

  • KeyType::ML_DSA_65_HASH256 = 9 in packages/rs-dpp/src/identity/identity_public_key/key_type.rs, after the key types 6 to 8 of the two pull requests below this one. It is the tenth variant, so its position and its number agree, which is what the derived bincode encoding writes.
  • The key data is 32 bytes: SHA256(public key), the encoded 1,952 byte ML-DSA-65 public key hashed once.
  • The private key is the same 32 byte seed an ML_DSA_65 key has.
  • 32 bytes, not HASH160. A 20 byte hash leaves about 80 bits against a collision, and a new key type should not start with that.
  • No domain tag. What the 32 bytes are a hash of is settled by where they are stored (the data of a key of type 9), and a signature only verifies against them with a 1,952 byte preimage that is also the key the signature was made with. There is no second reading of the bytes for a tag to rule out, the preimage has one fixed length, and ML-DSA already binds every signature to its public key. Left plain, the hash is what openssl dgst -sha256 gives for the raw key, so a wallet, a hardware signer or Dash Core can compute it without a Platform constant. The value is pinned in a test against OpenSSL 4.1.0.

Signing and verification

  • An ML-DSA public key cannot be recovered from a signature the way an ECDSA key can. The signature field of a transition signed with this key type is therefore the public key followed by the signature: 1,952 + 3,309 = 5,261 bytes.
  • Verification (StateTransition::verify_identity_signed_signature, through ml_dsa_65::verify_data_signature_with_public_key):
    1. the field must be exactly 5,261 bytes,
    2. the SHA-256 of its first 1,952 bytes must equal the stored hash,
    3. the remaining 3,309 bytes must verify as that key's ML-DSA-65 signature over the signable bytes, under the context string ML_DSA_65_HASH256.
  • The ML-DSA code is reused, not copied: the new functions in packages/rs-dpp/src/util/ml_dsa_65.rs share the decoding of the key and the signature with the existing verifier.
  • A context string of its own. An ML_DSA_65 key signs under the empty context string of FIPS 204; an ML_DSA_65_HASH256 key signs under the bytes of ML_DSA_65_HASH256. One identity can hold the same key pair in both forms, each with its own security level, budget and expiry, and no transition signs the id of the key that signed it. Without the context, the full key's signature with the public key put in front would verify as the hashed key's, and the hashed key's signature with the public key taken off would verify as the full key's, so anyone relaying a transition could move it to the other key. With it, a signature verifies for the form it was made for and no other. The value is pinned against OpenSSL 4.1.0 (-pkeyopt context-string:ML_DSA_65_HASH256).
  • Any other size (the signature without the key, the key without a signature, one byte less or more, 14,000 bytes), a key with another hash, a spliced or altered signature, the full key's signature behind the key and a signature that is not canonically encoded are all InvalidStateTransitionSignatureError (20002), refused by check_tx and unpaid in a block. No path panics.
  • Like ECDSA_HASH160, the type is in drive-abci's list of key types that sign transitions. EDDSA_25519_HASH160 and BIP13_SCRIPT_HASH stay out of it and sign nothing, as before.

Uniqueness and proof of possession

  • Follows the existing hashed types: not unique to an identity, and no proof of possession. A key of the type that carries a signature when it is added is refused with SignatureShouldNotBePresentError (20008), as for ECDSA_HASH160. A proof of possession would put the public key on the chain at registration, which is what the hash is there to avoid.
  • The 20 byte hash a key is found by is RIPEMD160(SHA256(data)), the rule of every key type whose data is not already 20 bytes. This is not the hash the ML_DSA_65 key of the same key pair is found by (RIPEMD160(SHA256(public key))), so the full key in the unique table and its hash in the non-unique table never share an entry, and neither registration can keep the other out. A test registers both forms of one key pair on two identities, in both orders.

Activation

  • ML_DSA_65_HASH256_KEY_INITIAL_PROTOCOL_VERSION = 16.
  • Protocol version 16 has not shipped: v5.1.1 is the latest release and its latest protocol version is 15, and 16 exists only on v5.2-dev. So its tables and the generations only it selects are edited in place; no new protocol number and no new vN.
  • active_version_range_for_keys_in_creation makes a transition that registers such a key inactive before 16: refused while decoding, unpaid, for IdentityCreate, IdentityUpdate, IdentityCreateFromAddresses and IdentityCreateFromShieldedPool.

Validation

  • Key data that is not 32 bytes: InvalidIdentityPublicKeyDataError (10511).
  • Registered for ENCRYPTION or DECRYPTION: IdentityPublicKeyTypeNotAllowedForPurposeError (10540), the rule ML_DSA_65 has. The hash of a signing key serves the purposes the key serves.
  • The rule feat(platform)!: add ML-KEM-768 and ML-KEM-1024 identity keys (PV16) #6507 added, that no two keys of non-unique types in one transition may have the same lookup hash, covers the type without a change: a 20 byte hash key carrying RIPEMD160(SHA256(data)) of an ML_DSA_65_HASH256 key of the same set is DuplicatedIdentityPublicKeyBasicError. The full ML_DSA_65 key and its hash in one set are two entries and are accepted.
  • Allowed for AUTHENTICATION at every security level, master included, and for TRANSFER.
  • No new consensus error and no new error code.

Sizes and limits

  • max_state_transition_size (20,480) is the only limit a 5,261 byte signature field meets, and it bounds the whole transition. max_field_value_size (5,120) is read only for document field values and never for a signature field. The untrusted decoder's budget is 100,000 bytes.
  • No new number was needed in SystemLimits: 5,261 is the sum of two sizes of the scheme, ml_dsa_65::PUBLIC_KEY_SIZE + ml_dsa_65::SIGNATURE_SIZE.
  • Consequence: an identity update signed with an ML_DSA_65_HASH256 key has room to add two ML_DSA_65 keys (5,261 bytes each with their proof of possession), where one signed with an ML_DSA_65 key has room for three.

Fee

  • New entry verify_signature_ml_dsa_65_hash256 in the signature fee table (FEE_SIGNATURE_VERSION1, which every FEE_VERSION* schedule names, as verify_signature_ml_dsa_65 is): 105,000 credits per check, against 100,000 for ML_DSA_65.
  • Basis: the check is one SHA-256 over 1,952 bytes plus the ML_DSA_65 check. Measured on one machine with the pinned ml-dsa 0.1.2, the hash takes 4.4 microseconds and the verification 125, so the hash adds about 3.5%, rounded up.
  • Adding a key of the type is charged no signature check. The key is added without a signature, so nothing is hashed and nothing is verified. The proof of possession of an added key is now metered as its own operation (SignatureVerificationOperation::for_proof_of_possession, priced by KeyType::proof_of_possession_verify_cost): 0 for ML_DSA_65_HASH256, and for every other key type exactly what it was charged before, the cost of one signature check of the type.
  • Unread before protocol version 16, where no key of the type exists.

Emergency switch

  • EmergencySwitch::KeyTypeMlDsa65Hash256, id 13, in the switches of protocol version 16: the next free id after the three switches (10 to 12) of the two pull requests below this one.
  • While it is paused or off, a transition signed with an ML_DSA_65_HASH256 key, and one adding such a key, is refused without a fee, through the same code as the other key type switches. It is separate from KeyTypeMlDsa65: each gates only its own key type.

Clients

  • simple-signer signs with the key type (public key in front of the signature).
  • rs-sdk-ffi, wasm-dpp, wasm-dpp2 and wasm-sdk accept the value 9 and the name ML_DSA_65_HASH256.
  • Swift SDK: KeyType gains mlDsa65Hash256 (9). KeychainSigner refuses to sign with one, as it refuses mlDsa65: every path there signs ECDSA secp256k1.
  • Kotlin SDK: KeyType gains ML_DSA_65_HASH256(9), and the example app names it "ML-DSA-65 Hash256". KeystoreSigner refuses a stored key of the type through the rule feat(platform)!: add SLH-DSA-SHA2-128s identity keys (PV16) #6510 added (SingleKeySigner::signs_key_type, where this pull request places the type as not signable).
  • rs-platform-wallet returns an error when asked to derive such a key, as for ML_DSA_65, and stores a key of the type an update added without a derivation breadcrumb, as it does an SLH_DSA_SHA2_128S or an ML-KEM key: the key can only have come from outside the wallet.

Before and after

An identity update adding the key:

IdentityPublicKeyInCreationV0 {
    id: 1,
    key_type: KeyType::ML_DSA_65_HASH256,
    purpose: Purpose::AUTHENTICATION,
    security_level: SecurityLevel::HIGH,
    data: /* 32 bytes: SHA256 of the 1,952 byte public key */,
    signature: /* empty: no proof of possession */,
    ..
}
Protocol version 15 and earlier Protocol version 16
check_tx StateTransitionNotActiveError (10603) accepted
in a block refused unpaid, identity untouched key added, 32 bytes stored
the same key with a proof of possession StateTransitionNotActiveError (10603) SignatureShouldNotBePresentError (20008), unpaid
for ENCRYPTION or DECRYPTION StateTransitionNotActiveError (10603) IdentityPublicKeyTypeNotAllowedForPurposeError (10540), unpaid

The same key pair registered in each form, and a transition signed with it:

ML_DSA_65 (type 5) ML_DSA_65_HASH256 (type 9)
stored on the identity 1,952 bytes 32 bytes
proof of possession when added 3,309 bytes, required none, refused if present
unique to one identity yes no
signature field of a signed transition 3,309 bytes 5,261 bytes: the key, then a 3,309 byte signature
context string of the signature empty ML_DSA_65_HASH256
a signature made for the other form refused (20002) refused (20002)
fee for the signature check 100,000 credits 105,000 credits
fee for the proof of possession when added 100,000 credits none: there is nothing to check
emergency switch KeyTypeMlDsa65 (9) KeyTypeMlDsa65Hash256 (13)

In-place changes to shipped generations

Every edit below adds an arm for a key type that no identity can hold before protocol version 16: a transition registering one is not active there and is refused while it is decoded, and a transition is the only way a key reaches an identity. So no shipped protocol version reaches the new code. This is the argument #6354 made for ML_DSA_65, in the same places.

Generation Selected by Edit
validate_state_transition_identity_signed 0 (run by generations 1 and 2), SUPPORTED_KEY_TYPES every protocol version the key type signs
verify_identity_signed_signature 0 (run by 1) every protocol version arm that verifies the key and the signature
validate_identity_public_keys_structure 1 14 to 16 data size 32, and the purpose rule
KeyType::signature_verify_cost 0 every protocol version reads the new fee entry
FEE_SIGNATURE_VERSION1 every fee schedule new entry, unread before 16
from_public_key_signed_external 0 and from_public_key_signed_with_private_key 0 every protocol version client side only, no consensus: both attach a proof of possession to a key of a unique type and to no other. The external one gives the same output as before; the private-key one no longer signs for a hash key or an ML-KEM key
identity update added_key_proofs_of_possession 0 and advanced_structure 0, identity create identity_and_signatures 0, identity create from addresses public_key_signatures 0, identity create from shielded pool transform_into_action 0 every protocol version that has the transition the operation recorded for an added key is for_proof_of_possession, which costs the same as before for every key type that can exist before 16

Not in this pull request

  • Wallet derivation and signing, tracked in Wallet and mobile support for ML_DSA_65 identity keys #6394 with ML_DSA_65: there is no agreed derivation path for the seed, and the wallet's signers sign ECDSA only.
  • Masternode owner and voting keys mapped to this type.
  • Example apps: no screen creates or adds such a key.

Decisions to confirm

These are consensus-visible and were not settled before the work. Protocol version 16 is unreleased, so each can still change in place.

  1. The name ML_DSA_65_HASH256.
  2. The fee, 105,000 credits per signature check.
  3. No domain tag on the hash (reasons above).
  4. The lookup hash RIPEMD160(SHA256(data)), which keeps the two forms of one key pair apart in the key hash tables. The alternative, RIPEMD160(data), would equal the hash of the full key, the way an ECDSA_HASH160 key shares the hash of its ECDSA_SECP256K1 key.
  5. The purpose rule: refused for ENCRYPTION and DECRYPTION, as ML_DSA_65 is. The classical hashed types have no such rule.
  6. The context string ML_DSA_65_HASH256 on signatures of the type (added after review). The alternative is to refuse one identity holding both forms of a key pair, which needs state reads on every key registration.
  7. No charge for the proof of possession of an added key of the type (added after review). The classical hash key types keep paying the cost of one signature check when added, as they do today.

Public interface changes

platform-version

  • Added feature_initial_protocol_versions::ML_DSA_65_HASH256_KEY_INITIAL_PROTOCOL_VERSION.
  • FeeSignatureVersion gains a field, so a struct literal of it no longer compiles without it:
    pub verify_signature_ml_dsa_65_hash256: u64,
    FeeSignatureVersionFieldsBeforeVersion4 is unchanged, so the bytes of platform states saved before 1.4 read as before.

dpp

  • KeyType gains ML_DSA_65_HASH256 = 9. An exhaustive match on KeyType outside the workspace needs an arm for it. KeyType::try_from(9u8) now succeeds.
  • KeyType::all_key_types() changes its return type:
    // before (on #6510)
    pub fn all_key_types() -> [KeyType; 9]
    // after
    pub fn all_key_types() -> [KeyType; 10]
  • dpp::util::ml_dsa_65 gains:
    pub const PUBLIC_KEY_HASH_SIZE: usize = 32;
    pub const SIGNATURE_WITH_PUBLIC_KEY_SIZE: usize = PUBLIC_KEY_SIZE + SIGNATURE_SIZE; // 5261
    pub const PUBLIC_KEY_HASH_SIGNING_CONTEXT: &[u8] = b"ML_DSA_65_HASH256";
    pub fn public_key_hash(public_key: &[u8]) -> Result<[u8; PUBLIC_KEY_HASH_SIZE], MlDsa65Error>
    pub fn public_key_hash_from_seed(seed: &[u8; SEED_SIZE]) -> [u8; PUBLIC_KEY_HASH_SIZE]
    pub fn sign_with_public_key(data: &[u8], seed: &[u8; SEED_SIZE]) -> Result<Vec<u8>, MlDsa65Error>
    pub fn verify_data_signature_with_public_key(
        data: &[u8],
        signature_with_public_key: &[u8],
        expected_public_key_hash: &[u8],
    ) -> Result<(), MlDsa65Error>
    public_key_hash refuses bytes that are not the 1,952 of an encoded public key (InvalidPublicKeySize), so a key still in a DER wrapper or a truncated one does not yield a hash that registers and can never sign.
  • MlDsa65Error gains InvalidPublicKeyHashSize(usize), InvalidSignatureWithPublicKeySize(usize) and PublicKeyHashMismatch. An exhaustive match on it needs arms for them.
  • KeyType gains proof_of_possession_verify_cost(&self, platform_version). Its initial_protocol_version() answers 16 and its private_key_size() 32 for the new type.
  • Behaviour, IdentityPublicKeyInCreation::from_public_key_signed_with_private_key: it attaches a proof of possession only to a key of a unique type, as from_public_key_signed_external does. Before, it signed for every key type: an ECDSA_HASH160 key came back with a signature Platform refuses, and a BIP13_SCRIPT_HASH, EDDSA_25519_HASH160 or ML-KEM key gave an error. All of those now come back without a signature, which is what Platform admits.
  • EmergencySwitch gains KeyTypeMlDsa65Hash256 = 13, appended last; its name as JSON and as a plain object is "keyTypeMlDsa65Hash256". EmergencySwitch::existing returns fourteen switches at protocol version 16, so the queries that list the switches and their statuses return one more entry.
  • Behaviour: StateTransition::sign, sign_by_private_key, PlatformMessageSignable::sign_by_private_key and verify_signature, KeyType::public_key_data_from_private_key_data, IdentityPublicKey::validate_private_key_bytes and public_key_hash handle the new type. A signature made for it is 5,261 bytes. A private key that is not 32 bytes gives ProtocolError::PrivateKeySizeError.

wasm-dpp, wasm-dpp2, wasm-sdk

  • KeyType.ML_DSA_65_HASH256 (9) in both binding crates. KeyTypeLike in wasm-dpp2 also accepts "ml_dsa_65_hash256" and 9.
  • EmergencySwitchName in wasm-dpp2 gains "keyTypeMlDsa65Hash256".
  • DocumentCreateCostOptions.signatureKeyType accepts 'ML_DSA_65_HASH256'.

rs-sdk-ffi

  • dash_sdk_identity_create_from_components and dash_sdk_identity_public_key_create_from_data accept key type 9, through dpp's conversion of the key type byte (feat(platform)!: add SLH-DSA-SHA2-128s identity keys (PV16) #6510). No signature or struct layout changes.
  • dash_sdk_key_type_private_key_size(9) is 32 and dash_sdk_signer_from_private_key_supports_key_type(9) is false. Both exports come from the layers below; this pull request adds the key type to the dpp and simple-signer rules they read.
  • The emergency switch functions take and return switch names as strings, so "keyTypeMlDsa65Hash256" is accepted with no change to them.

drive-abci

  • SignatureVerificationOperation gains for_proof_of_possession(key_type) and a private field that tells the two apart, so two operations of one key type compare equal only when they are the same kind.

rs-sdk

  • No change. For the record: invitation recovery (identity_carries_keys) recognises an identity as the claimant's own only through a key of a unique type. ML_DSA_65_HASH256 is not unique and proves no possession, so a key set made only of such keys never matches, as with the other hash key types.

simple-signer

  • SimpleSigner::sign signs for the new key type. sign_create_witness refuses it, as it refuses ML_DSA_65.
  • SingleKeySigner::signs_key_type(KeyType::ML_DSA_65_HASH256) is false: that signer signs ECDSA only.

Swift SDK

  • KeyType gains case mlDsa65Hash256 = 9 (name "ML-DSA-65 Hash256"). An exhaustive switch on KeyType in an app needs an arm for it. KeyType(rawValue: 9) now succeeds, so the readers that dropped or refused a type 9 key now return it.
  • Behaviour, KeychainSigner: it reports that it cannot sign with an ML_DSA_65_HASH256 key and fails a sign request for one with unsupportedKeyType, whether the caller passes key type 9 or the stored row says so.
  • KeySizeValidator.expectedPrivateKeySize(for: .mlDsa65Hash256) is 32, read from Rust (dash_sdk_key_type_private_key_size). KeyValidation.validatePrivateKeyForPublicKey passes key type 9 to Rust.
  • No stored schema changes.

Kotlin SDK

  • KeyType gains ML_DSA_65_HASH256(9). An exhaustive when on KeyType in an app needs a branch for it. A key of type 9 read from a state transition now maps to it instead of to no key type.

How Has This Been Tested?

Run locally on macOS (aarch64), on top of feat/slh-dsa-identity-keys at b655ea6d4d. While this pull request is stacked on a feature branch, CI runs neither the Rust suites nor the Swift build on it, so these local runs are the only Rust signal until it is retargeted. Targeted runs of every touched crate, not the full suites:

  • cargo test -p dpp --all-features --lib -- ml_dsa key_type emergency_switch signing:: public_key_in_creation identity_public_key slh_dsa ml_kem should_only_admit should_sign_with: 350 passed.
  • cargo test -p drive-abci --all-features --lib -- ml_dsa_65 identity_create::tests validate_state_transition_identity_signed hash_key_data slh_dsa ml_kem proofs_of_possession signature_verification_operation identity_create_from identity_update: 364 passed.
  • cargo test -p platform-version --all-features -- signature, cargo test -p simple-signer --all-features, cargo test -p rs-sdk-ffi --all-features --lib -- signer crypto identity::keys identity::create (79 passed), cargo test -p platform-wallet --all-features --lib -- derivation_breadcrumb (3 passed), cargo test -p wasm-dpp2 --all-features --lib -- vote key_type: all passed.
  • cargo clippy -p dpp -p drive-abci -p platform-version -p simple-signer -p rs-sdk-ffi -p platform-wallet -p wasm-dpp -p wasm-dpp2 -p wasm-sdk -p dash-sdk --all-targets --all-features --locked -- --no-deps -D warnings: clean. cargo check --workspace --all-targets --all-features: clean. cargo fmt --all -- --check: clean.

What the new tests show:

  • Scheme (rs-dpp/src/util/ml_dsa_65.rs): the hash of a seed's public key and the key followed by its signature under the context string are pinned to the values OpenSSL 4.1.0 gives; a signature made for one form does not verify as the other, in both directions; bytes that are not a 1,952 byte key are not hashed; a key with another hash, a spliced signature, another message, a signature that is not canonically encoded and every other size are refused, each with its own error.
  • Transition signing (rs-dpp/src/state_transition/mod.rs): a transfer signed with the key carries 5,261 bytes whose tail is not the signature the full key makes; twelve malformed signature fields, the full key's signature behind the public key among them, are each InvalidStateTransitionSignatureError, and the hashed key's signature is refused under the full key; a private key that is not the hashed key's own is refused before signing; a transition adding the key decodes at protocol version 16 with a 5,261 byte signature field and is refused at 15.
  • Blocks (rs-drive-abci, through check_tx and process_raw_state_transitions):
    • an identity update adds the key with no proof of possession, stores 32 bytes, and the identity is found through the non-unique key hash table and not the unique one;
    • an identity whose master key is of the type signs an update that check_tx and a block accept;
    • nine malformed signature fields are refused by check_tx and unpaid by a block, the identity unchanged;
    • a proof of possession on the key, key data that is not 32 bytes, and ENCRYPTION or DECRYPTION are refused unpaid;
    • protocol version 15 refuses an identity update and an identity create carrying the key type as not active, without spending the asset lock;
    • an identity create with a master and a critical key of the type succeeds;
    • one identity holds a key pair as ML_DSA_65 while another holds its hash, registered in either order;
    • an identity holding one key pair in both forms: a transition signed with either key is admitted as signed, and refused unpaid when its signature is handed in under the other key;
    • adding a key of the type records an operation that costs nothing, where adding an ML_DSA_65 key records one that costs 100,000 credits.
  • Encoding: key type 9 is the byte 9 under bincode, from both decoders and under both configurations, and as JSON; the test that every switch is encoded as its id passes unchanged with switch 13.
  • Emergency switch: the new switch gates a transition signed with the key type and one adding it, and nothing of ML_DSA_65.
  • Same lookup hash in one transition: a 20 byte hash key carrying the lookup hash of an ML_DSA_65_HASH256 key of the same set is refused in either order, and the full key beside its own hash is accepted.

Not run locally:

  • Swift: DashSDKFFI.xcframework is not built in this checkout, so the Swift SDK, the example app and the XCTests were not compiled or run. The touched files pass swiftc -parse, and the KeyType enum with its exhaustive switches was compiled and exercised on its own. The call to dash_sdk_key_type_private_key_size in the arm of the key type has not been compiled against a generated header. The Swift build in CI, once it runs, is the first full compile.
  • JavaScript: the wasm-dpp2 mocha spec added here needs a wasm build and was not run.
  • Kotlin: the enum case, the two label lists and the unit test line were not compiled or run locally.
  • No devnet run, and no protocol version 15 to 16 upgrade rehearsal.

Breaking Changes

Consensus: protocol version 16 accepts a key type, a signature form and an emergency switch that it did not. Protocol version 16 is unreleased, and protocol versions up to 15 behave as before. Nodes built from v5.2-dev before and after this change do not agree at protocol version 16.

Source: KeyType, EmergencySwitch and MlDsa65Error gain variants, FeeSignatureVersion gains a field, and KeyType::all_key_types() returns ten key types (see "Public interface changes").

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 QuantumExplorer added this to the v5.2.0 milestone Dec 4, 2026
@github-actions github-actions Bot 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-04T12:16:02.818Z

@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

🔍 Review in progress (commit a672e85) · live progress · priority

ML_DSA_65_HASH256 (key type 9) stores the 32 byte SHA-256 of an ML-DSA-65
public key on the identity in place of the 1,952 byte key, from protocol
version 16. A transition signed with the key carries the public key in front
of the signature (5,261 bytes): the key is hashed and compared with the stored
hash, then the signature is verified by the ML_DSA_65 code already there.

Like the other hash key types it is not unique to an identity and is
registered without a proof of possession. It is found by
RIPEMD160(SHA256(data)), which is not the hash the ML_DSA_65 key of the same
key pair is found by, so the two forms never share an entry of the key hash
tables. It is refused for ENCRYPTION and DECRYPTION as ML_DSA_65 is.

Checking a signature costs verify_signature_ml_dsa_65_hash256, 105,000
credits. The key type has its own emergency switch, KeyTypeMlDsa65Hash256,
id 13. A transition registering the key type is not active before protocol
version 16, which is unreleased, so its tables and generations are edited in
place.

Bindings: wasm-dpp, wasm-dpp2, wasm-sdk, rs-sdk-ffi, the Swift SDK and the
Kotlin SDK know the key type; the Swift signer refuses it as it refuses
ML_DSA_65. Wallet derivation and signing stay with issue #6394.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@QuantumExplorer
QuantumExplorer force-pushed the feat/ml-dsa-65-hash-identity-keys branch from a65a6ef to bcb9a23 Compare December 4, 2026 10:35
@QuantumExplorer
QuantumExplorer changed the base branch from v5.2-dev to feat/slh-dsa-identity-keys December 4, 2026 10:35
@QuantumExplorer
QuantumExplorer marked this pull request as ready for review December 4, 2026 10:35

@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: 6 blockers

  • A signed batch can be attributed to the other registration of the same ML-DSA key — packages/rs-dpp/src/util/ml_dsa_65.rs:176-179 (new)
    Impact: At PV16, an identity that registers both forms of a key pair can have a pending batch executed under a different key's budget or expiry than the signer selected.
  • The public message verifier accepts unsigned messages for hashed ML-DSA keys — packages/rs-dpp/src/signing.rs:175-184 (new)
    Impact: A Rust application using PlatformMessageSignable::verify_signature to authenticate a type-9 key holder can accept a message without proof that the holder signed it.
  • The private-key registration builder returns a hashed key that Platform rejects — packages/rs-dpp/src/signing.rs:226-231 (new)
    Impact: A DPP caller using IdentityPublicKeyInCreation::from_public_key_signed_with_private_key gets Ok, but submitting the result reveals the full public key to the recipient and fails registration.
  • Registering a hashed ML-DSA key charges for a signature check that never runs — packages/rs-platform-version/src/version/fee/signature/v1.rs:20-23 (new)
    Impact: An identity owner pays a base 105,000-credit verification charge per added type-9 key even when the key carries no proof and a different key authorizes the transition.
  • Swift validates type-9 seed length against a second copy of the Rust rule — packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:257-258 (new)
    Impact: Swift callers of KeySizeValidator.isValidSize receive a verdict from a host-side size table rather than the rule used to parse the seed in DPP.
  • iOS refuses stored type-9 seeds while Android offers them to its ECDSA signer — packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift:497-499 (new)
    Impact: An Android SDK caller with a decryptable type-9 seed stored under its public-key hash can pass signing preflight and, if the seed parses as an ECDSA scalar, receive a signature that Platform rejects.

PR #6504 adds a PV16 identity key that stores an ML-DSA-65 public-key hash and carries the full public key only when signing. The Kotlin SDK build and tests and the book preview passed; the Rust workspace tests, wasm32 tests, and Swift SDK build were skipped, and no code checks failed. One verified suggestion is omitted under the ten-comment limit.

🔴 6 blocking | 🟡 4 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.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); reviewer 9: gpt-6.2-astra (agent: phase2-reviewer, role: tenderdash-consensus-security); 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-visible identity-key serialization and validation, cryptographic signature verification, and key-handling paths, including ML-DSA public-key hashing and transition signature parsing in packages/rs-dpp/src/state_transition/mod.rs and packages/rs-dpp/src/util/ml_dsa_65.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, gpt-6.2-astra — tenderdash-consensus-security (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-dpp/src/util/ml_dsa_65.rs`:
- [BLOCKING] packages/rs-dpp/src/util/ml_dsa_65.rs:176-179: A signed batch can be attributed to the other registration of the same ML-DSA key
  Impact: At PV16, an identity that registers both forms of a key pair can have a pending batch executed under a different key's budget or expiry than the signer selected.
  A batch signed with a budgeted key can be accepted under its eligible, unbudgeted counterpart. `BatchTransitionV1` excludes `signature_public_key_id` from the signed bytes, and this verifier supplies the same message and underlying key to the full-key verifier. The PR permits both forms on one identity, and Drive-ABCI loads the authorization record and remaining budget by the submitted key ID. The hash check binds the signature to the key pair, not to the selected registration. Give type 9 a distinct signing context in DPP and use it consistently in its signers and verifiers. Test that a batch signed for one form does not authenticate under the other; the stored public-key hash need not change.
- [SUGGESTION] packages/rs-dpp/src/util/ml_dsa_65.rs:128-130: The public hash helper accepts incorrectly encoded keys and returns registrable data
  Impact: An SDK caller passing container-encoded or truncated bytes to `public_key_hash` can register the resulting digest but cannot use it with the intended key.
  The helper returns a 32-byte digest for any slice, so it does not catch inputs such as a DER-wrapped key passed in place of the raw 1,952-byte key. Registration sees only the resulting digest and intentionally does not verify possession; the mismatch surfaces when the caller first tries to sign. Require the fixed-size raw encoding at the helper boundary, or return `InvalidPublicKeySize` for a slice of the wrong length. The digest of a valid raw key stays the same.

In `packages/rs-dpp/src/signing.rs`:
- [BLOCKING] packages/rs-dpp/src/signing.rs:175-184: The public message verifier accepts unsigned messages for hashed ML-DSA keys
  Impact: A Rust application using `PlatformMessageSignable::verify_signature` to authenticate a type-9 key holder can accept a message without proof that the holder signed it.
  `verify_signature` returns a valid result for an empty signature without inspecting the message or registered hash. The new test also confirms that it rejects the genuine signature returned by the same trait's `sign_by_private_key`. This is the right rule for the registration witness, not for message authentication. The node's outer transition verifier is separate and does verify the signature. Give registration callers an explicit proof-of-possession check that preserves their verdicts, and route type-9 message verification through DPP's cryptographic verifier.
- [BLOCKING] packages/rs-dpp/src/signing.rs:226-231: The private-key registration builder returns a hashed key that Platform rejects
  Impact: A DPP caller using `IdentityPublicKeyInCreation::from_public_key_signed_with_private_key` gets `Ok`, but submitting the result reveals the full public key to the recipient and fails registration.
  The private-key constructor unconditionally signs and stores the returned bytes as the registration witness. The new signing arm returns the 5,261-byte public-key-plus-signature envelope, so PV16 rejects that witness with `SignatureShouldNotBePresentError` after the recipient has already received the full key. The external-signer constructor correctly leaves the witness empty. Have both registration constructors use the same DPP proof-of-possession rule, without changing how the key signs messages or outer transitions.

In `packages/rs-platform-version/src/version/fee/signature/v1.rs`:
- [BLOCKING] packages/rs-platform-version/src/version/fee/signature/v1.rs:20-23: Registering a hashed ML-DSA key charges for a signature check that never runs
  Impact: An identity owner pays a base 105,000-credit verification charge per added type-9 key even when the key carries no proof and a different key authorizes the transition.
  A successful registration is charged the rate benchmarked for hashing a 1,952-byte key and verifying an ML-DSA signature, although its witness check only tests whether the field is empty. Identity update and the three identity-create paths all record `SignatureVerificationOperation::new(key.key_type())` for the added key, so fee accounting cannot distinguish the absence check from actual signature verification. Meter the two operations separately in PV16 estimation and execution. Preserve the full rate for real type-9 signature checks and leave shipped fees for other key types unchanged.

In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:257-258: Swift validates type-9 seed length against a second copy of the Rust rule
  Impact: Swift callers of `KeySizeValidator.isValidSize` receive a verdict from a host-side size table rather than the rule used to parse the seed in DPP.
  `isValidSize` accepts or rejects the input by comparing its length to this new literal, independently of `ml_dsa_65::seed_from_private_key` and `SEED_SIZE`. The two agree today, but the book's “Where code goes” rule assigns pure-data invariants to DPP and leaves mobile bindings to marshal them. Preserve the Swift API and have it read the key type's expected private-key size from DPP through a thin FFI call.

In `packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift:497-499: iOS refuses stored type-9 seeds while Android offers them to its ECDSA signer
  Impact: An Android SDK caller with a decryptable type-9 seed stored under its public-key hash can pass signing preflight and, if the seed parses as an ECDSA scalar, receive a signature that Platform rejects.
  `KeystoreSigner.canSignWith` checks whether the stored bytes are decryptable, but `dispatchSign` drops the key type on the stored-key path. Its JNI helper reaches `dash_sdk_signer_sign`, which supplies a dummy ECDSA key, so it cannot produce the requested ML-DSA signature. Public-key sync alone does not trigger this. The PR prevents the same mistake on iOS by extending a Swift refusal list, putting a capability decision in the binding rather than in the Rust signer that owns it. Carry the actual identity key type through the stored-key sign call and use the raw Rust signer's capability for both mobile preflights. This requires rejecting unsupported requests, not implementing the wallet derivation and signing tracked in dashpay/platform#6394 or restricting custom signers.

In `packages/rs-dpp/src/state_transition/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/state_transition/mod.rs:1174-1177: Default-feature DPP decodes type-9 registrations as active at PV15
  Impact: A client using either version-aware untrusted decoder with DPP's default features gets `Ok` for a type-9 identity registration that a PV15 node refuses.
  The activation range is correct, but with the default `state-transitions` feature and without `validation`, `decode_untrusted_in_version` checks the range only for transitions that carry a data contract. None of the four key-registration transitions carries one, so the new discriminant decodes successfully and the function returns `Ok`. Before this change, the unknown discriminant caused decoding to fail. Apply the type-9 activation rule in both feature configurations without changing lightweight decoding of unrelated historical transitions.

In `packages/wasm-dpp2/src/enums/keys/key_type.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/enums/keys/key_type.rs:50: wasm-dpp2 rejects valid ML-DSA seeds that are not secp256k1 scalars
  Impact: A JavaScript client can validate a type-9 key against its seed but cannot use `StateTransition.sign` or `signByPrivateKey` with that seed if it falls outside the secp256k1 scalar range.
  Both signing methods require `PrivateKeyWasm`, whose constructors use Dash Core's ECDSA private-key parser. That rejects some 32-byte inputs that DPP accepts as ML-DSA seeds, including an all-`0xff` seed. `IdentityPublicKey.validatePrivateKey` already accepts raw bytes and does not impose this scalar restriction. Let both signing methods also accept raw seed bytes and pass them to DPP, while preserving the existing `PrivateKey` input for callers that use it.

In `packages/wasm-sdk/src/document_create_cost.rs`:
- [SUGGESTION] packages/wasm-sdk/src/document_create_cost.rs:181: The document cost estimator quotes a type-9 signing fee for PV14 and PV15
  Impact: A caller asking for a historical document-create quote gets an exact signature-fee component for a key type the requested network version cannot register.
  `documentCreateCost` accepts the new signature key type independently of its explicit platform-version argument. Drive's `processing_costs` then reads the shared 105,000-credit rate and marks the component `exact: true`, even for PV14 or PV15. Check the signature key type's activation in the Rust estimator before pricing it, so native and WASM callers get the same result.
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.

  • An unproven non-unique key claim can block a later unique-key registration — Drive already rejects a unique-key insertion when the lookup hash exists in the non-unique tree. Existing 20-byte hash-key types can create such a claim without proving possession. This predates type 9 and is distinct from whether the full and hashed ML-DSA forms of one key share a lookup entry.
    • Follow-up: Review the cross-tree reservation policy in a separate issue alongside #3396, which tracks the existing disagreement between validation and insertion.

Comment thread packages/rs-dpp/src/util/ml_dsa_65.rs Resolved
Comment thread packages/rs-dpp/src/signing.rs Resolved
Comment thread packages/rs-dpp/src/signing.rs Resolved
Comment thread packages/rs-dpp/src/util/ml_dsa_65.rs Resolved
… feat/ml-dsa-65-hash-identity-keys

# Conflicts:
#	packages/rs-dpp/src/state_transition/mod.rs

@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

Changes requested: 6 blockers

  • A signed batch can be attributed to the other registration of the same ML-DSA key — packages/rs-dpp/src/util/ml_dsa_65.rs:176-179 (thread, carried)
    Impact: A PV16 identity that keeps both forms of one key pair active can have a signed batch evaluated against the other registration's budget or contract bounds.
  • The public message verifier accepts unsigned messages for hashed ML-DSA keys — packages/rs-dpp/src/signing.rs:175-184 (thread, carried)
    Impact: An application using PlatformMessageSignable::verify_signature to authenticate a type-9 message gets success without a signature and rejection for a genuine signature.
  • The private-key registration builder returns a hashed key that Platform rejects — packages/rs-dpp/src/signing.rs:226-231 (thread, carried)
    Impact: A caller adding a type-9 key with from_public_key_signed_with_private_key gets a successful builder result that fails registration with SignatureShouldNotBePresentError.
  • Registering a hashed ML-DSA key charges for a signature check that never runs — packages/rs-platform-version/src/version/fee/signature/v1.rs:20-23 (thread, carried)
    Impact: At PV16, a valid identity update incurs a 105,000-credit base verification charge per added type-9 key, separate from the charge for authenticating the update.
  • iOS refuses stored type-9 seeds while Android offers them to its ECDSA signer — packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift:497-499 (thread, carried)
    Impact: An Android SDK caller that imports a type-9 seed into wallet storage can get a positive signing-capability result followed by an unusable ECDSA signature.
  • Swift validates type-9 seed length against a second copy of the Rust rule — packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:257-258 (thread, carried)
    Impact: Swift callers of KeySizeValidator.isValidSize get a type-9 seed-length verdict from a separate rule rather than the DPP rule that consumes the seed.

New on this head: This revision merges the SLH-DSA base updates, centralizes key-type activation in DPP, and applies the PV16 registration gate to type 9 in the default-feature decoder. The Kotlin SDK build and emulator tests and the book preview passed; the review check is still pending.

🔴 6 blocking | 🟡 4 suggestion(s)

1 finding(s) not shown inline (the lines are not part of this PR's diff)

🟡 Suggestion: Type-9 registration decoding is untested with DPP's default features
Impact: A regression in the default-feature decoder could let a client decode a type-9 registration as active at PV15 without failing the existing type-9 decoder test.
packages/rs-dpp/src/state_transition/mod.rs:1341-1349

The merge changes the public untrusted decoder used by default-feature consumers, but DPP's own tests enable validation through its dev-dependency and exercise the other decoder branch. The external default-feature check described here omitted type 9. Add a type-9 identity update to that check and retain it as a regression test: the same serialized update should be refused at PV15 and decoded at PV16.

source: muse-spark-1.3-contributor (phase1-reviewer: general, rust-quality)

Still open from earlier rounds (9)

  • 🔴 Blocking: A signed batch can be attributed to the other registration of the same ML-DSA key — packages/rs-dpp/src/util/ml_dsa_65.rs:176-179 (thread)
  • 🔴 Blocking: The public message verifier accepts unsigned messages for hashed ML-DSA keys — packages/rs-dpp/src/signing.rs:175-184 (thread)
  • 🔴 Blocking: The private-key registration builder returns a hashed key that Platform rejects — packages/rs-dpp/src/signing.rs:226-231 (thread)
  • 🔴 Blocking: Registering a hashed ML-DSA key charges for a signature check that never runs — packages/rs-platform-version/src/version/fee/signature/v1.rs:20-23 (thread)
  • 🔴 Blocking: iOS refuses stored type-9 seeds while Android offers them to its ECDSA signer — packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift:497-499 (thread)
  • 🔴 Blocking: Swift validates type-9 seed length against a second copy of the Rust rule — packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:257-258 (thread)
  • 🟡 Suggestion: The document cost estimator quotes a type-9 signing fee for PV14 and PV15 — packages/wasm-sdk/src/document_create_cost.rs:181 (thread)
  • 🟡 Suggestion: wasm-dpp2 rejects valid ML-DSA seeds that are not secp256k1 scalars — packages/wasm-dpp2/src/enums/keys/key_type.rs:50 (thread)
  • 🟡 Suggestion: The public hash helper accepts incorrectly encoded keys and returns registrable data — packages/rs-dpp/src/util/ml_dsa_65.rs:128-130 (thread)
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-visible identity key types, signature encoding and verification, cryptographic key handling, and protocol-versioned validation in files such as packages/rs-dpp/src/state_transition/mod.rs and packages/rs-dpp/src/util/ml_dsa_65.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-dpp/src/state_transition/mod.rs`:
- [SUGGESTION] packages/rs-dpp/src/state_transition/mod.rs:1341-1349: Type-9 registration decoding is untested with DPP's default features
  Impact: A regression in the default-feature decoder could let a client decode a type-9 registration as active at PV15 without failing the existing type-9 decoder test.
  The merge changes the public untrusted decoder used by default-feature consumers, but DPP's own tests enable `validation` through its dev-dependency and exercise the other decoder branch. The external default-feature check described here omitted type 9. Add a type-9 identity update to that check and retain it as a regression test: the same serialized update should be refused at PV15 and decoded at PV16.

In `packages/rs-dpp/src/util/ml_dsa_65.rs`:
- [BLOCKING] packages/rs-dpp/src/util/ml_dsa_65.rs:176-179: A signed batch can be attributed to the other registration of the same ML-DSA key
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892117)
- [SUGGESTION] packages/rs-dpp/src/util/ml_dsa_65.rs:128-130: The public hash helper accepts incorrectly encoded keys and returns registrable data
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892180)

In `packages/rs-dpp/src/signing.rs`:
- [BLOCKING] packages/rs-dpp/src/signing.rs:175-184: The public message verifier accepts unsigned messages for hashed ML-DSA keys
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892129)
- [BLOCKING] packages/rs-dpp/src/signing.rs:226-231: The private-key registration builder returns a hashed key that Platform rejects
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892131)

In `packages/rs-platform-version/src/version/fee/signature/v1.rs`:
- [BLOCKING] packages/rs-platform-version/src/version/fee/signature/v1.rs:20-23: Registering a hashed ML-DSA key charges for a signature check that never runs
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892141)

In `packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/FFI/KeychainSigner.swift:497-499: iOS refuses stored type-9 seeds while Android offers them to its ECDSA signer
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892149)

In `packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift`:
- [BLOCKING] packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift:257-258: Swift validates type-9 seed length against a second copy of the Rust rule
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892145)

In `packages/wasm-sdk/src/document_create_cost.rs`:
- [SUGGESTION] packages/wasm-sdk/src/document_create_cost.rs:181: The document cost estimator quotes a type-9 signing fee for PV14 and PV15
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892171)

In `packages/wasm-dpp2/src/enums/keys/key_type.rs`:
- [SUGGESTION] packages/wasm-dpp2/src/enums/keys/key_type.rs:50: wasm-dpp2 rejects valid ML-DSA seeds that are not secp256k1 scalars
  (carried; thread: https://github.com/dashpay/platform/pull/6504#discussion_r4798892164)

QuantumExplorer and others added 3 commits December 4, 2026 18:26
An ML_DSA_65_HASH256 key signs under the FIPS 204 context string
`ML_DSA_65_HASH256`, where an ML_DSA_65 key signs under the empty one. One
identity can hold a key pair in both forms, and a transition does not sign the
id of its signing key, so a signature made for one form could be handed in
under the other. It now verifies for the form it was made for only.

Adding a key of the type is charged no signature check: it carries no proof of
possession, so nothing is hashed or verified. The proof of possession of an
added key is metered as its own operation, which costs what a signature check
costs for every other key type, as before.

`from_public_key_signed_with_private_key` attaches a proof of possession to a
key of a unique type only, the rule `from_public_key_signed_external` follows,
instead of signing for a hash key whose registration Platform then refuses.

`ml_dsa_65::public_key_hash` refuses bytes that are not an encoded public key.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… feat/ml-dsa-65-hash-identity-keys

Besides the conflict in the Swift key size table, the merge places the
ML_DSA_65_HASH256 key type in what the layer below added:

- `SingleKeySigner::signs_key_type` answers false for it: that signer signs
  ECDSA only. The Kotlin signer's tests name type 9 among the refused ones.
- `KeySizeValidator` reads the size of its private key from Rust, through the
  new `dash_sdk_ml_dsa_65_hash256_private_key_size` (dpp's
  `ml_dsa_65::SEED_SIZE`), as the SLH_DSA_SHA2_128S arm does.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
QuantumExplorer and others added 3 commits December 4, 2026 18:52
… feat/ml-dsa-65-hash-identity-keys

Places the ML_DSA_65_HASH256 key type in what the layers below added:
`KeyType::private_key_size` (32 bytes), the documentation of the proof of
possession check on `PlatformMessageSignable::verify_signature`, and the
wallet's rule for which keys are stored with a derivation breadcrumb (none
for a key type the wallet does not derive).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… feat/ml-dsa-65-hash-identity-keys

The layers below now give the size of a key type's private key through one
export, `dash_sdk_key_type_private_key_size`. The one-type export this branch
had added for ML_DSA_65_HASH256 is gone, and the Swift `KeySizeValidator` arm
of the key type asks the general one.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… feat/ml-dsa-65-hash-identity-keys

The FFI now reads a key type through dpp's conversion, so the per-number
arms this branch had added for ML_DSA_65_HASH256 are gone with the lists.

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