Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9eac951
feat: load a ceremony proving key and expose its verifier constants
ozwaldorf Aug 19, 2026
f841958
fix: give the fixture a lease a real bond() can grant
ozwaldorf Aug 21, 2026
8274905
fix: put the fixture escrow at a reachable CREATE address
ozwaldorf Aug 21, 2026
9a47b65
feat: serialize a proving key, and name the key types
ozwaldorf Aug 25, 2026
6dea00a
chore: add relation constraint profiling
ozwaldorf Aug 31, 2026
1671ecd
perf: specialize single-transfer receipt layout
ozwaldorf Aug 31, 2026
cbbb8e0
test: exhaust fixed receipt layout widths
ozwaldorf Aug 31, 2026
3b7b1a6
perf: extract authenticated header fields at fixed offsets
ozwaldorf Aug 31, 2026
2709f00
test: cover authenticated header prefix extraction
ozwaldorf Aug 31, 2026
85af001
docs: record combined optimization result
ozwaldorf Aug 31, 2026
902ad3e
perf: add structural receipt bound to combined candidate
ozwaldorf Aug 31, 2026
734913c
perf: prototype constructed receipt trie leaf
ozwaldorf Aug 31, 2026
c7ef300
perf: construct terminal MPT leaf in circuit
ozwaldorf Aug 31, 2026
a8fbe1c
chore: profile sequential receipt trie shapes
ozwaldorf Aug 31, 2026
da4f097
perf: add universal depth-seven MPT tier
ozwaldorf Aug 31, 2026
d2eda3b
perf: prototype arkworks Keccacheck verifier
ozwaldorf Sep 1, 2026
8b60d00
perf: integrate batched Keccacheck relation
ozwaldorf Sep 3, 2026
6237592
bench: measure integrated Keccacheck prover
ozwaldorf Sep 3, 2026
5f16efb
feat: export Keccacheck verifier artifacts
ozwaldorf Sep 3, 2026
08148cb
feat: add reproducible Keccacheck proving helper
ozwaldorf Sep 3, 2026
b5192b4
fix: assert one-hot selectors hit for in-range reads
ozwaldorf Sep 9, 2026
c43d92e
test: close batched, singleton and sole-log coverage gaps
ozwaldorf Sep 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 249 additions & 27 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = [
"crates/prover",
"crates/fixtures",
]
exclude = ["bench-arkworks"]
exclude = ["bench-arkworks", "experiments/keccacheck-arkworks"]

[workspace.package]
version = "0.1.0"
Expand Down
48 changes: 48 additions & 0 deletions EXPERIMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Combined candidate with constructed terminal leaf

Parent: `opt/combined-candidate` (`902ad3e`), 8,396,989 constraints.

This branch integrates a finite family of canonically constructed receipt-trie
leaves into the combined receipt/header candidate. The circuit constructs the
leaf from the already-bound key remainder and receipt, rather than accepting a
raw terminal-node witness and generically parsing and copying its value.

## Result

| Metric | Baseline | Parent combined | This branch |
|---|---:|---:|---:|
| MPT traversal | 6,722,724 | 6,634,340 | 3,304,933 |
| Full relation | 10,426,684 | 8,396,989 | 5,061,149 |
| Reduction from baseline | — | 19.5% | **51.5%** |

The terminal construction supports every remaining path length for the
three-byte key bound, not only the common empty path. Ancestor buffers use
structural maxima: 308 bytes for an active root branch and 532 bytes for a
fully occupied deeper branch. A root leaf is represented by zero ancestors.

The shape Boolean is an untrusted witness hint: it only selects whether the
complete 17-item branch decoder or complete two-item extension decoder must
pass. The wrong hint cannot bypass either decoder.

## Fast verification

- All seven remaining-path layouts match native RLP and Keccak.
- Genuine branch-to-leaf, extension, and root-leaf shapes satisfy.
- Wrong root, key, receipt, ancestor, extension path, and appended-node cases
reject.
- Existing branch-as-short and short-as-branch decoder tests reject.
- The representative full relation satisfies at exactly 5,061,149 constraints.

## Feasibility

High for the current relation's existing depth-four and three-byte-key policy.
The witness API still carries a redundant raw terminal node which synthesis
ignores; remove it in a cleanup pass before merging. Full fixture and proving
tests remain final-candidate gates rather than iteration gates.

The native sequential-trie profiler also exposes a pre-existing coverage
limit: proof depth reaches 5 at 130 receipts, 6 at 273, and 7 near 1,022. The
current depth-four circuit is therefore already a coverage tier, despite its
three-byte key buffer. Conversely, a one-byte transaction-index key has a
structural maximum of two branch ancestors and no extensions; that narrower
tier is measured separately rather than silently folded into this branch.
39 changes: 39 additions & 0 deletions UNIVERSAL_MPT_OPTIMIZATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Universal in-circuit MPT tier

Branch: `opt/universal-depth-7-constructed-leaf`

This is the universal circuit/VK candidate under the existing explicit bounds:

- canonical receipt-trie key at most three bytes (transaction index below
65,536), hence at most six key nibbles;
- receipt at most 448 bytes;
- header at most 704 bytes;
- structurally bounded root and deeper MPT nodes.

Each branch consumes one key nibble and each extension consumes at least one.
Therefore a six-nibble key admits at most six ancestor nodes followed by the
constructed terminal leaf, for a maximum compiled depth of seven. All unused
slots are constrained inert, but R1CS still pays their Keccak and decoder cost.

The entire Ethereum authentication chain remains inside the circuit: full
header Keccak, receipts-root extraction, every MPT Keccak/RLP/path link,
terminal-leaf construction, receipt semantics, intent opening, and statement
hashing.

## Why ordinary preprocessing cannot shorten the proof

An MPT node authenticates only its immediate child reference. Removing an
intermediate node also removes the Keccak equation connecting the parent hash
to the descendant. Off-circuit offsets, decoded shapes, or intermediate hashes
are only hints; the circuit must recompute and constrain every omitted link.

A genuinely constant-depth input would require a succinct proof attesting to
the omitted links, or an independently authenticated non-MPT commitment. The
former is a recursive/folding architecture and the latter is not supplied by
Ethereum's current receipt commitment. Neither is a preprocessing-only change
to this Groth16 relation.

Fast verification uses exact synthesis/profile counts, one representative
satisfying relation, adversarial gadget tests already shared with the parent,
and workspace compilation. Full setup/proving/EVM export remains a finalist
gate.
12 changes: 6 additions & 6 deletions contracts/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ contract Verifier {
uint256 constant DELTA_NEG_Y_1 = 19257957324113511611720790992651491173029981678335866461361133554601815821372;

// Constant and public input points
uint256 constant CONSTANT_X = 16208839724471277216601460661420983062276407618665006588326578935414763551635;
uint256 constant CONSTANT_Y = 9940980535099599717419533404020065535259107309790897410751122444250949482832;
uint256 constant PUB_0_X = 13140574417491532082542376956995810142852812141951714597942587116697734247084;
uint256 constant PUB_0_Y = 19437488196263352531732679871899443478925195370665642208888307033221185496979;
uint256 constant PUB_1_X = 12279282134251549331686514719497445837688998891797504738355585676440180297197;
uint256 constant PUB_1_Y = 1570097439651360812443069379342259804237432750561298171817028858121495635769;
uint256 constant CONSTANT_X = 15138933018800168104626208562752643351694693240728940576908099378077506127809;
uint256 constant CONSTANT_Y = 13440600505088464263913789249055128799319615219633549393247549586787259087349;
uint256 constant PUB_0_X = 17429719968351208872274701233868480357977279897948794222132726423007938649717;
uint256 constant PUB_0_Y = 16243863455167378616029873147049730070812431399223228044387392130975618122073;
uint256 constant PUB_1_X = 4292678073581155621200320656201434929785497837407533610793076027134243625633;
uint256 constant PUB_1_Y = 15639844169511816418353966019502957734362208535917293570815730516143903737786;

/// Negation in Fp.
/// @notice Returns a number x such that a + x = 0 in Fp.
Expand Down
8 changes: 4 additions & 4 deletions contracts/calldata.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
verifyProof(
[0x284d0ca267a6bcdec14f26b25dfefef12cdbff8037b01ddf5fadb4151f50afef, 0x2287ddd069fe92f847eb4a6a67d195a71bcf3fe62954d69101c4bb8829ebd743],
[[0x1c971d655685d85217ebb32974eefa561bc9d5d833ccd43499157fe898abf95b, 0x1f08f74d689ba70827301e355613a2919e91f35afaf904a24a04aad8e6df07c4], [0x065e219d3a630fe908520b14ef2f15a8353dda97586bcafaf0fe3d4b81972791, 0x2bf5690f0e9cff95de8a7468ff6026d72b85877446c58330b31c67eb94a497a1]],
[0x245129a75240bcd5621438310e91a169a397576b4072d7198df3d23713987f47, 0x2610b905d8e5c59b04ff012274231d2d12aa477d17124053a1f53c9f03f72f18],
[0xa2e1c2121f9af063923e7fecdcdab89e, 0xe82c46cd98b51c401ee16453967d0e0b]
[0x2ce1c0972184a6b47cb4cd25dc8ff88abfe797b19927bb8ae7de594b929c6bc6, 0x2f845012415f3bdc2a0f707d67a3494d18e17c49f07cea2cf736d5c623dee5b6],
[[0x2196511bc2eae46c3a22646730a48b417dd1cf809b220dc2735cfd83f9196bb0, 0x13624c8a626f9288aa7c50acb057b6d4a240db1cf8f93d7e44d227cb821021d2], [0x28735ab23f96cfa06e2fa035764426fa8c3a17f82347d8d2a4886877f88cfe91, 0x19836e95d5c9993d7b8dab32e5ee54b21105c6d2d1d96b355887464bde87a41a]],
[0x0d8d95904e20733d0c1e6f0dff0864a0543ea4d6286d30330ae76c35c150c87f, 0x264cee3f1ee8629a8b2b63c2765e3b0f0669f7438d08adba32724cf79deca00a],
[0x5ce039e6e0168697c1ee39fd592efdb1, 0x0273a75f1a45c7da3342430d209ab119]
)
18 changes: 9 additions & 9 deletions contracts/proof.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"proof": [
"0x284d0ca267a6bcdec14f26b25dfefef12cdbff8037b01ddf5fadb4151f50afef", "0x2287ddd069fe92f847eb4a6a67d195a71bcf3fe62954d69101c4bb8829ebd743",
"0x1c971d655685d85217ebb32974eefa561bc9d5d833ccd43499157fe898abf95b", "0x1f08f74d689ba70827301e355613a2919e91f35afaf904a24a04aad8e6df07c4", "0x065e219d3a630fe908520b14ef2f15a8353dda97586bcafaf0fe3d4b81972791", "0x2bf5690f0e9cff95de8a7468ff6026d72b85877446c58330b31c67eb94a497a1",
"0x245129a75240bcd5621438310e91a169a397576b4072d7198df3d23713987f47", "0x2610b905d8e5c59b04ff012274231d2d12aa477d17124053a1f53c9f03f72f18"
"0x2ce1c0972184a6b47cb4cd25dc8ff88abfe797b19927bb8ae7de594b929c6bc6", "0x2f845012415f3bdc2a0f707d67a3494d18e17c49f07cea2cf736d5c623dee5b6",
"0x2196511bc2eae46c3a22646730a48b417dd1cf809b220dc2735cfd83f9196bb0", "0x13624c8a626f9288aa7c50acb057b6d4a240db1cf8f93d7e44d227cb821021d2", "0x28735ab23f96cfa06e2fa035764426fa8c3a17f82347d8d2a4886877f88cfe91", "0x19836e95d5c9993d7b8dab32e5ee54b21105c6d2d1d96b355887464bde87a41a",
"0x0d8d95904e20733d0c1e6f0dff0864a0543ea4d6286d30330ae76c35c150c87f", "0x264cee3f1ee8629a8b2b63c2765e3b0f0669f7438d08adba32724cf79deca00a"
],
"publicSignals": ["0xa2e1c2121f9af063923e7fecdcdab89e", "0xe82c46cd98b51c401ee16453967d0e0b"],
"publicSignals": ["0x5ce039e6e0168697c1ee39fd592efdb1", "0x0273a75f1a45c7da3342430d209ab119"],
"statement": {
"instanceDomain": "0x1111111111111111111111111111111111111111111111111111111111111111",
"chainId": 1,
"escrow": "0x2222222222222222222222222222222222222222",
"escrow": "0x1c81a61a407017c58397a47d2ab28191b9b8ec9b",
"requestId": "0x3333333333333333333333333333333333333333333333333333333333333333",
"rowIndex": 0,
"intentCommitment": "0x187e649a78731c2dd46dc0c66cd13b2d06c78b5a81825efe17d51f6194aa46be",
"intentCommitment": "0xcecbba1151ca56f105982395b280672c18142a1e2d1a0b8dd569c4962982f860",
"bondAttempt": 1,
"bondStartBlock": 20999900,
"bondDeadline": 21000080,
"bondDeadline": 20999925,
"bondedCollector": "0x5555555555555555555555555555555555555555",
"rowPayoutAsset": "0x7777777777777777777777777777777777777777",
"rowPayoutAmount": "0x000000000000000000000000000000000000000000000000000000003b9aca00",
"witnessBlockNumber": 21000000,
"witnessBlockHash": "0xac9ad31ae5b5ab30cb08b4bc58b5baaff1a1747be050eb2ebfc1dc36348f95ee"
"witnessBlockNumber": 20999910,
"witnessBlockHash": "0x1d05fb8842f7f9f879a82357bcc0ec8e51d4cfdfcef3458d6d7660622f31d00a"
},
"note": "proof is [a.x, a.y, b.x1, b.x0, b.y1, b.y0, c.x, c.y]; the EVM pairing precompile takes G2 coordinates in that order, which is the reverse of arkworks' serialization. The statement block is what the escrow must reproduce from its own state for this proof to verify against it."
}
14 changes: 12 additions & 2 deletions crates/encoding/src/bin/gen_vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.iter()
.map(|(name, description, intent)| {
let v = IntentVector::from(intent);
Case { name, description, input: v.input, expected: v.expected }
Case {
name,
description,
input: v.input,
expected: v.expected,
}
})
.collect(),
};
Expand All @@ -42,7 +47,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.iter()
.map(|(name, description, statement)| {
let v = StatementVector::from(statement);
Case { name, description, input: v.input, expected: v.expected }
Case {
name,
description,
input: v.input,
expected: v.expected,
}
})
.collect(),
};
Expand Down
70 changes: 56 additions & 14 deletions crates/encoding/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,62 @@ mod tests {
// ever dropped from `preimage()`, this catches it.
let base = sample().hash();
let mutations: Vec<Statement> = vec![
Statement { instance_domain: [0x12; 32], ..sample() },
Statement { chain_id: 2, ..sample() },
Statement { escrow: [0x23; 20], ..sample() },
Statement { request_id: [0x34; 32], ..sample() },
Statement { row_index: 1, ..sample() },
Statement { intent_commitment: [0x45; 32], ..sample() },
Statement { bond_attempt: 2, ..sample() },
Statement { bond_start_block: 1001, ..sample() },
Statement { bond_deadline: 1181, ..sample() },
Statement { bonded_collector: [0x56; 20], ..sample() },
Statement { row_payout_asset: [0x01; 20], ..sample() },
Statement { row_payout_amount: [0x01; 32], ..sample() },
Statement { witness_block_number: 1101, ..sample() },
Statement { witness_block_hash: [0x67; 32], ..sample() },
Statement {
instance_domain: [0x12; 32],
..sample()
},
Statement {
chain_id: 2,
..sample()
},
Statement {
escrow: [0x23; 20],
..sample()
},
Statement {
request_id: [0x34; 32],
..sample()
},
Statement {
row_index: 1,
..sample()
},
Statement {
intent_commitment: [0x45; 32],
..sample()
},
Statement {
bond_attempt: 2,
..sample()
},
Statement {
bond_start_block: 1001,
..sample()
},
Statement {
bond_deadline: 1181,
..sample()
},
Statement {
bonded_collector: [0x56; 20],
..sample()
},
Statement {
row_payout_asset: [0x01; 20],
..sample()
},
Statement {
row_payout_amount: [0x01; 32],
..sample()
},
Statement {
witness_block_number: 1101,
..sample()
},
Statement {
witness_block_hash: [0x67; 32],
..sample()
},
];
assert_eq!(mutations.len(), 14, "one case per context field");
for (i, m) in mutations.iter().enumerate() {
Expand Down
25 changes: 20 additions & 5 deletions crates/encoding/src/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ pub fn intent_cases() -> Vec<(&'static str, &'static str, Intent)> {
(
"erc20_row_max_index",
"Row index 31, the largest valid index in a 32-row batch",
Intent { row_index: 31, ..base.clone() },
Intent {
row_index: 31,
..base.clone()
},
),
(
"native_row",
Expand Down Expand Up @@ -114,12 +117,18 @@ pub fn intent_cases() -> Vec<(&'static str, &'static str, Intent)> {
(
"amount_max",
"settlementAmount = 2^256 - 1, both limbs saturated",
Intent { settlement_amount: [0xff; 32], ..base.clone() },
Intent {
settlement_amount: [0xff; 32],
..base.clone()
},
),
(
"chain_id_large",
"chainId near 2^64 - 1, the widest value the circuit accepts",
Intent { chain_id: u64::MAX, ..base.clone() },
Intent {
chain_id: u64::MAX,
..base.clone()
},
),
]
}
Expand Down Expand Up @@ -153,12 +162,18 @@ pub fn statement_cases(commitment: crate::Bytes32) -> Vec<(&'static str, &'stati
(
"native_payout_attempt_two",
"Same row, second attempt: digest must differ from attempt one",
Statement { bond_attempt: 2, ..base.clone() },
Statement {
bond_attempt: 2,
..base.clone()
},
),
(
"erc20_payout",
"ERC-20 payout asset, exercising the asset field",
Statement { row_payout_asset: fill(0x90), ..base.clone() },
Statement {
row_payout_asset: fill(0x90),
..base.clone()
},
),
(
"block_numbers_wide",
Expand Down
35 changes: 27 additions & 8 deletions crates/fixtures/src/bin/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ const RPC: &str = "https://eth.drpc.org";

fn main() {
let args: Vec<String> = std::env::args().collect();
let count = arg(&args, "--count").and_then(|v| v.parse().ok()).unwrap_or(100usize);
let count = arg(&args, "--count")
.and_then(|v| v.parse().ok())
.unwrap_or(100usize);
let out = arg(&args, "--out").unwrap_or_else(|| "test/vectors/mainnet.json".into());
let rpc_url = arg(&args, "--rpc").unwrap_or_else(|| RPC.into());
// A prime stride spreads sampling rather than clustering in one period of
// activity. Kept small because free endpoints time out on blocks far from
// the tip; raise it against an archive node.
let stride: u64 = arg(&args, "--stride").and_then(|v| v.parse().ok()).unwrap_or(13);
let stride: u64 = arg(&args, "--stride")
.and_then(|v| v.parse().ok())
.unwrap_or(13);

let latest = match rpc(&rpc_url, "eth_blockNumber", vec![]) {
Ok(v) => u64::from_str_radix(v.as_str().unwrap_or("0x0").trim_start_matches("0x"), 16)
Expand All @@ -68,7 +72,11 @@ fn main() {
let want = (count - fixtures.len()).min(3);
match collect_block(&rpc_url, block, want) {
Ok(got) if !got.is_empty() => {
eprintln!(" block {block}: +{} (total {})", got.len(), fixtures.len() + got.len());
eprintln!(
" block {block}: +{} (total {})",
got.len(),
fixtures.len() + got.len()
);
fixtures.extend(got);
}
Ok(_) => {}
Expand Down Expand Up @@ -97,8 +105,14 @@ fn main() {
if let Some(s) = dataset.shape() {
eprintln!(" depth {} to {}", s.depth.0, s.depth.1);
eprintln!(" node bytes {} to {}", s.node_bytes.0, s.node_bytes.1);
eprintln!(" receipt bytes {} to {}", s.receipt_bytes.0, s.receipt_bytes.1);
eprintln!(" header bytes {} to {}", s.header_bytes.0, s.header_bytes.1);
eprintln!(
" receipt bytes {} to {}",
s.receipt_bytes.0, s.receipt_bytes.1
);
eprintln!(
" header bytes {} to {}",
s.header_bytes.0, s.header_bytes.1
);
eprintln!(" receipt types {:?}", s.types);
eprintln!("\nagainst the compiled bounds (node 544, key 4, receipt 1024, depth 4):");
report("depth", s.depth.1, 4);
Expand All @@ -114,7 +128,9 @@ fn report(name: &str, observed: usize, bound: usize) {
}

fn arg(args: &[String], name: &str) -> Option<String> {
args.iter().position(|a| a == name).and_then(|i| args.get(i + 1).cloned())
args.iter()
.position(|a| a == name)
.and_then(|i| args.get(i + 1).cloned())
}

fn rpc(url: &str, method: &str, params: Vec<Value>) -> Result<Value, String> {
Expand Down Expand Up @@ -144,10 +160,13 @@ fn rpc(url: &str, method: &str, params: Vec<Value>) -> Result<Value, String> {
Err(format!("{method} failed: {last}"))
}


fn collect_block(url: &str, number: u64, want: usize) -> Result<Vec<Fixture>, String> {
let tag = Value::String(format!("0x{number:x}"));
let block = rpc(url, "eth_getBlockByNumber", vec![tag.clone(), Value::Bool(false)])?;
let block = rpc(
url,
"eth_getBlockByNumber",
vec![tag.clone(), Value::Bool(false)],
)?;
let receipts = rpc(url, "eth_getBlockReceipts", vec![tag])?;
let receipts = receipts.as_array().ok_or("receipts not an array")?;
if receipts.is_empty() {
Expand Down
Loading
Loading