Standard library for SimplicityHL, a high-level language that compiles to Simplicity.
| File | Contents |
|---|---|
src/lib.simf |
Boolean helpers: not, or, assert_zero |
src/u4.simf – src/u256.simf |
Arithmetic for unsigned integer widths (auto-generated) |
src/types.simf |
Equality functions for Elements domain types (auto-generated) |
src/timelocks.simf |
enforce_relative_distance / enforce_relative_duration |
For each width N, the following functions are generated:
safe_add_N / checked_add_N — addition, panics or returns Option on overflow
safe_sub_N / checked_sub_N — subtraction, panics or returns Option on underflow
safe_multiply_N / checked_multiply_N — multiplication (u4–u128 only)
saturating_add_N — addition clamped to MAX on overflow
eq_N — equality comparison
Equality functions for Elements / Simplicity types: Amount1, Asset1, Confidential1, Fe, Ge, Gej, Height, Lock, Message, Message64, Nonce, Outpoint, Point, Pubkey, Scalar, Signature, Time, and more.
Running ./build.ps1 produces two ready-to-use single-file bundles from the sources:
| Path | Description |
|---|---|
dist/mcpp/std.simf.inc |
All sources concatenated with #ifndef include guards — drop this into any project using the C preprocessor |
dist/lib/std.simf |
Same content, but every function is pub fn — intended for use as a library dependency |
The arithmetic and domain-type files are auto-generated by Haskell scripts. Do not edit them directly.
| Script | Does |
|---|---|
codegen/Main.hs |
Generates std/src/u*.simf and std/src/types.simf |
codegen/Bundle.hs |
Reads all std/src/*.simf and writes the two dist bundles |
build.ps1 |
Runs both of the above (requires Docker, no local GHC needed) |
generate.ps1 |
Runs codegen only, skips bundling |
./build.ps1- Docker (for the Haskell codegen —
haskell:9.6image) - A SimplicityHL compiler to actually use the
.simffiles