miden_core/
lib.rs

1#![no_std]
2
3#[macro_use]
4extern crate alloc;
5
6#[cfg(feature = "std")]
7extern crate std;
8
9/// This is an implementation of `std::assert_matches::assert_matches`
10/// so it can be removed when that feature stabilizes upstream
11#[macro_export]
12macro_rules! assert_matches {
13    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
14        match $left {
15            $( $pattern )|+ $( if $guard )? => {}
16            ref left_val => {
17                panic!(r#"
18assertion failed: `(left matches right)`
19    left: `{:?}`,
20    right: `{}`"#, left_val, stringify!($($pattern)|+ $(if $guard)?));
21            }
22        }
23    };
24
25    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $msg:literal $(,)?) => {
26        match $left {
27            $( $pattern )|+ $( if $guard )? => {}
28            ref left_val => {
29                panic!(concat!(r#"
30assertion failed: `(left matches right)`
31    left: `{:?}`,
32    right: `{}`
33"#, $msg), left_val, stringify!($($pattern)|+ $(if $guard)?));
34            }
35        }
36    };
37
38    ($left:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )?, $msg:literal, $($arg:tt)+) => {
39        match $left {
40            $( $pattern )|+ $( if $guard )? => {}
41            ref left_val => {
42                panic!(concat!(r#"
43assertion failed: `(left matches right)`
44    left: `{:?}`,
45    right: `{}`
46"#, $msg), left_val, stringify!($($pattern)|+ $(if $guard)?), $($arg)+);
47            }
48        }
49    }
50}
51
52pub mod chiplets;
53pub mod errors;
54
55mod program;
56pub use program::{Program, ProgramInfo};
57
58mod kernel;
59pub use kernel::Kernel;
60pub use miden_crypto::{EMPTY_WORD, ONE, WORD_SIZE, Word, ZERO, word::LexicographicWord};
61pub mod crypto {
62    pub mod merkle {
63        pub use miden_crypto::merkle::{
64            DefaultMerkleStore, EmptySubtreeRoots, InnerNodeInfo, LeafIndex, MerkleError,
65            MerklePath, MerkleStore, MerkleTree, Mmr, MmrPeaks, NodeIndex, PartialMerkleTree,
66            RecordingMerkleStore, SMT_DEPTH, SimpleSmt, Smt, SmtProof, SmtProofError, StoreNode,
67        };
68    }
69
70    pub mod hash {
71        pub use miden_crypto::hash::{
72            Digest, ElementHasher, Hasher,
73            blake::{Blake3_160, Blake3_192, Blake3_256, Blake3Digest},
74            rpo::Rpo256,
75            rpx::Rpx256,
76        };
77    }
78
79    pub mod random {
80        pub use miden_crypto::rand::{
81            RandomCoin, RandomCoinError, RpoRandomCoin, RpxRandomCoin, WinterRandomCoin,
82        };
83    }
84
85    pub mod dsa {
86        pub use miden_crypto::dsa::rpo_falcon512;
87    }
88}
89
90pub mod mast;
91
92pub use winter_math::{
93    ExtensionOf, FieldElement, StarkField, ToElements,
94    fields::{QuadExtension, f64::BaseElement as Felt},
95    polynom,
96};
97pub type QuadFelt = QuadExtension<Felt>;
98
99pub mod prettier {
100    pub use miden_formatting::{prettier::*, pretty_via_display, pretty_via_to_string};
101
102    /// Pretty-print a list of [PrettyPrint] values as comma-separated items.
103    pub fn pretty_print_csv<'a, T>(items: impl IntoIterator<Item = &'a T>) -> Document
104    where
105        T: PrettyPrint + 'a,
106    {
107        let mut doc = Document::Empty;
108        for (i, item) in items.into_iter().enumerate() {
109            if i > 0 {
110                doc += const_text(", ");
111            }
112            doc += item.render();
113        }
114        doc
115    }
116}
117
118mod operations;
119pub use operations::{
120    AssemblyOp, DebugOptions, Decorator, DecoratorIterator, DecoratorList, Operation,
121    opcode_constants::*,
122};
123
124pub mod stack;
125pub use stack::{StackInputs, StackOutputs};
126
127pub mod sys_events;
128
129mod advice;
130pub use advice::map::AdviceMap;
131
132pub mod utils;