Build
Add a recovery root to your contract.
Bedrock is a Solidity core your contract inherits, an RFC 8554 LMS verifier, and a TypeScript SDK and CLI that prepare, check and submit what each root signs. Version 0.1.0, for QoreChain’s diana testnet: read the assumptions before relying on it.
forge install Femtech-web/bedrock
echo 'bedrock/=lib/bedrock/contracts/evm/src/' >> remappings.txtnpm install bedrock-continuity viem
npx bedrock-continuity inspect <contract>A good fit
- A contract that holds value for others and is run by keys that could be stolen, or whose signature family could fail: treasuries, vaults, payroll, escrow.
- A team that can keep one LMS keystore on an offline machine and rehearse an incident before depending on it.
Not what it provides
- Protection if SHA-256 or Bedrock's LMS verifier fails. The recovery root depends on both.
- Production value today. Version 0.1.0 targets diana and has not been professionally audited.
01/Quickstart
Inherit two roots, then follow three rules.
- 1 Hash each action with its own typehash and every parameter that matters.
- 2 Call
_authorize(action, auth). It returns which roots signed; decide whether that set is enough. - 3 Charge any value with
_charge(signers, amount). Single-root commitments are bounded; dual ones are not.
Stamp anything that takes effect later with epoch and check it with _isEstablished: an incident then voids it if it had not matured.
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);
}
}02/Bedrock Check
Check what your deployment establishes.
bedrock-continuity report reads one contract and says, property by property, whether it was read from the contract, recognized from its code, shown by evidence you supply, unknown, or unsupported. It never scores.
Recognition means the runtime code is an unmodified build of the published source, immutables aside. A contract that inherits BedrockCore with its own functions gets its state read and its semantics marked unknown: whether every value path goes through _authorize cannot be read from the chain.
READ interface bedrock-core/0.1.0
RECOGNIZED code unmodified BedrockVault
READ mode Normal, epoch 1
READ primary authority verifier 0xef94…bb58, key hash 0xc92c…3774
RECOGNIZED primary family ML-DSA-87 through QoreChain's pqcVerify
READ recovery authority key hash 0x1a7f…2d33, next leaf 2
RECOGNIZED recovery family LMS (RFC 8554), verified in the contract's own code
RECOGNIZED family diversity lattice primary, hash-based recovery
READ exposure policy 0.02 QOR per 180s, cap 0.05 QOR
READ remaining allowance primary 0.02 QOR, recovery 0.02 QOR
EVIDENCE evidence …response 6 of 6 recorded transactions match their receipts
UNSUPPORTED hash family fails not provided
UNSUPPORTED stolen recovery key not providedThe capped exposure vault on diana after its owner’s response. Tested on the live vaults, on a baseline contract (a single unknown), on an address without code, and on a fresh local deployment.
03/Authorizing an action
The recovery key never touches a networked machine.
Every privileged call is an operation that becomes a plain JSON instruction. Each step is a separate command, so each can run where it belongs.
1 · online · no keys
Prepare
Reads the live epoch, nonces and next leaf. Checks its own digest against the contract's authorizationDigest.
2 · offline
Check
Recomputes the action and digest from the operation itself and prints, in plain words, what will be signed.
3 · offline · keystore
Sign
Advances the keystore's state on disk before releasing a signature. The SDK never sees the LMS secret.
4 · online · any account
Submit
Confirms nothing moved, simulates, then sends. The authority is the signatures, so an unrelated relayer can deliver it.
# 1 Prepare · online · no keys
bedrock-continuity prepare <contract> incident \
--reason "…" --signers recovery --out incident.json
# 2 Check · offline
bedrock-continuity check incident.json
# 3 Sign · offline · keystore
bedrock-lms sign --dir <keystore> --digest <digest> \
--chain-high-water <recoveryNextLeaf>
# 4 Submit · online · any account
bedrock-continuity submit incident.json --recovery-key @pub.json \
--recovery-signature @sig.json --dry-runThe primary root signs the same digest with @qorechain/sdk’s pqcSign, using the key registered in x/pqc. On QoreChain the submitting account needs an open EVM window.
04/Assumptions
Rules that keep the guarantee intact.
One leaf, one message.
An LMS key is stateful. Keep its keystore on one offline machine; never copy it, run two copies, or restore an old backup without the checks in docs/signer-state.md.
One recovery key per deployment.
Never point two contracts, or a rehearsal and a deployment, at the same LMS key.
Every value path goes through _authorize.
A function that moves value or grants authority without it is outside the bound. Users' own state takes no authority path at all.
Size the cap to what you could lose unattended.
The cap is the most one root can commit between dual checkpoints if nobody is watching. An incident does not refund it.
Keep both families.
Do not override _checkRecovery or _isRecoveryKey; they are virtual only for the same-family baseline used in the comparison.
Testnet and unaudited.
Version 0.1.0 targets diana. Professional cryptographic and smart-contract audits are needed before it holds real value.
Reference
SDK: typed reads, errors by name
import { createPublicClient, http } from "viem";
import { createVault, diana } from "bedrock-continuity";
const client = createPublicClient({ chain: diana, transport: http() });
const vault = createVault({ client, address: "0x0e1c072332178bdd904967b2d322747bad6d8e8e" });
const m = await vault.manifest();
m.mode; // "Recovery"
m.primaryAvailable; // what the primary may still commit alone
m.recoveryNextLeaf; // the LMS leaf the contract accepts next
const r = await vault.submit(ins, sigs, relayerWallet);
// { ok: false, stage: "simulation", error: { name: "PrimaryUnavailable", … } }Reads, digests, instructions, submission and event watching, all typed against the compiled ABI.
CLI: seven commandsbedrock-continuity
inspect <contract> [--vault]mode, epoch, roots, nonces, policy, what each root may still commithistory <contract> --from <block>every Bedrock event, in diana's 10,000-block log rangesprepare <contract> <operation> --signers …incident, rotate-recovery, tighten-policy, set-policy, checkpoint, payoutcheck <instruction.json>offline recomputation before anything is signedsubmit <instruction.json> … [--dry-run]submitter key from BEDROCK_SUBMITTER_KEY, never a flagreceipts <results.json>re-read every recorded transaction in a results filereport <contract> [--evidence <results.json>]Bedrock Check: each property read, recognized, evidenced, unknown or unsupported
--json gives machine-readable output; --rpc selects another network.
Network: diana testnet
- EVM chain id
- 9800
- RPC
https://evm-testnet.qore.host- Explorer
- explore.qore.network
- Drill vault
- 0x0e1c07…8e8e
- ML-DSA-87 verifier
- 0xef947e…bb58
- LMS verifier
- 0xc1a05d…808b
- Drill vault policy
- 0.2 QOR per 24 h, cap 0.5 QOR
Rehearse before you depend on it
Rehearse with a throwaway keystore and test funds, never with the key that protects a deployment.
make sdk # deploy, pay within budget, refuse beyond it,
# LMS incident via the CLI, user withdraws after itcd tools
pnpm drill # compromise, incident, recovery, preserved state
pnpm manifest checkEach live run writes its hashes, gas and checks to docs/results/, where make verify-live and the verify page re-read them.
Every part, and how to get it
- ContractsBedrockCore, ExposureBudget, the LMS verifier and its ERC-7913 adapter, two example contracts
forge install Femtech-web/bedrockOn GitHub - SDK and CLIbedrock-continuity 0.1.0: inspect, prepare, check offline, submit, watch, re-read receipts, report what a contract establishes (TypeScript, viem)
npm install bedrock-continuity viemOn npm - LMS signerbedrock-lms: a stateful keystore that never signs two messages with one leaf (Go)
make signerFrom source - CI.github/workflows/verify.yml runs make verify on a clean runner; started by hand so each run is linkable
Actions → verify → Run workflowIn the repository
make sdk-registry installs the published package from npm into an empty project outside the repository and uses the library, the CLI and the Solidity sources against diana, read-only; make sdk-fresh does the same with a build from source. Nobody outside this project uses Bedrock yet.