Skip to content

Commit c9a3887

Browse files
tizocdannywillems
authored andcommitted
docs(handover): Improvements to the proofs docs
1 parent 2a1d625 commit c9a3887

File tree

4 files changed

+113
-13
lines changed

4 files changed

+113
-13
lines changed

docs/handover/circuits.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,53 @@ production, not constraint generation. This means that while OpenMina can
88
produce proofs using existing circuits, it cannot generate the circuit
99
definitions themselves.
1010

11+
For an overview of the proof system implementation in `ledger/src/proofs/`, see
12+
[`ledger/src/proofs/summary.md`](../../ledger/src/proofs/summary.md).
13+
1114
## Architecture
1215

13-
### Witness-Only Implementation
16+
### Proof Generation Implementation and Limitations
17+
18+
The OpenMina codebase includes complete proof generation capabilities with one
19+
key limitation:
1420

15-
The OpenMina codebase includes:
21+
**What OpenMina Can Do:**
1622

1723
- **Witness generation**: Full implementation for producing witnesses needed for
1824
proof generation
19-
- **Proof production**: Capability to create proofs using pre-existing circuit
20-
definitions
21-
- **Constraint generation**: NOT implemented - circuits must be generated
22-
externally
23-
24-
Due to time constraints during development, constraint generation was not ported
25-
to OpenMina. As a result, circuits must be generated using the original OCaml
26-
implementation.
25+
- **Proof production**: Complete capability to create proofs using pre-existing
26+
circuit definitions
27+
- **Circuit logic**: Equivalent to the OCaml implementation for all proof types
28+
- **Proof verification**: Can verify proofs using precomputed verification
29+
indices
30+
31+
**What OpenMina Cannot Do:**
32+
33+
- **Circuit constraints**: Missing the constraint declarations from the OCaml
34+
code that define circuit structure
35+
- **Constraint compilation/evaluation**: Missing the functionality to
36+
compile/evaluate constraint declarations into circuit constraints
37+
- **Verification key generation**: Cannot generate verification keys for new
38+
circuits
39+
40+
**Practical Implications:**
41+
42+
- Can generate proofs and witnesses for existing circuits
43+
- Cannot create new circuits or modify existing circuit definitions
44+
- Relies on OCaml implementation for all circuit creation and constraint
45+
processing
46+
- Uses precomputed verification indices from the OCaml implementation
47+
48+
The circuit logic is equivalent to the OCaml implementation except both the
49+
constraint declarations and the constraint compilation/evaluation functionality
50+
are missing - these were not ported due to time constraints during development,
51+
not technical limitations, and could be added for full independence.
2752

2853
### Circuit Generation Process
2954

30-
Since OpenMina cannot generate circuits, the raw circuit data must be produced
31-
using the OCaml implementation from the original Mina codebase. This process
32-
involves:
55+
Since these constraint capabilities are missing, OpenMina requires externally
56+
generated circuit data. The following process describes how circuits are created
57+
and distributed using the original Mina codebase:
3358

3459
1. Using a custom branch in the OpenMina fork of Mina:
3560
https://github.com/openmina/mina

docs/handover/component-summaries.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ technical debt analysis and implementation notes.
1111
- [summary.md](../../core/summary.md)
1212
- **ledger/**
1313
- [summary.md](../../ledger/summary.md)
14+
- **src/**
15+
- **proofs/**
16+
- [summary.md](../../ledger/src/proofs/summary.md)
1417
- **node/**
1518
- **src/**
1619
- [summary.md](../../node/src/summary.md)

docs/handover/ledger-crate.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ Note: The crate implements witness generation for circuits but not the
7777
constraint generation, so circuits cannot be fully generated from this crate
7878
alone.
7979

80+
For detailed technical information about the proof system implementation, see
81+
[`ledger/src/proofs/summary.md`](../../ledger/src/proofs/summary.md).
82+
8083
**zkApp Support** (`src/zkapps/`)
8184

8285
- Full zkApp transaction processing

ledger/src/proofs/summary.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Proofs Module Summary
2+
3+
The proofs module handles zero-knowledge proof generation and verification for
4+
the Mina protocol using the Kimchi proof system. The implementation has proven
5+
to work reliably on devnet but contains many TODOs and probably cleanup.
6+
7+
## Quick Reference
8+
9+
**Core Proof Types**
10+
11+
- `transaction.rs` - Transaction verification with witness generation
12+
- `block.rs` - Blockchain state transitions with consensus validation
13+
- `merge.rs` - Combining multiple transaction proofs
14+
- `zkapp.rs` - Smart contract execution proofs with authorization types
15+
16+
**Infrastructure**
17+
18+
- `witness.rs` - Witness data management (primary/auxiliary)
19+
- `caching.rs` - Verifier index and SRS caching
20+
- `constants.rs` - Circuit sizes and domain configurations
21+
- `step.rs`/`wrap.rs` - Step/wrap proof pattern for recursion
22+
23+
## Implementation
24+
25+
**Kimchi Integration**
26+
27+
- Type aliases in `mod.rs` directly use Kimchi types for verifier/prover indices
28+
and proofs
29+
- Circuit constraints and field operations built on Kimchi foundations
30+
- Maintains compatibility with Mina protocol proof formats
31+
- Uses a fork of proof-systems that is based on an older version than currently
32+
used by OCaml implementation
33+
- Uses a fork of arkworks to considerably speed up field operations on WASM
34+
- See [#1106](https://github.com/o1-labs/openmina/issues/1106) for details on
35+
these forks
36+
37+
**Performance Features**
38+
39+
- Caching system stores verifier indices and SRS data in `$HOME/.cache/openmina`
40+
- Circuit blobs for external circuit data fetching
41+
- Precomputed verification indices for devnet/mainnet in `data/` directory
42+
43+
**Pickles Recursive Proof System**
44+
45+
- The entire proofs module implements Pickles (recursive proof composition
46+
system)
47+
- `step.rs`/`wrap.rs` provide the fundamental step/wrap recursion pattern
48+
- `public_input/prepared_statement.rs` handles different recursion levels (N0,
49+
N1, N2)
50+
51+
**Witness vs Circuit Split**
52+
53+
- Witness generation handled in `witness.rs` with comparison functionality for
54+
OCaml compatibility testing
55+
- Circuit logic implemented but lacks constraint declarations and
56+
compilation/evaluation functionality
57+
- Uses precomputed verification indices from `data/` directory
58+
59+
For details on missing constraint functionality and circuit management, see
60+
[`docs/handover/circuits.md`](../../../docs/handover/circuits.md).
61+
62+
## Known Issues
63+
64+
**Incomplete Functionality**
65+
66+
- Joint combiner functionality has TODO items in `step.rs`
67+
- Feature flag handling incomplete in some verification paths
68+
- ZkApp call stack hash computation needs completion
69+
- Some field type conversions marked as temporary hacks

0 commit comments

Comments
 (0)