Skip to content

Commit 6934a57

Browse files
committed
Merge #302: rewrite README.md
c8602cf rewrite README.md (Andrew Poelstra) Pull request description: With suggestions and rewording from Claude 4. The next PR will attempt to fill in the top-level library docs which appear on docs.rs, including more useful simple example programs. Top commit has no ACKs. Tree-SHA512: cfaeba995028264dd23fdbdba68e72979ab3854c355f487d8596caa73cb23f795703b1acb08ce5ec4d5b0922d0cc27cf6b4f14bb71c01d2c162650b022f58270
2 parents 74233f3 + c8602cf commit 6934a57

File tree

1 file changed

+126
-8
lines changed

1 file changed

+126
-8
lines changed

README.md

Lines changed: 126 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,137 @@
1-
![Build](https://github.com/apoelstra/rust-simplicity/workflows/Continuous%20integration/badge.svg)
1+
<p>
2+
<a href="https://crates.io/crates/simplicity-lang"><img alt="Crate Info" src="https://img.shields.io/crates/v/simplicity-lang.svg"/></a>
3+
<a href="https://github.com/BlockstreamResearch/rust-simplicity/blob/master/LICENSE"><img alt="CC0 1.0 Universal Licensed" src="https://img.shields.io/badge/license-CC0--1.0-blue.svg"/></a>
4+
<a href="https://github.com/BlockstreamResearch/rust-simplicity/actions?query=workflow%3AContinuous%20integration"><img alt="CI Status" src="https://img.shields.io/github/actions/workflow/status/BlockstreamResearch/rust-simplicity/main.yml"></a>
5+
<a href="https://docs.rs/simplicity-lang"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-simplicity_lang-green"/></a>
6+
</p>
27

38
# rust-simplicity
4-
Under development....
59

6-
# Minimum Supported Rust Version
10+
This is the official Rust library of the [Simplicity Language](https://simplicity-lang.org/).
711

8-
The MSRV of this crate is **1.78.0**.
12+
Simplicity is a low-level, typed functional language designed to be a drop-in alternative
13+
for Bitcoin's [Tapscript](https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki).
14+
It offers static resource bounds and has a formal specification (in Rocq) which allows the
15+
creation of machine-checkable proofs of program behavior.
916

10-
# Updating jets code
17+
It is currently deployed on Blockstream's Liquid, which is a sidechain resembling Bitcoin
18+
in many ways; but which differs in many Script-relevant ways (e.g. supporting multiple
19+
assets and using Confidential Transactions). We expect by the end of 2025 to directly
20+
support Bitcoin, so that Simplicity can be used on a custom regtest chain.
1121

12-
Some of the jet files in the library are auto-generated from Haskell code. These can be updated `update_jets.sh`. This requires the user has `cabal` and other necessary things that are required to build simplicity haskell. Instructions for those can be found in the simplicity repository.
22+
Simplicity is a very low-level language. If you are simply looking to develop with the
23+
language, you may wish to use [SimplicityHL](https://github.com/BlockstreamResearch/simplicityhl)
24+
instead.
1325

14-
This script also checks that the internal vendored version of simplicity has the same git hash as of the version from which we are auto-generating the code. If this is not the case, the script will fail. This is because we only vendor minimal required C simplicity code and not the entire simplicity repo.
26+
## rust-simplicity
1527

16-
# Benchmarking
28+
The goal of rust-simplicity is to provide the tools to encode, decode, analyze, construct
29+
and manipulate Simplicity programs at all stages of development. These stages are:
30+
31+
* **construction**, which is when a program is incomplete, and consists of a set of
32+
"Simplicity expressions" intended to be assembled into a full program. Such expressions
33+
are represented by the [`ConstructNode`](https://docs.rs/simplicity-lang/latest/simplicity/node/type.ConstructNode.html)
34+
type.
35+
* **commitment**, which is when a program is complete but has not been satisfied. At this
36+
point, it is possible to derive addressses and receive funds to them, but to spend
37+
those funds requires the generation of witness data. Such programs are represented
38+
by [`CommitNode`](https://docs.rs/simplicity-lang/latest/simplicity/node/type.CommitNode.html)
39+
* **redemption**, which is when a program has witness data attached. This is the only
40+
point at which a program may appear explicitly on the blockchain, and the only point
41+
at which the program has a canonical encoding. Such programs are represented by
42+
[`RedeemNode`](https://docs.rs/simplicity-lang/latest/simplicity/node/type.RedeemNode.html)
43+
44+
Generally speaking, the process of producing a Simplicity program involves moving
45+
from one node type to the next.
46+
47+
## Installation
48+
49+
To use rust-simplicity, this to your Cargo.toml:
50+
51+
```toml
52+
[dependencies]
53+
simplicity-lang = "0.5"
54+
```
55+
56+
## Quick Start
57+
58+
```rust
59+
use simplicity::node::CoreConstructible;
60+
use simplicity::types::Context;
61+
use simplicity::{ConstructNode, Core};
62+
use std::sync::Arc;
63+
64+
// Create a trivial Simplicity program
65+
let ctx = Context::new();
66+
let program = Arc::<ConstructNode<Core>>::unit(&ctx);
67+
68+
// Encode the program to bytes
69+
let encoded = simplicity::bit_encoding::write_to_vec(|w| {
70+
program.encode_without_witness(w)
71+
}).unwrap();
72+
```
73+
74+
## Relationship to libsimplicity
75+
76+
This Rust library provides extensive tools for program construction and analysis, while
77+
[libsimplicity](https://github.com/BlockstreamResearch/Simplicity) is a minimal C library
78+
focused solely on decoding, validating, and executing programs in blockchain consensus code.
79+
80+
rust-simplicity includes a vendored copy of libsimplicity and uses it for:
81+
82+
- cryptographic and other "heavy" operations through optimized C jets
83+
- cross-validating the C and Rust Bit Machine implementations
84+
85+
The libsimplicity repository also contains:
86+
- A reference implementation written in Haskell
87+
- A Rocq (Coq) implementation for formal verification and machine-checkable proofs
88+
89+
## Further Reading
90+
91+
- **[API Documentation](https://docs.rs/simplicity-lang/)** - Complete API reference
92+
- **[Simplicity Tech Report](https://github.com/BlockstreamResearch/simplicity/blob/pdf/Simplicity-TR.pdf)** - Full informal language specification
93+
- **[Simplicity Website](https://simplicity-lang.org/)** - Official language homepage
94+
- **[libsimplicity](https://github.com/BlockstreamResearch/Simplicity)** - Reference implementation
95+
96+
# Contributing
97+
98+
The goals of this library are to support the low-level Simplicity language, and to
99+
provide a basis for the [SimplicityHL](https://github.com/BlockstreamResearch/simplicityhl)
100+
language implementation. If you wish to work on high-level programming language
101+
abstractions, you may want to visit that repo instead.
102+
103+
Having said that, contributions are welcome! This library is in its early stages
104+
and undergoing rapid development. We especially welcome improvements in:
105+
106+
* representing and displaying type inference information and errors
107+
* representing and displaying information about Simplicity (sub)expressions;
108+
usefully and uniquely specifying subexpressions within larger expressions
109+
* improvements to the debuggability and introspection of the Bit Machine, the
110+
Simplicity interpreter.
111+
* testing, especially of programs that exhibit extreme behavior; improving test
112+
infrastructure and CI
113+
* improving the ergonomics and reliability of our vendoring scripts (see below)
114+
* documentation!
115+
116+
## Minimum Supported Rust Version
117+
118+
The MSRV of this crate is **1.78.0**. For now we will not increase this without
119+
a major version bump, though as the library matures we may change that policy.
120+
121+
## Updating libsimplicity
122+
123+
This library includes a vendored copy of the libsimplicity C library, as well as
124+
files generated by the `GenRustJets` utility from the libsimplicity Haskell library.
125+
These files are clearly marked as being autogenerated, and may not be directly
126+
changed.
127+
128+
Instead, to update this code you must use the included `vendor-simplicity.sh` and
129+
`update_jets.sh` scripts.
130+
131+
`update_jets.sh` requires the user has `cabal` and all dependencies of the libsimplicity
132+
Haskell library. Instructions for those can be found in the simplicity repository.
133+
134+
## Benchmarking
17135

18136
There are two sets of benchmarks in this codebase. First, there is the `jets-bench`
19137
sub-crate which uses criterion to collect statistics about jet performance. These

0 commit comments

Comments
 (0)