| Crates.io | simplicity-lang |
| lib.rs | simplicity-lang |
| version | 0.6.0 |
| created_at | 2024-01-29 22:07:30.875613+00 |
| updated_at | 2025-09-22 16:06:24.940886+00 |
| description | General purpose library for processing Simplicity programs |
| homepage | https://github.com/BlockstreamResearch/rust-simplicity/ |
| repository | https://github.com/BlockstreamResearch/rust-simplicity/ |
| max_upload_size | |
| id | 1119398 |
| size | 2,099,243 |
This is the official Rust library of the Simplicity Language.
Simplicity is a low-level, typed functional language designed to be a drop-in alternative for Bitcoin's Tapscript. It offers static resource bounds and has a formal specification (in Rocq) which allows the creation of machine-checkable proofs of program behavior.
It is currently deployed on Blockstream's Liquid, which is a sidechain resembling Bitcoin in many ways; but which differs in many Script-relevant ways (e.g. supporting multiple assets and using Confidential Transactions). We expect by the end of 2025 to directly support Bitcoin, so that Simplicity can be used on a custom regtest chain.
Simplicity is a very low-level language. If you are simply looking to develop with the language, you may wish to use SimplicityHL instead.
The goal of rust-simplicity is to provide the tools to encode, decode, analyze, construct and manipulate Simplicity programs at all stages of development. These stages are:
ConstructNode
type.CommitNodeRedeemNodeGenerally speaking, the process of producing a Simplicity program involves moving from one node type to the next.
To use rust-simplicity, this to your Cargo.toml:
[dependencies]
simplicity-lang = "0.5"
use simplicity::node::CoreConstructible;
use simplicity::types::Context;
use simplicity::{ConstructNode, jet::Core};
use std::sync::Arc;
// Create a trivial Simplicity program
let program = Context::with_context(|ctx| {
let construct = Arc::<ConstructNode<Core>>::unit(&ctx);
construct.finalize_types().unwrap()
});
// Encode the program to bytes
let encoded: Vec<u8> = simplicity::write_to_vec(|w| {
program.encode_without_witness(w)
});
This Rust library provides extensive tools for program construction and analysis, while libsimplicity is a minimal C library focused solely on decoding, validating, and executing programs in blockchain consensus code.
rust-simplicity includes a vendored copy of libsimplicity and uses it for:
The libsimplicity repository also contains:
The goals of this library are to support the low-level Simplicity language, and to provide a basis for the SimplicityHL language implementation. If you wish to work on high-level programming language abstractions, you may want to visit that repo instead.
Having said that, contributions are welcome! This library is in its early stages and undergoing rapid development. We especially welcome improvements in:
The MSRV of this crate is 1.74.0. For now we will not increase this without a major version bump, though as the library matures we may change that policy.
This library includes a vendored copy of the libsimplicity C library, as well as
files generated by the GenRustJets utility from the libsimplicity Haskell library.
These files are clearly marked as being autogenerated, and may not be directly
changed.
Instead, to update this code you must use the included vendor-simplicity.sh and
update_jets.sh scripts.
update_jets.sh requires the user has cabal and all dependencies of the libsimplicity
Haskell library. Instructions for those can be found in the simplicity repository.
There are two sets of benchmarks in this codebase. First, there is the jets-bench
sub-crate which uses criterion to collect statistics about jet performance. These
benchmarks are specifically targeted at the C jets and are intended to estimate
consensus costs.
See jets-bench/README.md for information about running these benchmarks.
The second set of benchmarks are benchmarks for this library's performance. These are used to track performance of this library itself. These can be run with
RUSTFLAGS=--cfg=bench cargo +nightly bench
The custom cfg flag is used to prevent nightly-only code from polluting ordinary
code.