Skip to content

Implement Hash on non-secret Signature and VerifyingKey types#1309

Merged
tarcieri merged 1 commit intoRustCrypto:masterfrom
MavenRain:hash-on-public-types
May 1, 2026
Merged

Implement Hash on non-secret Signature and VerifyingKey types#1309
tarcieri merged 1 commit intoRustCrypto:masterfrom
MavenRain:hash-on-public-types

Conversation

@MavenRain
Copy link
Copy Markdown
Contributor

Per #1229: Signature and public-key types lack Hash, which prevents
use in HashMap / HashSet keys and similar collections.

  • ecdsa: Signature, DER Signature, SignatureWithOid
  • ed25519: Signature, pkcs8::PublicKeyBytes
  • ed448: Signature, pkcs8::PublicKeyBytes
  • ml-dsa: Signature, VerifyingKey
  • slh-dsa: Signature, VerifyingKey

Where a trivial derive works (ed25519, ed448), uses derive. Where
generic bounds or upstream gaps require it, uses a manual impl over
the canonical serialized bytes (to_bytes / encode / as_bytes),
which is the natural Hash domain for these types anyway.

Followups (separate PRs, blocked on upstream):

  • ecdsa VerifyingKey (needs PublicKey: Hash in elliptic-curve)
  • dsa types (need BoxedUint: Hash in crypto-bigint)
  • lms types (need Mode-generic trait bound threading)

Closes #1229

@tarcieri
Copy link
Copy Markdown
Member

Hmm, those unreachable_pub failures seem potentially unrelated

@tarcieri
Copy link
Copy Markdown
Member

@MavenRain if you merge/rebase it should take care of the test failures

  Per RustCrypto#1229: Signature and public-key types lack `Hash`, which prevents
  use in `HashMap` / `HashSet` keys and similar collections.

  - ecdsa: Signature, DER Signature, SignatureWithOid
  - ed25519: Signature, pkcs8::PublicKeyBytes
  - ed448: Signature, pkcs8::PublicKeyBytes
  - ml-dsa: Signature, VerifyingKey
  - slh-dsa: Signature, VerifyingKey

  Where a trivial derive works (ed25519, ed448), uses derive. Where
  generic bounds or upstream gaps require it, uses a manual impl over
  the canonical serialized bytes (`to_bytes` / `encode` / `as_bytes`),
  which is the natural Hash domain for these types anyway.

  Followups (separate PRs, blocked on upstream):
  - ecdsa VerifyingKey (needs PublicKey<C>: Hash in elliptic-curve)
  - dsa types (need BoxedUint: Hash in crypto-bigint)
  - lms types (need Mode-generic trait bound threading)

  Closes RustCrypto#1229
@MavenRain MavenRain force-pushed the hash-on-public-types branch from 2685fe9 to b3274c9 Compare May 1, 2026 19:42
@tarcieri tarcieri merged commit 826baa3 into RustCrypto:master May 1, 2026
61 checks passed
@tarcieri tarcieri mentioned this pull request May 3, 2026
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.

Types generally do not implement Hash.

2 participants