pub struct CoreLibrary { /* private fields */ }Expand description
The Miden core library, providing a set of optimized procedures for Miden programs.
This library wraps the miden-core Package and its miden-precompiles runtime dependency.
When the core library is dynamically linked during assembly time, procedures can be called from
any Miden program and are serialized as 32 bytes, reducing the amount of code that needs to be
shared between parties for proving and verifying program execution.
§Contents
The core library provides several categories of functionality:
- Cryptographic primitives: Poseidon2, Blake3, SHA-256, Falcon signature verification,
authenticated encryption (AEAD decryption), and stable core facades for bundled deferred
precompiles under
::miden::core::*. - Mathematical operations: Division operations for u64, u128, and u256.
- Data structures: Sparse Merkle Tree operations, Merkle Mountain Range (MMR), and sorted array utilities with lower-bound search capabilities.
- Memory operations: Efficient hashing and “un-hashing” of large amounts of data.
§Usage
The core library is typically used with the assembler to enable core library procedures in compiled programs:
use miden_assembly::{Assembler, Linkage};
use miden_core_lib::CoreLibrary;
let core_lib = CoreLibrary::default();
let mut assembler = Assembler::new(source_manager);
for package in core_lib.packages() {
assembler.link_package(package, Linkage::Dynamic).unwrap();
}For program execution, you’ll also need to register the event handlers:
let handlers = core_lib.handlers();
// Register handlers with your host...Stack and memory print-style debug handlers are registered with stdout writers by default. These handlers can print private values if a program moves witness data onto the operand stack or into memory. Privacy-sensitive hosts should replace or unregister these handlers. Advice debug handlers can expose witness data directly, so hosts must opt into those explicitly.