Skip to content
Bedrock

How it works

Two roots, a budget, and an epoch.

The invariant, its properties, the non-guarantees and the integration example below are read from docs/guarantees.md, the README and the audit record when the site is built, so they match the repository word for word. Each property names the code that enforces it and the test that checks it.

Setting

Two authority roots from families that share no assumption.

Primary

ML-DSA-87
Family
ML-DSA-87 (FIPS 204), or any ERC-7913 signer
Verified by
MLDSAVerifier, which calls QoreChain's pqcVerify precompile (0x0a01)
Stored on chain as
verifier address + key hash

Recovery

LMS
Family
LMS, RFC 8554 (LMS_SHA256_M32_H10 / LMOTS_SHA256_N32_W4)
Verified by
LMS library compiled into the contract, using only the SHA-256 precompile (0x02)
Stored on chain as
key hash, next leaf

ML-DSA rests on module-lattice problems and on SHAKE (SHA-3); LMS rests only on properties of SHA-256 (SHA-2). The application runs in Normal mode with both roots, or in Recovery mode, where the primary is retired and its verifier is never called. An epoch counter increments with every incident.

Why

A strong base, and one family under everything.

QoreChain made post-quantum signatures native: ML-DSA-87 keys in x/pqc, hybrid-signed EVM windows, a verification precompile. That is a strong base. It also means every account and every contract rests on one signature family and one verifier.

That dependency is concrete. On diana, pqcVerify returned false for a valid signature over an empty message at block 10,654,790 and true at 10,654,810. Rivet found it. pnpm empty-message replays the before and after read-only, with a positive and a negative control (result). No cryptography was broken; a verifier behaved differently than expected. Bedrock is designed for that kind of event, and for the rarer ones behind it. It treats the failure of a whole family or its verifier as an operational incident with a tested procedure.

The Bedrock Continuity Invariant

Six clauses, for an adversary who controls the ML-DSA family.

For every reachable state, and for any adversary who controls the primary family (one of its keys, or forgeries or refusals by its verifier) but not the recovery root:

  1. 1That adversary's total value commitment between two dual-signed checkpoints is at most the policy cap.
  2. 2The recovery root can always retire the adversary's family.
  3. 3Retirement voids every authority grant that had not yet become binding.
  4. 4Retirement leaves every user entitlement and every binding commitment intact.
  5. 5After retirement, the application keeps operating under the surviving family.
  6. 6The retired family can never act again.
docs/guarantees.md

The roots are not symmetric

The roots are deliberately asymmetric. The recovery root is the root of trust: it signs rarely, its key stays offline, and its family rests only on SHA-256. An adversary who controls it is outside the invariant. That covers theft of its key, a break of SHA-256, or a defect in Bedrock's LMS verifier; see the non-guarantees.

Properties P1 to P10

Each clause, tied to code and to a test.

  1. P1Bounded single-family exposure

    Value committed by a single root (payouts, obligations, delegations) is charged to that root's own budget: at most periodLimit per window and at most cap between dual checkpoints. Windows restart at the first charge after the previous window ends, so any interval of periodLength sees at most 2 × periodLimit; cap is the hard bound. Only both roots together can reset the caps.

    Enforced in

    ExposureBudget.charge, BedrockCore._charge, checkpoint

    Evidence

    invariant_singleFamilyExposureBounded; test_primaryAloneCannotExceedCapAcrossPeriods; test_longOwnerAbsenceIsBoundedByCap (a year of absence yields exactly the cap); live on diana, five periods with nobody responding: the cap held where a period limit alone kept paying (docs/results/g4-exposure-live.json)

  2. P2Recovery liveness

    From any reachable state, a valid recovery-root signature can declare an incident. No action by the primary alone can stale, block or out-spend it: nonces are separate per root, tightening is undone by the incident, and the recovery budget is separate.

    Enforced in

    _authorize (per-root nonces), declareIncident (restores base policy)

    Evidence

    invariant_recoveryRootCanAlwaysDeclare; test_primaryActivityNeverStalesRecoverySignature; test_primaryCannotStarveRecoveryByTightening; test_recoveryAloneHasItsOwnBudget

  3. P3Pending authority is voided

    A commitment stamped with epoch *e* and maturing at readyAt is binding iff it matured before epoch *e* ended, or *e* is current and it has matured. Delegations are valid only in their own epoch. An incident ends the epoch.

    Enforced in

    _isEstablished, BedrockVault.isVoid, operatorPayout

    Evidence

    S1, S2; invariant_reservesMatchObligations; mutation "void obligations stay binding" is caught

  4. P4Legitimate state is preserved

    User balances and withdrawal requests have no authority path at all. Claims are permissionless and pay the owner. Binding obligations survive incidents.

    Enforced in

    BedrockVault user functions take no authorization

    Evidence

    invariant_userEntitlementsExact; invariant_solvent; S1–S3 _assertLegitimateStateIntact; live: a copied key refused a user's deposit (InsufficientTreasury) and the user withdrew it (docs/results/g4-exposure-response.json)

  5. P5Operation continues without the failed verifier

    In Recovery mode, any authorization carrying a primary signature is refused before verification. The recovery root alone can pay, schedule and restore within its budget.

    Enforced in

    _authorize (PrimaryUnavailable)

    Evidence

    test_S2_recoveryModeMakesNoCallToPrimaryVerifier (zero calls to the verifier); S2, S3

  6. P6No reverse authority

    A retired primary cannot sign anything that verifies: the epoch inside the digest changed, the key hash was replaced or cleared, and in Recovery mode primary signatures are refused outright. Only the recovery root declares incidents.

    Enforced in

    declareIncident, _digest

    Evidence

    test_S8_retiredAuthorityCannotReverse; test_primaryCannotDeclareIncident; live: a replaced key refused, also when reinstating itself (docs/results/g4-exposure-response.json)

  7. P7Root integrity

    The recovery key changes only with both roots (Normal) or the recovery root (Recovery). Loosening policy and resetting caps need both roots. A newly installed primary counts toward "both" only after DUAL_ACTIVATION_DELAY.

    Enforced in

    rotateRecoveryKey, setPolicy, checkpoint, primaryDualAfter

    Evidence

    invariant_recoveryRootFixed; S5; test_successorCountsTowardDualOnlyAfterDelay; live: a successor's budget restored by a both-roots checkpoint after the delay (docs/results/g4-exposure-response.json)

  8. P8Replay and binding

    Each authorization is single use, bound to the action, contract, chain, epoch, signer set and deadline. Recovery leaves strictly increase on chain.

    Enforced in

    _digest, _checkRecovery

    Evidence

    test_authorizationIsSingleUse; test_signatureBoundTo*; test_recoveryLeafCannotBeReused; S4

  9. P9Monotone counters, consistent mode

    The epoch and the recovery leaf never decrease. Recovery mode holds exactly when no primary verifier is set.

    Enforced in

    declareIncident, _checkRecovery

    Evidence

    invariant_monotoneCounters, invariant_modeConsistent

  10. P10Verifier correctness

    The LMS verifier accepts exactly what RFC 8554 accepts on the supported parameter sets, and never reverts on malformed input.

    Enforced in

    LMS, HSS

    Evidence

    RFC 8554 Test Cases 1 and 2; 371/371 verdicts agree with lms-go; six fuzzed properties. Valid signatures tested at every height, H5 to H25, at the last leaf. H5 to H20 also with full lms-go keys; H25 only with lms-go one-time signatures on random authentication paths (test/review/CryptoReview.t.sol)

How strong the evidence is

Evidence, not proof.

  • Property-based testing, not formal verification

    The invariants run as Foundry invariant tests: 48 random sequences of 40 calls each with fail-on-revert. The handler covers deposits, withdrawals, payouts by every signer set, over-budget attempts, obligations, settlement, release, delegations, tightening, checkpoints, incidents of both kinds, and time jumps. A passing run is evidence, not proof.

  • Mutation checks

    make mutants applies three deliberate defects one at a time, and the suite catches each (results):

    • · the recovery root not charged;
    • · a withdrawal paid to the caller;
    • · voided obligations staying binding. Only the scenario tests catch this one; the invariants do not model epoch voiding.
  • Independent oracles

    The verifier is checked against data Bedrock did not produce: the RFC's own test vectors, and the verdicts of Trail of Bits' lms-go. The test-only LMS signer is itself checked by reproducing RFC Test Case 2's published key from its published seed.

  • Not audited

    Bedrock is new code. The two-stage QCAI review and a separate AI-assisted review of the verifier and contracts are recorded in AUDIT.md. Nothing here should be read as a production audit.

Built on QoreChain

What Bedrock uses from QoreChain’s PQC layer.

pqcVerify (0x0a01)

Where: MLDSAVerifier.verify, the primary root's ERC-7913 verifier

Protects: every primary-root authorization: payouts, obligations, delegations, policy and checkpoints. The signed message is always the 32-byte EIP-712 digest. Wrong-sized keys or signatures never reach the precompile; a revert, missing precompile, short, long or non-canonical return is a rejection. BedrockCore in turn accepts the adapter's answer only as the exact zero-padded ERC-7913 selector

Tests: test/verify/MLDSAVerifier.t.sol (5 tests, 2 fuzzed; 2 planted defects caught); test_F3_onlyTheCanonicalVerifierAnswerIsAccepted; live: docs/results/g1-g2-live.json

pqcKeyStatus (0x0a02)

Where: BedrockCore constructor, when registryAccount is set

Protects: the primary key must equal the account's ML-DSA-87 key registered in x/pqc with proven possession, so the contract cannot be deployed against a key the owner never registered

Tests: test_enrollmentRequiresProvenRegisteredKey

none (by design)

Where: LMS library, the recovery root

Protects: the recovery root verifies RFC 8554 LMS with the SHA-256 precompile only, so it keeps working if pqcVerify misbehaves. In Recovery mode a primary signature is refused before any call to pqcVerify

Tests: test/verify/LMSVectors.t.sol, LMSProperties.t.sol, test_S2_recoveryModeMakesNoCallToPrimaryVerifier, test_S3_verifierRejectsValidSignatures

EVM windows

25 windows from the four roles, read from the chain. All 16 of 16 opened by the relayer, attacker and user are scoped to Bedrock’s contracts; the owner’s 6 unscoped windows are the deployment sessions, since a scoped window cannot create contracts. docs/results/windows-live.json

Tooling uses @qorechain/sdk and @qorechain/evm, following the patterns of QoreChain’s build-before-qday workshops.

Build on it

Inherit two roots in a few lines.

A contract inherits BedrockCore, authorizes each action with _authorize, and charges its value to the signers’ budgets with _charge. Install it with forge install, or from npm as bedrock-continuity (SDK, CLI and contracts); the example compiles in a fresh project. The integration guide lists the rules that keep the guarantee intact.

forge install Femtech-web/bedrock
echo 'bedrock/=lib/bedrock/contracts/evm/src/' >> remappings.txt
import {BedrockCore} from "bedrock/core/BedrockCore.sol";
import {ExposureBudget} from "bedrock/core/ExposureBudget.sol";

contract Treasury is BedrockCore {
    bytes32 constant GRANT =
        keccak256("Grant(address to,uint256 amount)");

    constructor(
        address mldsaVerifier,
        bytes memory mldsaKey,
        address owner,
        bytes memory lmsKey
    )
        BedrockCore(
            mldsaVerifier,
            mldsaKey,
            owner,
            lmsKey,
            ExposureBudget.Policy(1 ether, 5 ether, 1 days),
            2 days
        )
    {}

    function grant(
        address to,
        uint256 amount,
        Authorization calldata auth
    ) external {
        Signers signers =
            _authorize(keccak256(abi.encode(GRANT, to, amount)), auth);
        _charge(signers, amount);
        (bool ok,) = to.call{value: amount}("");
        require(ok);
    }
}

Non-guarantees

What the invariant does not cover.

  • Consensus. QoreChain validators sign blocks with ed25519. A break of that layer is outside any application's reach, and Bedrock does not claim to survive it.

  • Network admission. On diana, every EVM transaction needs a sender with a registered ML-DSA-87 key and an EVM window opened with a hybrid signature. Bedrock's recovery is independent at the application level: any account can relay it, and the relayer holds no authority. It is not independent of x/pqc at the network level. See threat-model.md.

  • Recovery-root compromise. The recovery root is the root of trust. If its private key is stolen, or LMS signatures can be forged (a SHA-256 break, or a defect in Bedrock's LMS verifier), the adversary has the recovery root's bounded power at once. After DUAL_ACTIVATION_DELAY they can install a primary of their own and gain full power. The delay is not a response window: retiring the primary and rotating the recovery key fit in one transaction, after which the owner's copy of the key matches nothing (test_stolenRecoveryKey_lockoutTakesOneTransaction). Recommended safeguards, and the k-of-n recovery root planned for the next version, are in AUDIT.md. Users can always withdraw what they own. Keep the recovery key offline; see signer-state.md.

  • Single-key compromise is not unique to Bedrock. An independent ML-DSA guardian contains one stolen key just as well (baseline B). Bedrock's advantage is specific to a failure of the whole family or its verifier.

  • Bedrock is not the lowest-loss design. A multi-signer that needs both families on every operation loses nothing to a stolen or forged ML-DSA key (baselines D2 and D3). It needs an LMS signature on every payout instead. Bedrock bounds the loss while routine payouts need ML-DSA alone.

  • Software signer state. The keystore prevents leaf reuse across crashes, concurrent use and lost state. It cannot detect a full rollback of its directory. NIST SP 800-208 requires hardware for this reason, and the software signer does not meet that requirement.