Skip to content

feat(tendermint): verify ML-DSA-65 validator signatures (mldsa65 feature) - #1533

Open
zmanian wants to merge 5 commits into
cometbft:mainfrom
zmanian:zaki/mldsa65-verify
Open

zmanian wants to merge 5 commits into
cometbft:mainfrom
zmanian:zaki/mldsa65-verify

Conversation

@zmanian

@zmanian zmanian commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Depends on #1532 (proto regeneration). This branch contains that commit too; review only the last commit, tendermint: verify ML-DSA-65 validator signatures.

Adds ML-DSA-65 (FIPS 204) validator keys for verification, matching CometBFT v0.40.0 (cometbft#5875) and the verification-only backport in v0.38.26 (cometbft#6028). This lets light clients, and the IBC relayers built on them, follow chains whose validators use ML-DSA-65. Signing and priv_validator_key.json are out of scope.

Behind a new mldsa65 feature

Uses RustCrypto ml-dsa 0.1.2 (Apache-2.0 OR MIT, no_std). It needs Rust 1.87, above the workspace MSRV of 1.82, which is why it is opt-in.

  • PublicKey::MlDsa65: JSON type cometbft/PubKeyMlDsa65, the protobuf Sum JSON wrapper form, v0.38 proto field 4, ordering and bytes.
  • Addresses are SHA256(pubkey)[:20], as CometBFT computes them, both from PublicKey and from the raw proto key used when decoding validator sets.
  • The default verifier checks pure ML-DSA signatures with an empty context (verify_with_context(msg, &[], sig)), as circl's mldsa65.Verify(pk, msg, nil, sig) does in Go.
  • tendermint-light-client-verifier gets a passthrough mldsa65 feature.

Without the feature

So that data from ML-DSA chains parses whether or not the feature is on:

  • Algorithm::MlDsa65 ("ml_dsa_65"). Before, consensus params with this key type failed to parse from JSON and were read as Ed25519 from protobuf.
  • Signature accepts 3309-byte signatures.
  • An ML-DSA validator set without the feature fails with an error, not a panic.

Design choices to look at

  • PublicKey stays Copy. The 1952-byte key is stored inline. Boxing it would remove Copy and make enabling the feature a breaking change. The cost is that the enum grows to about 2 KB when the feature is on, which trips clippy::large_enum_variant on PublicKey and on two error enums that hold a validator set (Verdict, CompareError). Those are allowed with a comment.
  • Only v0.38 proto types can carry the key. Converting an ML-DSA key into the v0.34 or v0.37 PublicKey yields an empty sum, which fails to decode rather than producing a wrong key.
  • to_bech32 uses a derived prefix. CometBFT defines no bech32 form for ML-DSA. The amino prefix is derived from the registered name cometbft/PubKeyMlDsa65 with the same rule that gives the Ed25519 and secp256k1 prefixes.

Testing

Expected values come from fixtures produced by CometBFT v0.40.0 (generator and README in tendermint/tests/support/mldsa65/):

  • The key's JSON, protobuf-wrapper JSON, proto bytes and address, and a validator-set hash, all matched against Go.
  • Go-signed messages verify. A flipped bit, a wrong length, and a signature made under a non-empty context are all rejected.
  • A mixed Ed25519 + ML-DSA-65 commit that Go's VerifyCommitLight accepts is accepted by ProdVerifier::verify_commit, and rejected once the ML-DSA signature is tampered with.
  • validator::Info deserializes from RPC-style JSON. Algorithm and ValidatorParams round-trip through JSON and protobuf.

Results, for tendermint, tendermint-proto, tendermint-light-client-verifier, tendermint-p2p and tendermint-rpc:

  • All features: 198 passed, 0 failed.
  • Default features (tendermint, light-client-verifier): 117 passed, 0 failed.
  • tools/no-std-check builds with -Z build-std=core,alloc and mldsa65 enabled.
  • No new clippy findings on changed lines.
  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Added entry in .changelog/

🤖 Generated with Claude Code

zmanian and others added 2 commits November 11, 2026 20:24
v0.38.26 backports the `mldsa65` (tag 4) case of
`tendermint.crypto.PublicKey` so v0.38 nodes can verify counterparties on
v0.40 with ML-DSA-65 validators. Regenerating adds `Sum::Mldsa65` (JSON
type `cometbft/PubKeyMlDsa65`) and the Go-only `blocksync::SigCount*`
messages; no other proto changes between v0.38.12 and v0.38.26.

Only the v0_38 output is committed. Running the tool also adds
`#[allow(clippy::all)]` throughout and touches v0_34/v0_37, which the
committed code on main does not have; those changes were left out.

Also:
- p2p: treat an ML-DSA-65 peer key like secp256k1 (unsupported key).
- proto-compiler: replace deprecated `TempDir::into_path` with `keep()`
  (tempfile >= 3.20), which otherwise fails the build under -D warnings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds ML-DSA-65 (FIPS 204) validator keys for verification, matching
CometBFT v0.40 and the v0.38.26 verification backport, so light clients
(and IBC relayers built on them) can follow chains whose validators use
ML-DSA-65. Signing is out of scope.

Behind a new `mldsa65` feature (RustCrypto `ml-dsa` 0.1.2, Rust 1.87+):
- `PublicKey::MlDsa65`, holding the 1952-byte packed key inline so
  `PublicKey` stays `Copy`; JSON type `cometbft/PubKeyMlDsa65`, the
  protobuf `Sum` wrapper form, v0_38 proto field 4, ordering, bytes,
  bech32 (amino prefix derived from the registered name).
- Addresses are SHA256(pubkey)[:20], both from `PublicKey` and from the
  raw proto key used when decoding validator sets.
- The default verifier checks pure ML-DSA signatures with an empty
  context (`verify_with_context(msg, &[], sig)`), as circl does in Go.
- `tendermint-light-client-verifier` gets a passthrough `mldsa65` feature.

Independent of the feature, so ML-DSA chains' data parses:
- `Algorithm::MlDsa65` ("ml_dsa_65") in consensus params, JSON and proto.
- `Signature` accepts 3309-byte signatures.

The larger `PublicKey` trips `clippy::large_enum_variant` on it and on two
error enums that embed a validator set; those are allowed with a comment.

Tests use fixtures generated by CometBFT v0.40.0 (generator and README in
tendermint/tests/support/mldsa65): key JSON/proto/address, a validator-set
hash, Go-signed messages (including a non-empty-context signature that
must be rejected), and a mixed Ed25519/ML-DSA-65 commit that Go's
VerifyCommitLight accepts and the Rust light-client verifier must accept,
and reject once tampered. Also covers no_std (build-std core,alloc).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 12, 2026

Copy link
Copy Markdown

This PR does not match any of the 1 configured review trigger rule.

zmanian and others added 3 commits November 11, 2026 20:27
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JayT106 added a commit to crypto-org-chain/hermes that referenced this pull request Nov 16, 2026
Patches tendermint-rs to a backport of cometbft/tendermint-rs#1533 and
enables its mldsa65 feature. ml-dsa needs Rust 1.87, so the MSRV moves
from 1.85 to 1.87.
JayT106 added a commit to crypto-org-chain/hermes that referenced this pull request Nov 18, 2026
…ort (#11)

* feat: verify ML-DSA-65 validator keys via tendermint-rs v0.40.4 backport

Patches tendermint-rs to a backport of cometbft/tendermint-rs#1533 and
enables its mldsa65 feature. ml-dsa needs Rust 1.87, so the MSRV moves
from 1.85 to 1.87.

* docs: state MSRV 1.87 in README and changelog, note client update size

* ci: pin cargo-doc to a nightly with stable cfg(true) and doc_auto_cfg

* ci: apply the tendermint-rs patch to the standalone check-guide workspace

* ci: drop the unused testgen patch from check-guide and run its check on root manifest changes

* test: verify an ML-DSA-65 signed header after Any encoding

* fix(test-framework): skip wasmvm version check when starting injectived

(cherry picked from commit 9c63cd1606cdeac8de5c43222618b27d7d0da439)

* test: lower injective max_msg_num to keep relay txs under max_gas

(cherry picked from commit eac8cd8)
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.

1 participant