Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hashsigs-rs

> 编程语言
Open source

Hash-based post quantum signatures in Rust

11.2K stars0 likes1 views
WebsiteGitHub

About

Hash-based post quantum signatures in Rust

hashsigs-rs

Core Rust hash-signature workspace with:

  • hashsigs-rs: one crate containing:
    • wotsplus — the standalone WOTS+ one-time signature scheme (v1, legacy)
    • sphincs_plus_c — the stateless SPHINCS+C scheme
    • shrincs — the hybrid SHRINCS signer / verifier
    • wasm — verifier / signer bindings
  • solana/: verify-only Solana program, plus an account-wrapper example at solana/examples/shrincs-account/
  • ts/: @quip.network/hashsigs-wasm, the npm wrapper for the wasm build
  • py/: the Python package scaffold (hashsigs). The binding API is under construction

This crate is the reference signer: it generates the golden vectors that anchor the Solidity verifier in hashsigs-solidity.

The SHRINCS construction

SHRINCS is a two-path hash-based signature construction (ePrint 2025/2203, appendix). One committed key bundle carries two verification paths with different costs and budgets:

  • Stateful path (cheap, bounded). A WOTS-C one-time signature under an unbalanced XMSS-style Merkle tree (UXMSS). Normal operations use this path. Each signature consumes one leaf, up to maxSignatures (at most 4,096).
  • Stateless path (expensive, break-glass). A full SPHINCS+C signature: a FORS-C few-time signature carried up a hypertree of WOTS-C layers. Reserved for recovery and key rotation. Needs no signer state.
mermaid
graph TD
    C["publicKeyCommitment (32 B)<br/>tag: shrincs-public-key/&lt;profile&gt;<br/>binds statefulPublicKey + pkSeed + hypertreeRoot"]
    C --> SR["Stateful root (UXMSS)<br/>unbalanced tree of WOTS-C one-time leaves<br/>leaf index = auth-path length"]
    C --> HR["Stateless root (SPHINCS+C)<br/>hypertree of WOTS-C layers<br/>over FORS-C few-time signatures"]

A 32-byte publicKeyCommitment binds both roots plus the profile identity. Only the commitment needs on-chain storage. Callers resupply the full 164-byte public-key bundle on every verify, and the verifier recomputes and checks the commitment. Verification is pure keccak-256 (SHA-256 for scheme hashes in the sha2 profile) and grinds nothing. Signer state (nonces, used-leaf tracking, budgets) belongs to the integrating account, not the verifier.

Components

Dependencies point only downward. Neither path knows about the other. shrincs composes them at the API boundary.

  • shrincs — the hybrid: commitment scheme, stateful + stateless dispatch, canonical action and rotation hashes.
  • shrincs::uxmss — the stateful half: WOTS-C leaves under the unbalanced tree, crate-internal.
  • sphincs_plus_c — the stateless half: FORS-C (fors_c) and the hypertree (hypertree). Oblivious to shrincs.
  • wots_c — the shared WOTS-C target-sum chain walk, grind, and codec. Both paths bind it with their own domain tags. It calls into neither.
  • wotsplus — standalone WOTS+ with checksum chains, the v1 wallet scheme. Not part of SHRINCS. Legacy: do not use WOTS+ for new integrations. Use SHRINCS. It stays only to keep v1 wallets verifiable.
  • Scheme-neutral foundation at the crate root: hash/ (tagged hash suite), abi (Solidity-compatible codec), buf, profiles, treehash.

Research lineage

Key Paper Role here
SHRINCS Kudinov, Nick — Hash-based Signature Schemes for Bitcoin, ePrint 2025/2203 The hybrid construction. UXMSS is its App. B.3
SPHINCS+C Kudinov, Hülsing, Ronen, Yogev — SPHINCS+C: Compressing SPHINCS+ With (Almost) No Cost, ePrint 2022/778, IEEE S&P 2023 The stateless path: WOTS-C target-sum chains, FORS-C grinding
SPHINCS+ SPHINCS+ Specification v3.1 (2022) Base stateless design: PK = (PK.seed, PK.root), FORS + hypertree
FIPS 205 NIST — Stateless Hash-Based Digital Signature Standard (SLH-DSA) Address-word conventions, with one documented deviation (below)
WOTS+ Hülsing — W-OTS+: Shorter Signatures for Hash-Based Signature Schemes, AFRICACRYPT 2013 Winternitz chains, shipped standalone as the legacy v1 scheme
RFC 8391 XMSS: eXtended Merkle Signature Scheme Baseline the stateful component departs from

Deltas against the standard constructions

Against SPHINCS+, the SPHINCS+C changes move work from the verifier to signer-side grinding:

  • WOTS-C drops the checksum chains. The signer grinds a counter until the message digits sum to a fixed target (480 at 256s, 240 at 128s). The verifier checks the target-sum equation.
  • FORS-C grinds until the last FORS tree index is zero, so the signature reveals only k − 1 trees.
  • Each signature adds a 4-byte grind counter and a per-signature randomizer.

Against RFC 8391 XMSS, UXMSS differs in four ways:

  • The tree is unbalanced and sized to any maxSignatures, with no power-of-two constraint.
  • The leaf index is implicit: it equals the auth-path length.
  • Leaves are WOTS-C, sharing chain machinery with the stateless side.
  • Hashes use SPHINCS-style string tags (uxmss-*) instead of the RFC 8391 ADRS structure.

Documented FIPS 205 deviation: the signer does not serialize upper-layer hypertree coordinates. The verifier re-derives them. Layer-0 coordinates come from the FORS digest, and each upper layer follows a fixed recurrence (src/sphincs_plus_c/hypertree.rs).

Parameters, sizes, and measured costs

Six compile-time profiles ship: three parameter sets, each in a keccak and a sha2 variant. The cryptographic constants match the Solidity verifier. src/profiles/ is the Rust source of truth.

Parameter 256s / 256s-sha2 128s-q18 / 128s-q20 and their sha2 twins
Scheme-hash suite keccak-256 / SHA-256 keccak-256 / SHA-256
Hash entropy 32 B 16 B truncated (full 32-byte wire slots)
Hypertree height 64, 8 layers height 18, 1 layer
FORS-C 22 trees, height 14 6 trees, height 24
WOTS-C 64 chains, w = 16, target sum 480 32 chains, w = 16, target sum 240
Stateless signature budget 2^20 2^18 (q18) / 2^20 (q20)
FORS-C grind bound 2^24 2^28

128s-q20 differs from 128s-q18 only in the stateless budget. The larger q20 budget still needs security-analysis backing before production use. The sha2 suite switches scheme hashes only, so 128s-q18-sha2 shares every row of this table with 128s-q18, and 128s-q20-sha2 with 128s-q20. EVM-domain hashes (profile identity, commitments, canonical action hashes) stay keccak under every profile, so the 128s and sha2 profiles change hashing work, not commitment framing.

Per-variation sizes and costs

One table covers every published variation: key sizes, signature sizes, native times, and on-chain verify costs.

Read it with four things in mind. Key sizes are constant across all six SHRINCS profiles, so those columns repeat by design and the layouts appear below the table. The stateful signature has no single size, because leaf L carries L auth nodes and signatures grow 32 B per consumed leaf. Stateful sign time shrinks as L grows, since the auth-path rebuild covers fewer remaining leaves. Native times come from one sweep on 2026-08-25, on one core of an AMD Ryzen 9 5950X, --release, maxSignatures = 1024, stateful sign at leaf 1, so every row compares to every other row. One keygen derives both paths of a profile, so the two rows of a profile share a keygen time.

Variation Path Secret key Public bundle On-chain key Signature size Keygen Sign Verify (native) EVM verify gas Solana verify (CU)
shrincs-256s-keccak stateful 264 B 164 B 32 B 2,084 + 32·L B (2,116 at L = 1) 440 ms 350 ms 0.16 ms 190,792 111,586
shrincs-256s-keccak stateless 264 B 164 B 32 B 29,092 B 440 ms ~1.2 s 1.5 ms 1,660,931 1,029,780
shrincs-256s-sha2 stateful 264 B 164 B 32 B 2,084 + 32·L B (2,116 at L = 1) 117 ms 91 ms 0.05 ms 281,063 101,909
shrincs-256s-sha2 stateless 264 B 164 B 32 B 29,092 B 117 ms ~0.33 s 0.43 ms 2,455,228 931,804
shrincs-128s-q18-keccak stateful 264 B 164 B 32 B 1,060 + 32·L B (1,092 at L = 1) 45.2 s 172 ms 0.08 ms 117,759 58,461
shrincs-128s-q18-keccak stateless 264 B 164 B 32 B 5,704 B 45.2 s ~2.8 min 0.17 ms 204,635 106,555 †
shrincs-128s-q20-keccak stateful 264 B 164 B 32 B 1,060 + 32·L B (1,092 at L = 1) 44.9 s 173 ms 0.08 ms 117,759 derived from q18
shrincs-128s-q20-keccak stateless 264 B 164 B 32 B 5,704 B 44.9 s ~2.8 min 0.17 ms 204,635 derived from q18
shrincs-128s-q18-sha2 stateful 264 B 164 B 32 B 1,060 + 32·L B (1,092 at L = 1) 12.8 s 46 ms 0.02 ms not measured § not measured ‡
shrincs-128s-q18-sha2 stateless 264 B 164 B 32 B 5,704 B 12.8 s ~47 s 0.04 ms not measured § not measured ‡
shrincs-128s-q20-sha2 stateful 264 B 164 B 32 B 1,060 + 32·L B (1,092 at L = 1) 13.3 s 47 ms 0.02 ms not measured § not measured ‡
shrincs-128s-q20-sha2 stateless 264 B 164 B 32 B 5,704 B 13.3 s ~51 s 0.04 ms not measured § not measured ‡
wotsplus (v1, keccak, legacy) one-time 32 B 64 B none 2,144 B 0.41 ms 0.20 ms 0.23 ms ~500,000 298,064

Key layouts, constant across all six SHRINCS profiles:

Item Bytes Layout
SHRINCS secret key 264 stateful(136) ‖ stateless(128): eight 32-byte seeds/roots + two 4-byte counters
SHRINCS public bundle 164 statefulPublicKey(68) ‖ commitment(32) ‖ pkSeed(32) ‖ hypertreeRoot(32)
publicKeyCommitment 32 the only on-chain key material
Stateful public key 68 pkSeed(32) ‖ root(32) ‖ maxSignatures(4 BE)
Stateless (SPHINCS+C) public key 64 pkSeed(32) ‖ root(32)
WOTS+ v1 key (legacy) 32 secret / 64 public seed / public_seed(32) ‖ pk_hash(32)

Signature sizes count packed field bytes. The Signature size column is the packed size, and ABI envelopes run larger, as the notes below explain.

EVM verify gas is the account-wrapper call, measured in hashsigs-solidity on 2026-07-13. The stateful path is 8–14× cheaper than stateless. That asymmetry is the design point: everyday operations ride the bounded stateful path, and the stateless authority stays reserved for recovery.

† Measured through the SphincsPlusCVerify instruction. A SHRINCS stateless signature is a SPHINCS+C signature plus a commitment check, and the hybrid ShrincsVerifyStateless cost was not recorded at 128s.

‡ No SBF run has recorded these two profiles. The program builds against them through --features hashsigs-rs/profile-128s-q18-sha2, so the figure is missing, not unavailable. Do not read the keccak twin's cost across: the SHA-256 syscall and the keccak syscall have different costs.

§ The wrapper-call figures need the account-wrapper vectors, which do not exist for the two 128s sha2 profiles yet. Instead this run measures the raw stateless verifier directly, on the same call under each profile (SHRINCSSphincs128sVectors.testMeasureStateless128sVerifyGas, 2026-08-25): 242,552 gas under 128s-q18 and 128s-q20, and 317,515 gas under 128s-q18-sha2 and 128s-q20-sha2. That is the raw verifier, not the wrapper call, so compare it only against the other number in this footnote. The 1.31× ratio is the SHA-256 precompile against the keccak256 opcode, and it matches the direction of the 256s pair in the table.

Notes:

  • Solana compute units come from the SBF VM running the real program binary (docs/solidity-parity.md). 128s-q20 shares every crypto constant with 128s-q18, so the table lists its cost as derived, not measured. The WOTS+ instruction pins keccak hashing, so its cost does not depend on the compiled p

Issues· 7 open

View all issuesOpen on GitHub
  • #25

    FORS-C grind bound (2^24) is profile-independent: ~37% stateless signing failure at 128s (a=24)

    Updated Jul 27, 2026

> Tags

Rust

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言