Skip to content

stringhandler/simplicity-std

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simp-std

Standard library for SimplicityHL, a high-level language that compiles to Simplicity.

What's in here

std/ — the standard library package

File Contents
src/lib.simf Boolean helpers: not, or, assert_zero
src/u4.simfsrc/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

Integer operations (u4 – u256)

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

Domain type equality (types.simf)

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.


Distributions (dist/)

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

Codegen

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

Dependencies

  • Docker (for the Haskell codegen — haskell:9.6 image)
  • A SimplicityHL compiler to actually use the .simf files

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors