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::{EMPTY_WORD, ONE, WORD_SIZE, Word, 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, SMT_DEPTH, SimpleSmt, Smt, SmtProof, SmtProofError, StoreNode,
68        };
69    }
70
71    pub mod hash {
72        pub use miden_crypto::hash::{
73            Digest, ElementHasher, Hasher,
74            blake::{Blake3_160, Blake3_192, Blake3_256, Blake3Digest},
75            rpo::{Rpo256, RpoDigest},
76            rpx::{Rpx256, RpxDigest},
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    ExtensionOf, FieldElement, StarkField, ToElements,
95    fields::{QuadExtension, f64::BaseElement as Felt},
96    polynom,
97};
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    SignatureKind, 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;