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 debuginfo;
54pub mod errors;
55
56mod program;
57pub use program::{Program, ProgramInfo};
58
59mod kernel;
60pub use kernel::Kernel;
61pub use miden_crypto::{Word, EMPTY_WORD, ONE, WORD_SIZE, ZERO};
62pub mod crypto {
63    pub mod merkle {
64        pub use miden_crypto::merkle::{
65            DefaultMerkleStore, EmptySubtreeRoots, InnerNodeInfo, LeafIndex, MerkleError,
66            MerklePath, MerkleStore, MerkleTree, Mmr, MmrPeaks, NodeIndex, PartialMerkleTree,
67            RecordingMerkleStore, SimpleSmt, Smt, SmtProof, SmtProofError, StoreNode, SMT_DEPTH,
68        };
69    }
70
71    pub mod hash {
72        pub use miden_crypto::hash::{
73            blake::{Blake3Digest, Blake3_160, Blake3_192, Blake3_256},
74            rpo::{Rpo256, RpoDigest},
75            rpx::{Rpx256, RpxDigest},
76            Digest, ElementHasher, Hasher,
77        };
78    }
79
80    pub mod random {
81        pub use miden_crypto::rand::{
82            RandomCoin, RandomCoinError, RpoRandomCoin, RpxRandomCoin, WinterRandomCoin,
83        };
84    }
85
86    pub mod dsa {
87        pub use miden_crypto::dsa::rpo_falcon512;
88    }
89}
90
91pub mod mast;
92
93pub use math::{
94    fields::{f64::BaseElement as Felt, QuadExtension},
95    polynom, ExtensionOf, FieldElement, StarkField, ToElements,
96};
97
98pub mod prettier {
99    pub use miden_formatting::{prettier::*, pretty_via_display, pretty_via_to_string};
100
101    /// Pretty-print a list of [PrettyPrint] values as comma-separated items.
102    pub fn pretty_print_csv<'a, T>(items: impl IntoIterator<Item = &'a T>) -> Document
103    where
104        T: PrettyPrint + 'a,
105    {
106        let mut doc = Document::Empty;
107        for (i, item) in items.into_iter().enumerate() {
108            if i > 0 {
109                doc += const_text(", ");
110            }
111            doc += item.render();
112        }
113        doc
114    }
115}
116
117mod operations;
118pub use operations::{
119    opcode_constants::*, AssemblyOp, DebugOptions, Decorator, DecoratorIterator, DecoratorList,
120    Operation, SignatureKind,
121};
122
123pub mod stack;
124pub use stack::{StackInputs, StackOutputs};
125
126pub mod sys_events;
127
128mod advice;
129pub use advice::map::AdviceMap;
130
131pub mod utils;