# blockstreamresearch/rust-simplicity architecture

> Architecture diagram of the GitHub repository blockstreamresearch/rust-simplicity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/blockstreamresearch/rust-simplicity
- Repository: https://github.com/blockstreamresearch/rust-simplicity

## Overview

rust-simplicity is a Rust library for constructing, analyzing, encoding, and executing typed Simplicity programs. Its central workflow progresses from incomplete construction nodes, through committed programs, to redeemed programs with witness data; redeemed programs can be encoded or run on the Bit Machine. Supporting layers provide type inference, Merkle commitments, cost analysis, human-readable parsing, policy satisfaction, and optimized C jets. The graph follows documented capabilities and source-index references; some subsystem wiring is not sampled, so uncertain links are omitted.

Main entry points: [`src/node/mod.rs`](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/mod.rs) (Node operations), [`src/bit_machine/mod.rs`](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/bit_machine/mod.rs) (Bit Machine), [`src/jet/mod.rs`](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/mod.rs) (Jet interface), [`src/node/redeem.rs`](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/redeem.rs) (Redemption nodes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Program authoring"]
  node_construct["Construction nodes<br/>[construct.rs]"]
  node_commit["Commitment nodes<br/>[commit.rs]"]
  node_redeem["Redemption nodes<br/>[redeem.rs]"]
  node_human["Human encoding<br/>[mod.rs]"]
  node_parser["Human parser<br/>[mod.rs]"]
end

subgraph group_representation["Program representation"]
  node_nodecore["Node operations<br/>[mod.rs]"]
  node_types["Types and inference<br/>[mod.rs]"]
  node_dag["DAG traversal<br/>[dag.rs]"]
  node_values["Values and witnesses<br/>[value.rs]"]
  node_encoding["Bit encoding<br/>[encode.rs]"]
  node_merkle["Merkle commitments<br/>[cmr.rs]"]
end

subgraph group_execution["Execution and analysis"]
  node_analysis["Cost analysis<br/>[analysis.rs]"]
  node_machine["Bit Machine<br/>[mod.rs]"]
end

subgraph group_integrations["Jets and policy"]
  node_jets["Jet interface<br/>[mod.rs]"]
  node_corejets["Core jet set<br/>[core.rs]"]
  node_elementsjets["Elements jet set<br/>[elements.rs]"]
  node_policy["Policy satisfaction<br/>[satisfy.rs]"]
  node_cffi["C jet FFI<br/>[ffi.rs]"]
end

node_developer(("Program developer"))

node_developer -->|"builds"| node_construct
node_construct -.->|"finalizes"| node_commit
node_commit -->|"adds witnesses"| node_redeem
node_developer -->|"writes or reads"| node_human
node_human -->|"parses with"| node_parser
node_parser -->|"builds nodes"| node_construct
node_nodecore -->|"uses"| node_types
node_nodecore -->|"uses"| node_dag
node_nodecore -->|"uses"| node_analysis
node_nodecore -->|"uses"| node_values
node_nodecore -->|"uses"| node_jets
node_redeem -->|"executes with"| node_machine
node_redeem -->|"encodes with"| node_encoding
node_redeem -->|"analyzes with"| node_analysis
node_machine -->|"dispatches"| node_jets
node_machine -->|"checks bounds"| node_analysis
node_machine -.->|"reads and returns"| node_values
node_jets -->|"provides"| node_corejets
node_jets -->|"provides"| node_elementsjets
node_jets -.->|"calls optimized jets"| node_cffi
node_policy -->|"uses for satisfaction"| node_machine
node_policy -->|"uses"| node_encoding
node_merkle -->|"uses type data"| node_types
node_encoding -.->|"encodes values"| node_values

click node_construct "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/construct.rs"
click node_commit "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/commit.rs"
click node_redeem "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/redeem.rs"
click node_human "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/human_encoding/mod.rs"
click node_parser "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/human_encoding/parse/mod.rs"
click node_nodecore "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/mod.rs"
click node_types "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/types/mod.rs"
click node_dag "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/dag.rs"
click node_values "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/value.rs"
click node_encoding "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/bit_encoding/encode.rs"
click node_merkle "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/merkle/cmr.rs"
click node_analysis "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/analysis.rs"
click node_machine "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/bit_machine/mod.rs"
click node_jets "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/mod.rs"
click node_corejets "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/init/core.rs"
click node_elementsjets "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/init/elements.rs"
click node_policy "https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/policy/satisfy.rs"
click node_cffi "https://github.com/blockstreamresearch/rust-simplicity/blob/master/simplicity-sys/src/ffi.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_construct,node_commit,node_redeem,node_human,node_parser toneBlue
class node_nodecore,node_types,node_dag,node_values,node_encoding,node_merkle toneAmber
class node_analysis,node_machine toneMint
class node_jets,node_corejets,node_elementsjets,node_policy,node_cffi toneRose
class node_developer toneIndigo
```

## Components

### Program authoring

- [Construction nodes](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/construct.rs): `src/node/construct.rs`
- [Commitment nodes](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/commit.rs): `src/node/commit.rs`
- [Redemption nodes](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/redeem.rs): `src/node/redeem.rs`
- [Human encoding](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/human_encoding/mod.rs): `src/human_encoding/mod.rs`
- [Human parser](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/human_encoding/parse/mod.rs): `src/human_encoding/parse/mod.rs`

### Program representation

- [Node operations](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/node/mod.rs): `src/node/mod.rs`
- [Types and inference](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/types/mod.rs): `src/types/mod.rs`
- [DAG traversal](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/dag.rs): `src/dag.rs`
- [Values and witnesses](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/value.rs): `src/value.rs`
- [Bit encoding](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/bit_encoding/encode.rs): `src/bit_encoding/encode.rs`
- [Merkle commitments](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/merkle/cmr.rs): `src/merkle/cmr.rs`

### Execution and analysis

- [Cost analysis](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/analysis.rs): `src/analysis.rs`
- [Bit Machine](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/bit_machine/mod.rs): `src/bit_machine/mod.rs`

### Jets and policy

- [Jet interface](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/mod.rs): `src/jet/mod.rs`
- [Core jet set](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/init/core.rs): `src/jet/init/core.rs`
- [Elements jet set](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/jet/init/elements.rs): `src/jet/init/elements.rs`
- [Policy satisfaction](https://github.com/blockstreamresearch/rust-simplicity/blob/master/src/policy/satisfy.rs): `src/policy/satisfy.rs`
- [C jet FFI](https://github.com/blockstreamresearch/rust-simplicity/blob/master/simplicity-sys/src/ffi.rs): `simplicity-sys/src/ffi.rs`

### Other components

- **Program developer**

## Connections

- Program developer → Construction nodes: builds (evidence: `README.md`)
- Construction nodes → Commitment nodes: finalizes
- Commitment nodes → Redemption nodes: adds witnesses (evidence: `README.md`)
- Program developer → Human encoding: writes or reads (evidence: `README.md`)
- Human encoding → Human parser: parses with (evidence: `src/human_encoding/mod.rs`)
- Human parser → Construction nodes: builds nodes (evidence: `src/human_encoding/parse/mod.rs`)
- Node operations → Types and inference: uses (evidence: `src/node/mod.rs`)
- Node operations → DAG traversal: uses (evidence: `src/node/mod.rs`)
- Node operations → Cost analysis: uses (evidence: `src/node/mod.rs`)
- Node operations → Values and witnesses: uses (evidence: `src/node/mod.rs`)
- Node operations → Jet interface: uses (evidence: `src/node/mod.rs`)
- Redemption nodes → Bit Machine: executes with (evidence: `src/node/redeem.rs`)
- Redemption nodes → Bit encoding: encodes with (evidence: `src/node/redeem.rs`)
- Redemption nodes → Cost analysis: analyzes with (evidence: `src/node/redeem.rs`)
- Bit Machine → Jet interface: dispatches (evidence: `src/bit_machine/mod.rs`)
- Bit Machine → Cost analysis: checks bounds (evidence: `src/bit_machine/mod.rs`)
- Bit Machine → Values and witnesses: reads and returns
- Jet interface → Core jet set: provides (evidence: `src/jet/mod.rs`)
- Jet interface → Elements jet set: provides (evidence: `src/jet/mod.rs`)
- Jet interface → C jet FFI: calls optimized jets (evidence: `README.md`)
- Policy satisfaction → Bit Machine: uses for satisfaction (evidence: `src/policy/satisfy.rs`)
- Policy satisfaction → Bit encoding: uses (evidence: `src/policy/satisfy.rs`)
- Merkle commitments → Types and inference: uses type data (evidence: `src/merkle/cmr.rs`)
- Bit encoding → Values and witnesses: encodes values
