diff --git a/CHANGELOG.md b/CHANGELOG.md index bf98f04722..f2d6013d99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ #### VM Internals - Removed unused `find_lone_leaf()` function from the Advice Provider (#1262). - [BREAKING] Changed fields type of the `StackOutputs` struct from `Vec` to `Vec` (#1268). +- [BREAKING] Migrated to `miden-crypto` v0.9.0 (#1287). ## 0.8.0 (02-26-2024) diff --git a/air/src/constraints/chiplets/bitwise/mod.rs b/air/src/constraints/chiplets/bitwise/mod.rs index c01e10f4d9..b5450e2066 100644 --- a/air/src/constraints/chiplets/bitwise/mod.rs +++ b/air/src/constraints/chiplets/bitwise/mod.rs @@ -5,9 +5,10 @@ use crate::{ BITWISE_A_COL_IDX, BITWISE_A_COL_RANGE, BITWISE_B_COL_IDX, BITWISE_B_COL_RANGE, BITWISE_OUTPUT_COL_IDX, BITWISE_PREV_OUTPUT_COL_IDX, BITWISE_SELECTOR_COL_IDX, }, - utils::{are_equal, binary_not, collections::*, is_binary, is_zero, EvaluationResult}, + utils::{are_equal, binary_not, is_binary, is_zero, EvaluationResult}, ONE, ZERO, }; +use alloc::vec::Vec; use winter_air::TransitionConstraintDegree; #[cfg(test)] diff --git a/air/src/constraints/chiplets/hasher/mod.rs b/air/src/constraints/chiplets/hasher/mod.rs index 17e4ecc211..e58828d80b 100644 --- a/air/src/constraints/chiplets/hasher/mod.rs +++ b/air/src/constraints/chiplets/hasher/mod.rs @@ -7,9 +7,10 @@ use crate::{ }, HASHER_NODE_INDEX_COL_IDX, HASHER_SELECTOR_COL_RANGE, HASHER_STATE_COL_RANGE, }, - utils::{are_equal, binary_not, collections::*, is_binary, EvaluationResult}, + utils::{are_equal, binary_not, is_binary, EvaluationResult}, ONE, ZERO, }; +use alloc::vec::Vec; #[cfg(test)] mod tests; diff --git a/air/src/constraints/chiplets/hasher/tests.rs b/air/src/constraints/chiplets/hasher/tests.rs index 5c278efc3b..c36219a655 100644 --- a/air/src/constraints/chiplets/hasher/tests.rs +++ b/air/src/constraints/chiplets/hasher/tests.rs @@ -4,9 +4,9 @@ use super::{ }; use crate::{ trace::chiplets::hasher::{Selectors, LINEAR_HASH, STATE_WIDTH}, - utils::collections::*, Felt, TRACE_WIDTH, }; +use alloc::vec::Vec; use rand_utils::rand_array; use vm_core::chiplets::hasher::apply_round; use winter_air::EvaluationFrame; diff --git a/air/src/constraints/chiplets/memory/mod.rs b/air/src/constraints/chiplets/memory/mod.rs index 159719428e..b4325c4a02 100644 --- a/air/src/constraints/chiplets/memory/mod.rs +++ b/air/src/constraints/chiplets/memory/mod.rs @@ -5,8 +5,9 @@ use crate::{ MEMORY_D0_COL_IDX, MEMORY_D1_COL_IDX, MEMORY_D_INV_COL_IDX, MEMORY_TRACE_OFFSET, MEMORY_V_COL_RANGE, }, - utils::{binary_not, collections::*, is_binary, EvaluationResult}, + utils::{binary_not, is_binary, EvaluationResult}, }; +use alloc::vec::Vec; use winter_air::TransitionConstraintDegree; #[cfg(test)] diff --git a/air/src/constraints/chiplets/memory/tests.rs b/air/src/constraints/chiplets/memory/tests.rs index 910aabf36d..868dcbdb47 100644 --- a/air/src/constraints/chiplets/memory/tests.rs +++ b/air/src/constraints/chiplets/memory/tests.rs @@ -9,7 +9,8 @@ use crate::trace::{ }, TRACE_WIDTH, }; -use crate::{chiplets::memory, utils::collections::*, Felt, FieldElement, ONE, ZERO}; +use crate::{chiplets::memory, Felt, FieldElement, ONE, ZERO}; +use alloc::vec::Vec; use rand_utils::rand_value; // UNIT TESTS diff --git a/air/src/constraints/chiplets/mod.rs b/air/src/constraints/chiplets/mod.rs index 7dc36f9d26..ec2772940f 100644 --- a/air/src/constraints/chiplets/mod.rs +++ b/air/src/constraints/chiplets/mod.rs @@ -1,7 +1,8 @@ use super::super::{ EvaluationFrame, Felt, FieldElement, TransitionConstraintDegree, CHIPLETS_OFFSET, }; -use crate::utils::{are_equal, binary_not, collections::*, is_binary}; +use crate::utils::{are_equal, binary_not, is_binary}; +use alloc::vec::Vec; mod bitwise; mod hasher; diff --git a/air/src/constraints/range.rs b/air/src/constraints/range.rs index 9b3a756a51..5459705ff5 100644 --- a/air/src/constraints/range.rs +++ b/air/src/constraints/range.rs @@ -2,9 +2,11 @@ use crate::{ chiplets::ChipletsFrameExt, constraints::MainFrameExt, trace::range::{B_RANGE_COL_IDX, M_COL_IDX, V_COL_IDX}, - utils::{are_equal, collections::*}, + utils::are_equal, Assertion, EvaluationFrame, Felt, FieldElement, TransitionConstraintDegree, }; +use alloc::vec::Vec; + use vm_core::{ExtensionOf, ZERO}; use winter_air::AuxTraceRandElements; diff --git a/air/src/constraints/stack/field_ops/mod.rs b/air/src/constraints/stack/field_ops/mod.rs index b2ec9981f3..bc4894e6ca 100644 --- a/air/src/constraints/stack/field_ops/mod.rs +++ b/air/src/constraints/stack/field_ops/mod.rs @@ -1,8 +1,9 @@ use super::{op_flags::OpFlags, EvaluationFrame, FieldElement, TransitionConstraintDegree}; use crate::{ stack::EvaluationFrameExt, - utils::{are_equal, collections::*, is_binary}, + utils::{are_equal, is_binary}, }; +use alloc::vec::Vec; #[cfg(test)] pub mod tests; diff --git a/air/src/constraints/stack/io_ops/mod.rs b/air/src/constraints/stack/io_ops/mod.rs index 3b6179289d..7f1c64f9c9 100644 --- a/air/src/constraints/stack/io_ops/mod.rs +++ b/air/src/constraints/stack/io_ops/mod.rs @@ -1,8 +1,6 @@ use super::{op_flags::OpFlags, EvaluationFrame, FieldElement, TransitionConstraintDegree}; -use crate::{ - stack::EvaluationFrameExt, - utils::{are_equal, collections::*}, -}; +use crate::{stack::EvaluationFrameExt, utils::are_equal}; +use alloc::vec::Vec; #[cfg(test)] pub mod tests; diff --git a/air/src/constraints/stack/mod.rs b/air/src/constraints/stack/mod.rs index e3fc571a2f..519ee89ac2 100644 --- a/air/src/constraints/stack/mod.rs +++ b/air/src/constraints/stack/mod.rs @@ -4,7 +4,8 @@ use super::super::{ STACK_AUX_TRACE_OFFSET, STACK_TRACE_OFFSET, ZERO, }; use crate::decoder::{IS_CALL_FLAG_COL_IDX, IS_SYSCALL_FLAG_COL_IDX, USER_OP_HELPERS_OFFSET}; -use crate::utils::{are_equal, collections::*, is_binary}; +use crate::utils::{are_equal, is_binary}; +use alloc::vec::Vec; use vm_core::{stack::STACK_TOP_SIZE, StackOutputs}; pub mod field_ops; diff --git a/air/src/constraints/stack/overflow/mod.rs b/air/src/constraints/stack/overflow/mod.rs index 32bd93093a..346bba5906 100644 --- a/air/src/constraints/stack/overflow/mod.rs +++ b/air/src/constraints/stack/overflow/mod.rs @@ -1,5 +1,6 @@ use super::{op_flags::OpFlags, EvaluationFrame, FieldElement, TransitionConstraintDegree}; -use crate::{stack::EvaluationFrameExt, utils::collections::*}; +use crate::stack::EvaluationFrameExt; +use alloc::vec::Vec; #[cfg(test)] pub mod tests; diff --git a/air/src/constraints/stack/stack_manipulation/mod.rs b/air/src/constraints/stack/stack_manipulation/mod.rs index 3fdee5cae0..4163633e56 100644 --- a/air/src/constraints/stack/stack_manipulation/mod.rs +++ b/air/src/constraints/stack/stack_manipulation/mod.rs @@ -1,8 +1,9 @@ use super::{op_flags::OpFlags, EvaluationFrame, FieldElement, TransitionConstraintDegree}; use crate::{ stack::EvaluationFrameExt, - utils::{are_equal, binary_not, collections::*}, + utils::{are_equal, binary_not}, }; +use alloc::vec::Vec; #[cfg(test)] pub mod tests; diff --git a/air/src/constraints/stack/system_ops/mod.rs b/air/src/constraints/stack/system_ops/mod.rs index 2775f73e22..5a1d8a6a0f 100644 --- a/air/src/constraints/stack/system_ops/mod.rs +++ b/air/src/constraints/stack/system_ops/mod.rs @@ -1,8 +1,6 @@ use super::{op_flags::OpFlags, EvaluationFrame, FieldElement, TransitionConstraintDegree}; -use crate::{ - stack::EvaluationFrameExt, - utils::{are_equal, collections::*}, -}; +use crate::{stack::EvaluationFrameExt, utils::are_equal}; +use alloc::vec::Vec; #[cfg(test)] pub mod tests; diff --git a/air/src/constraints/stack/u32_ops/mod.rs b/air/src/constraints/stack/u32_ops/mod.rs index 401166f72c..22b693d514 100644 --- a/air/src/constraints/stack/u32_ops/mod.rs +++ b/air/src/constraints/stack/u32_ops/mod.rs @@ -1,8 +1,9 @@ use super::{op_flags::OpFlags, EvaluationFrame, Felt, FieldElement, TransitionConstraintDegree}; use crate::{ stack::EvaluationFrameExt, - utils::{are_equal, collections::*, is_binary}, + utils::{are_equal, is_binary}, }; +use alloc::vec::Vec; #[cfg(test)] pub mod tests; diff --git a/air/src/errors.rs b/air/src/errors.rs index feda629ab7..cd9ef5bdb7 100644 --- a/air/src/errors.rs +++ b/air/src/errors.rs @@ -1,4 +1,5 @@ -use crate::{trace::MIN_TRACE_LEN, utils::string::*}; +use crate::trace::MIN_TRACE_LEN; +use alloc::string::String; use core::fmt::{Display, Formatter}; // EXECUTION ERROR diff --git a/air/src/lib.rs b/air/src/lib.rs index a597604ce4..426ea836f6 100644 --- a/air/src/lib.rs +++ b/air/src/lib.rs @@ -1,11 +1,15 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] -#[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; +#[cfg(feature = "std")] +extern crate std; + +use alloc::vec::Vec; + use vm_core::{ - utils::{collections::*, ByteReader, ByteWriter, Deserializable, Serializable}, + utils::{ByteReader, ByteWriter, Deserializable, Serializable}, ExtensionOf, ProgramInfo, StackInputs, StackOutputs, ONE, ZERO, }; use winter_air::{ @@ -173,7 +177,7 @@ impl Air for ProcessorAir { ); // Add initial assertions for the range checker's auxiliary columns. - range::get_aux_assertions_first_step(&mut result); + range::get_aux_assertions_first_step::(&mut result); // --- set assertions for the last step --------------------------------------------------- let last_step = self.last_step(); @@ -187,7 +191,7 @@ impl Air for ProcessorAir { ); // Add the range checker's auxiliary column assertions for the last step. - range::get_aux_assertions_last_step(&mut result, last_step); + range::get_aux_assertions_last_step::(&mut result, last_step); result } diff --git a/air/src/proof.rs b/air/src/proof.rs index 43d8dec278..c092e68ad3 100644 --- a/air/src/proof.rs +++ b/air/src/proof.rs @@ -1,8 +1,7 @@ +use alloc::vec::Vec; use vm_core::{ crypto::hash::{Blake3_192, Blake3_256, Hasher, Rpo256}, - utils::{ - collections::*, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, - }, + utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}, }; use winter_air::proof::StarkProof; diff --git a/air/src/trace/main_trace.rs b/air/src/trace/main_trace.rs index 405f5471db..454074a714 100644 --- a/air/src/trace/main_trace.rs +++ b/air/src/trace/main_trace.rs @@ -16,7 +16,7 @@ use super::{ CHIPLETS_OFFSET, CLK_COL_IDX, CTX_COL_IDX, DECODER_TRACE_OFFSET, FMP_COL_IDX, FN_HASH_OFFSET, STACK_TRACE_OFFSET, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::ops::{Deref, Range}; use vm_core::{utils::range, Felt, ONE, ZERO}; diff --git a/air/src/utils.rs b/air/src/utils.rs index 687b8432fc..9a9e8487c0 100644 --- a/air/src/utils.rs +++ b/air/src/utils.rs @@ -1,10 +1,10 @@ use super::FieldElement; +use alloc::vec::Vec; use core::ops::Range; -use vm_core::utils::{collections::*, range as create_range}; +use vm_core::utils::range as create_range; // RE-EXPORTS // ================================================================================================ -pub use vm_core::utils::{collections, string}; // BASIC CONSTRAINT OPERATORS // ================================================================================================ diff --git a/assembly/src/assembler/context.rs b/assembly/src/assembler/context.rs index 6d30ef70c2..295b96c927 100644 --- a/assembly/src/assembler/context.rs +++ b/assembly/src/assembler/context.rs @@ -2,10 +2,10 @@ use super::{ AssemblyError, CallSet, CodeBlock, CodeBlockTable, Kernel, LibraryPath, NamedProcedure, Procedure, ProcedureCache, ProcedureId, ProcedureName, RpoDigest, }; -use crate::{ - ast::{ModuleAst, ProgramAst}, - utils::{collections::*, string::*}, -}; +use crate::ast::{ModuleAst, ProgramAst}; +use alloc::collections::BTreeMap; +use alloc::string::ToString; +use alloc::vec::Vec; // ASSEMBLY CONTEXT // ================================================================================================ diff --git a/assembly/src/assembler/instruction/procedures.rs b/assembly/src/assembler/instruction/procedures.rs index 1801caac39..b95b7bf775 100644 --- a/assembly/src/assembler/instruction/procedures.rs +++ b/assembly/src/assembler/instruction/procedures.rs @@ -2,7 +2,7 @@ use super::{ Assembler, AssemblyContext, AssemblyError, CodeBlock, Operation, ProcedureId, RpoDigest, SpanBuilder, }; -use crate::utils::collections::*; +use alloc::vec::Vec; // PROCEDURE INVOCATIONS // ================================================================================================ diff --git a/assembly/src/assembler/mod.rs b/assembly/src/assembler/mod.rs index 67686db4b4..1d18d4dcda 100644 --- a/assembly/src/assembler/mod.rs +++ b/assembly/src/assembler/mod.rs @@ -1,12 +1,12 @@ use super::{ ast::{instrument, Instruction, ModuleAst, Node, ProcedureAst, ProgramAst}, - btree_map, crypto::hash::RpoDigest, - AssemblyError, BTreeMap, CallSet, CodeBlock, CodeBlockTable, Felt, Kernel, Library, - LibraryError, LibraryPath, Module, NamedProcedure, Operation, Procedure, ProcedureId, - ProcedureName, Program, ONE, ZERO, + AssemblyError, CallSet, CodeBlock, CodeBlockTable, Felt, Kernel, Library, LibraryError, + LibraryPath, Module, NamedProcedure, Operation, Procedure, ProcedureId, ProcedureName, Program, + ONE, ZERO, }; -use crate::utils::collections::*; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; use core::{borrow::Borrow, cell::RefCell}; use vm_core::{utils::group_vector_elements, Decorator, DecoratorList}; diff --git a/assembly/src/assembler/module_provider.rs b/assembly/src/assembler/module_provider.rs index f25d0b33d6..f5e2eab677 100644 --- a/assembly/src/assembler/module_provider.rs +++ b/assembly/src/assembler/module_provider.rs @@ -1,5 +1,6 @@ use super::{Library, LibraryError, Module, ProcedureId}; -use crate::utils::collections::*; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; // MODULE PROVIDER // ================================================================================================ diff --git a/assembly/src/assembler/procedure_cache.rs b/assembly/src/assembler/procedure_cache.rs index 3caa49a1c5..31761f922d 100644 --- a/assembly/src/assembler/procedure_cache.rs +++ b/assembly/src/assembler/procedure_cache.rs @@ -1,6 +1,5 @@ -use super::{ - btree_map::Entry, AssemblyError, BTreeMap, NamedProcedure, Procedure, ProcedureId, RpoDigest, -}; +use super::{AssemblyError, BTreeMap, NamedProcedure, Procedure, ProcedureId, RpoDigest}; +use alloc::collections::btree_map::Entry; // PROCEDURE CACHE // ================================================================================================ diff --git a/assembly/src/assembler/span_builder.rs b/assembly/src/assembler/span_builder.rs index b767fb2dbb..43e7901781 100644 --- a/assembly/src/assembler/span_builder.rs +++ b/assembly/src/assembler/span_builder.rs @@ -2,7 +2,8 @@ use super::{ AssemblyContext, AssemblyError, BodyWrapper, Borrow, CodeBlock, Decorator, DecoratorList, Instruction, Operation, }; -use crate::utils::{collections::*, string::*}; +use alloc::string::ToString; +use alloc::vec::Vec; use vm_core::{AdviceInjector, AssemblyOp}; // SPAN BUILDER diff --git a/assembly/src/assembler/tests.rs b/assembly/src/assembler/tests.rs index 8edd17cb65..fad93cd59b 100644 --- a/assembly/src/assembler/tests.rs +++ b/assembly/src/assembler/tests.rs @@ -1,5 +1,7 @@ use super::{combine_blocks, Assembler, CodeBlock, Library, Module, Operation}; use crate::{ast::ModuleAst, LibraryNamespace, LibraryPath, Version}; +use alloc::string::ToString; +use alloc::vec::Vec; use core::slice::Iter; // TESTS diff --git a/assembly/src/ast/code_body.rs b/assembly/src/ast/code_body.rs index 230035f83c..d484f4fa84 100644 --- a/assembly/src/ast/code_body.rs +++ b/assembly/src/ast/code_body.rs @@ -2,7 +2,7 @@ use super::{ ByteReader, ByteWriter, Deserializable, DeserializationError, Node, Serializable, SourceLocation, MAX_BODY_LEN, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::{iter, slice}; // CODE BODY diff --git a/assembly/src/ast/format.rs b/assembly/src/ast/format.rs index 2ba9c6fec3..cf96708fdf 100644 --- a/assembly/src/ast/format.rs +++ b/assembly/src/ast/format.rs @@ -2,7 +2,7 @@ use super::{ CodeBody, FormattableNode, InvokedProcsMap, LibraryPath, ProcedureAst, ProcedureId, ProcedureName, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::fmt; const INDENT_STRING: &str = " "; diff --git a/assembly/src/ast/imports.rs b/assembly/src/ast/imports.rs index 4a275e45cd..efdef0f379 100644 --- a/assembly/src/ast/imports.rs +++ b/assembly/src/ast/imports.rs @@ -3,7 +3,9 @@ use super::{ ParsingError, ProcedureId, ProcedureName, Serializable, Token, TokenStream, MAX_IMPORTS, MAX_INVOKED_IMPORTED_PROCS, }; -use crate::utils::{collections::*, string::*}; +use alloc::collections::BTreeMap; +use alloc::string::{String, ToString}; +use alloc::vec::Vec; // TYPE ALIASES // ================================================================================================ diff --git a/assembly/src/ast/mod.rs b/assembly/src/ast/mod.rs index 9f0652ad44..c96274b72b 100644 --- a/assembly/src/ast/mod.rs +++ b/assembly/src/ast/mod.rs @@ -7,7 +7,9 @@ use super::{ LabelError, LibraryPath, ParsingError, ProcedureId, ProcedureName, Serializable, SliceReader, StarkField, Token, TokenStream, MAX_LABEL_LEN, }; -use crate::utils::{collections::*, string::*}; +use alloc::collections::BTreeMap; +use alloc::string::String; +use alloc::vec::Vec; use vm_core::utils::bound_into_included_u64; pub use tracing::{event, info_span, instrument, Level}; diff --git a/assembly/src/ast/module.rs b/assembly/src/ast/module.rs index e15099a401..266aa3fe40 100644 --- a/assembly/src/ast/module.rs +++ b/assembly/src/ast/module.rs @@ -11,8 +11,9 @@ use super::{ Token, TokenStream, }, }; -use crate::utils::{collections::*, string::*}; +use alloc::string::{String, ToString}; +use alloc::vec::Vec; use core::{fmt, str::from_utf8}; use vm_core::utils::Serializable; diff --git a/assembly/src/ast/nodes/advice.rs b/assembly/src/ast/nodes/advice.rs index 2b0fdc8b86..a819ccee76 100644 --- a/assembly/src/ast/nodes/advice.rs +++ b/assembly/src/ast/nodes/advice.rs @@ -5,7 +5,7 @@ use super::{ }, serde::signatures, }; -use crate::utils::string::*; +use alloc::string::ToString; use core::fmt; use vm_core::{AdviceInjector, Felt, SignatureKind, ZERO}; diff --git a/assembly/src/ast/nodes/mod.rs b/assembly/src/ast/nodes/mod.rs index f10feb087c..1d97c981f4 100644 --- a/assembly/src/ast/nodes/mod.rs +++ b/assembly/src/ast/nodes/mod.rs @@ -1,5 +1,5 @@ use super::{AstFormatterContext, CodeBody, Felt, FormattableCodeBody, ProcedureId, RpoDigest}; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::fmt; use vm_core::DebugOptions; diff --git a/assembly/src/ast/nodes/serde/debug.rs b/assembly/src/ast/nodes/serde/debug.rs index 3b8b30b0b5..d1652680ad 100644 --- a/assembly/src/ast/nodes/serde/debug.rs +++ b/assembly/src/ast/nodes/serde/debug.rs @@ -1,5 +1,5 @@ use super::{super::DebugOptions, ByteReader, ByteWriter, DeserializationError}; -use crate::utils::string::*; +use alloc::string::ToString; const STACK_ALL: u8 = 0; const STACK_TOP: u8 = 1; diff --git a/assembly/src/ast/nodes/serde/deserialization.rs b/assembly/src/ast/nodes/serde/deserialization.rs index 7a86a5caf6..babdc98247 100644 --- a/assembly/src/ast/nodes/serde/deserialization.rs +++ b/assembly/src/ast/nodes/serde/deserialization.rs @@ -2,7 +2,7 @@ use super::{ super::AdviceInjectorNode, debug, ByteReader, CodeBody, Deserializable, DeserializationError, Felt, Instruction, Node, OpCode, ProcedureId, RpoDigest, MAX_PUSH_INPUTS, }; -use crate::utils::string::*; +use alloc::string::ToString; // NODE DESERIALIZATION // ================================================================================================ diff --git a/assembly/src/ast/nodes/serde/mod.rs b/assembly/src/ast/nodes/serde/mod.rs index a81ddaaa7a..cc4f9fff8a 100644 --- a/assembly/src/ast/nodes/serde/mod.rs +++ b/assembly/src/ast/nodes/serde/mod.rs @@ -1,6 +1,6 @@ use super::{CodeBody, Felt, Instruction, Node, ProcedureId, RpoDigest}; -use crate::utils::string::*; use crate::MAX_PUSH_INPUTS; +use alloc::string::ToString; use num_enum::TryFromPrimitive; use vm_core::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; diff --git a/assembly/src/ast/nodes/serde/signatures.rs b/assembly/src/ast/nodes/serde/signatures.rs index ebaf358562..484f814f83 100644 --- a/assembly/src/ast/nodes/serde/signatures.rs +++ b/assembly/src/ast/nodes/serde/signatures.rs @@ -1,5 +1,5 @@ use super::{ByteReader, ByteWriter, DeserializationError}; -use crate::utils::string::*; +use alloc::string::ToString; use vm_core::SignatureKind; const RPOFALCON512: u8 = 0; diff --git a/assembly/src/ast/parsers/constants.rs b/assembly/src/ast/parsers/constants.rs index 3303eec94b..84477200d3 100644 --- a/assembly/src/ast/parsers/constants.rs +++ b/assembly/src/ast/parsers/constants.rs @@ -1,5 +1,6 @@ use super::{Felt, LocalConstMap, ParsingError, Token}; -use crate::utils::{collections::*, string::*}; +use alloc::string::String; +use alloc::vec::Vec; use core::fmt::Display; // CONSTANT VALUE EXPRESSIONS @@ -298,6 +299,7 @@ mod tests { }, ONE, }; + use alloc::string::ToString; use Operation::*; #[test] diff --git a/assembly/src/ast/parsers/context.rs b/assembly/src/ast/parsers/context.rs index 41c3dadb9f..32bf0d8a63 100644 --- a/assembly/src/ast/parsers/context.rs +++ b/assembly/src/ast/parsers/context.rs @@ -4,7 +4,8 @@ use super::{ ModuleImports, Node, ParsingError, ProcedureAst, ProcedureId, ProcedureName, ReExportedProcMap, Token, TokenStream, MAX_BODY_LEN, MAX_DOCS_LEN, }; -use crate::utils::{collections::*, string::*}; +use alloc::string::ToString; +use alloc::vec::Vec; // PARSER CONTEXT // ================================================================================================ diff --git a/assembly/src/ast/parsers/io_ops.rs b/assembly/src/ast/parsers/io_ops.rs index 2a23a9af68..11f2328f58 100644 --- a/assembly/src/ast/parsers/io_ops.rs +++ b/assembly/src/ast/parsers/io_ops.rs @@ -5,7 +5,8 @@ use super::{ Node::{self, Instruction}, ParsingError, Token, CONSTANT_LABEL_PARSER, HEX_CHUNK_SIZE, }; -use crate::{utils::collections::*, StarkField, ADVICE_READ_LIMIT, MAX_PUSH_INPUTS}; +use crate::{StarkField, ADVICE_READ_LIMIT, MAX_PUSH_INPUTS}; +use alloc::vec::Vec; use core::ops::RangeBounds; use vm_core::WORD_SIZE; diff --git a/assembly/src/ast/parsers/labels.rs b/assembly/src/ast/parsers/labels.rs index 61ea86445e..05a5f3ce03 100644 --- a/assembly/src/ast/parsers/labels.rs +++ b/assembly/src/ast/parsers/labels.rs @@ -1,5 +1,6 @@ use super::{Deserializable, LabelError, RpoDigest, SliceReader, MAX_LABEL_LEN}; -use crate::utils::{collections::*, string::*}; +use alloc::string::ToString; +use alloc::vec::Vec; // LABEL PARSERS // ================================================================================================ diff --git a/assembly/src/ast/parsers/mod.rs b/assembly/src/ast/parsers/mod.rs index 1b8c8f39cd..0046c906f3 100644 --- a/assembly/src/ast/parsers/mod.rs +++ b/assembly/src/ast/parsers/mod.rs @@ -5,10 +5,9 @@ use super::{ SliceReader, StarkField, Token, TokenStream, MAX_BODY_LEN, MAX_DOCS_LEN, MAX_LABEL_LEN, MAX_STACK_WORD_OFFSET, }; -use crate::{ - utils::{collections::*, string::*}, - HEX_CHUNK_SIZE, -}; +use crate::HEX_CHUNK_SIZE; +use alloc::string::{String, ToString}; +use alloc::vec::Vec; use core::{fmt::Display, ops::RangeBounds}; mod adv_ops; diff --git a/assembly/src/ast/procedure.rs b/assembly/src/ast/procedure.rs index 4ad93afce2..bd1fe0d5eb 100644 --- a/assembly/src/ast/procedure.rs +++ b/assembly/src/ast/procedure.rs @@ -1,10 +1,14 @@ +use alloc::{ + string::{String, ToString}, + vec::Vec, +}; + use crate::ast::{MAX_BODY_LEN, MAX_DOCS_LEN}; use super::{ super::tokens::SourceLocation, code_body::CodeBody, nodes::Node, ByteReader, ByteWriter, Deserializable, DeserializationError, LibraryPath, ProcedureId, ProcedureName, Serializable, }; -use crate::utils::{collections::*, string::*}; use core::{iter, str::from_utf8}; // PROCEDURE AST diff --git a/assembly/src/ast/program.rs b/assembly/src/ast/program.rs index 26139ab9ad..b180848d24 100644 --- a/assembly/src/ast/program.rs +++ b/assembly/src/ast/program.rs @@ -1,3 +1,5 @@ +use alloc::vec::Vec; + use crate::ast::MAX_BODY_LEN; use super::{ @@ -18,7 +20,6 @@ use super::{ SliceReader, Token, TokenStream, }, }; -use crate::utils::collections::*; use core::{fmt, iter}; #[cfg(feature = "std")] diff --git a/assembly/src/ast/tests.rs b/assembly/src/ast/tests.rs index f465ffa1e4..52035cc66d 100644 --- a/assembly/src/ast/tests.rs +++ b/assembly/src/ast/tests.rs @@ -2,7 +2,11 @@ use super::{ AstSerdeOptions, CodeBody, Felt, Instruction, LocalProcMap, ModuleAst, Node, ParsingError, ProcedureAst, ProcedureId, ProcedureName, ProgramAst, SourceLocation, Token, }; -use crate::utils::{collections::*, string::*}; +use alloc::{ + collections::BTreeMap, + string::{String, ToString}, + vec::Vec, +}; use vm_core::utils::SliceReader; // UNIT TESTS diff --git a/assembly/src/errors.rs b/assembly/src/errors.rs index 414bcceb72..4cc962a224 100644 --- a/assembly/src/errors.rs +++ b/assembly/src/errors.rs @@ -2,7 +2,10 @@ use super::{ ast::ProcReExport, crypto::hash::RpoDigest, tokens::SourceLocation, KernelError, LibraryNamespace, ProcedureId, ProcedureName, Token, }; -use crate::utils::{collections::*, string::*}; +use alloc::{ + string::{String, ToString}, + vec::Vec, +}; use core::fmt; // ASSEMBLY ERROR diff --git a/assembly/src/lib.rs b/assembly/src/lib.rs index a7cc116704..af34c3f20c 100644 --- a/assembly/src/lib.rs +++ b/assembly/src/lib.rs @@ -1,15 +1,16 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] -#[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; +#[cfg(feature = "std")] +extern crate std; + use vm_core::{ code_blocks::CodeBlock, crypto, errors::KernelError, utils::{ - collections::{btree_map, BTreeMap}, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, SliceReader, }, CodeBlockTable, Felt, Kernel, Operation, Program, StarkField, ONE, ZERO, diff --git a/assembly/src/library/masl.rs b/assembly/src/library/masl.rs index 51eca33fd5..10bdf3da52 100644 --- a/assembly/src/library/masl.rs +++ b/assembly/src/library/masl.rs @@ -3,7 +3,7 @@ use super::{ LibraryError, LibraryNamespace, LibraryPath, Module, ModuleAst, Serializable, Version, MAX_DEPENDENCIES, MAX_MODULES, }; -use crate::utils::collections::*; +use alloc::{collections::BTreeSet, vec::Vec}; use core::slice::Iter; // CONSTANT DEFINITIONS @@ -119,6 +119,8 @@ impl MaslLibrary { #[cfg(feature = "std")] mod use_std { + use alloc::{collections::BTreeMap, string::ToString}; + use super::{super::super::ast::instrument, *}; use std::{fs, io, path::Path}; diff --git a/assembly/src/library/mod.rs b/assembly/src/library/mod.rs index 56608a9bba..0ebdf6453f 100644 --- a/assembly/src/library/mod.rs +++ b/assembly/src/library/mod.rs @@ -3,10 +3,10 @@ use super::{ ByteReader, ByteWriter, Deserializable, DeserializationError, LibraryError, PathError, Serializable, MAX_LABEL_LEN, NAMESPACE_LABEL_PARSER, }; -use crate::utils::string::*; use core::{cmp::Ordering, fmt, ops::Deref, str::from_utf8}; mod masl; +use alloc::string::{String, ToString}; pub use masl::MaslLibrary; mod path; diff --git a/assembly/src/library/path.rs b/assembly/src/library/path.rs index 7bb7fb0192..5192315922 100644 --- a/assembly/src/library/path.rs +++ b/assembly/src/library/path.rs @@ -2,7 +2,7 @@ use super::{ ByteReader, ByteWriter, Deserializable, DeserializationError, PathError, Serializable, MAX_LABEL_LEN, }; -use crate::utils::string::*; +use alloc::string::{String, ToString}; use core::{fmt, ops::Deref, str::from_utf8}; // CONSTANTS diff --git a/assembly/src/library/tests.rs b/assembly/src/library/tests.rs index 92886923c4..0b3a5b1ff6 100644 --- a/assembly/src/library/tests.rs +++ b/assembly/src/library/tests.rs @@ -1,4 +1,5 @@ use super::{Library, LibraryNamespace, LibraryPath, MaslLibrary, Module, ModuleAst, Version}; +use alloc::vec::Vec; use vm_core::utils::{Deserializable, Serializable, SliceReader}; #[test] diff --git a/assembly/src/procedures/mod.rs b/assembly/src/procedures/mod.rs index 4519de64cd..8180a562ba 100644 --- a/assembly/src/procedures/mod.rs +++ b/assembly/src/procedures/mod.rs @@ -3,7 +3,10 @@ use super::{ ByteReader, ByteWriter, CodeBlock, Deserializable, DeserializationError, LabelError, LibraryPath, Serializable, PROCEDURE_LABEL_PARSER, }; -use crate::utils::{collections::*, string::*}; +use alloc::{ + collections::BTreeSet, + string::{String, ToString}, +}; use core::{ fmt, ops::{self, Deref}, @@ -366,6 +369,7 @@ impl ops::Deref for CallSet { #[cfg(test)] mod test { use super::{super::MAX_LABEL_LEN, LabelError, ProcedureName}; + use alloc::borrow::ToOwned; #[test] fn test_procedure_name_max_len() { diff --git a/assembly/src/tests.rs b/assembly/src/tests.rs index f76fbc4e32..b41d8f401c 100644 --- a/assembly/src/tests.rs +++ b/assembly/src/tests.rs @@ -3,6 +3,7 @@ use crate::{ Assembler, AssemblyContext, AssemblyError, Library, LibraryNamespace, LibraryPath, MaslLibrary, Module, ProcedureName, Version, }; +use alloc::{string::ToString, vec::Vec}; use core::slice::Iter; // SIMPLE PROGRAMS diff --git a/assembly/src/tokens/lines.rs b/assembly/src/tokens/lines.rs index 16d5b2083e..b066aea4af 100644 --- a/assembly/src/tokens/lines.rs +++ b/assembly/src/tokens/lines.rs @@ -1,5 +1,5 @@ use super::{SourceLocation, Token}; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::{iter, str::Lines}; // LINES STREAM diff --git a/assembly/src/tokens/mod.rs b/assembly/src/tokens/mod.rs index 4534cb0bbf..19b5d99ac8 100644 --- a/assembly/src/tokens/mod.rs +++ b/assembly/src/tokens/mod.rs @@ -3,7 +3,11 @@ use super::{ ByteReader, ByteWriter, Deserializable, DeserializationError, LibraryPath, ParsingError, ProcedureName, Serializable, }; -use crate::utils::{collections::*, string::*}; +use alloc::{ + collections::BTreeMap, + string::{String, ToString}, + vec::Vec, +}; use core::fmt; mod lines; diff --git a/assembly/src/tokens/stream.rs b/assembly/src/tokens/stream.rs index 0d81227807..b5c4e116b3 100644 --- a/assembly/src/tokens/stream.rs +++ b/assembly/src/tokens/stream.rs @@ -1,5 +1,5 @@ use super::{LineTokenizer, LinesStream, ParsingError, SourceLocation, Token}; -use crate::utils::{collections::*, string::*}; +use alloc::{collections::BTreeMap, string::String, vec::Vec}; use core::fmt; // TOKEN STREAM diff --git a/core/Cargo.toml b/core/Cargo.toml index 35b2772046..6fba01cede 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -22,7 +22,7 @@ std = ["miden-crypto/std", "math/std", "winter-utils/std"] [dependencies] math = { package = "winter-math", version = "0.8", default-features = false } -miden-crypto = { version = "0.8", default-features = false } +miden-crypto = { version = "0.9", default-features = false } winter-utils = { package = "winter-utils", version = "0.8", default-features = false } [dev-dependencies] diff --git a/core/src/errors.rs b/core/src/errors.rs index 2956794cc1..d7b0c80695 100644 --- a/core/src/errors.rs +++ b/core/src/errors.rs @@ -1,6 +1,7 @@ -use crate::utils::string::*; use core::fmt; +use alloc::string::String; + // INPUT ERROR // ================================================================================================ diff --git a/core/src/lib.rs b/core/src/lib.rs index 3653452e4d..bc50dd027d 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -1,6 +1,8 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] + +#[cfg(feature = "std")] +extern crate std; -#[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; diff --git a/core/src/operations/decorators/assembly_op.rs b/core/src/operations/decorators/assembly_op.rs index b18b893787..56689724cf 100644 --- a/core/src/operations/decorators/assembly_op.rs +++ b/core/src/operations/decorators/assembly_op.rs @@ -1,4 +1,4 @@ -use crate::utils::string::*; +use alloc::string::String; use core::fmt; // ASSEMBLY OP diff --git a/core/src/operations/decorators/mod.rs b/core/src/operations/decorators/mod.rs index 9fb653c32e..12cb478e70 100644 --- a/core/src/operations/decorators/mod.rs +++ b/core/src/operations/decorators/mod.rs @@ -1,4 +1,4 @@ -use crate::utils::collections::*; +use alloc::vec::Vec; use core::fmt; mod advice; diff --git a/core/src/program/blocks/join_block.rs b/core/src/program/blocks/join_block.rs index 711b10d481..02a9c358a9 100644 --- a/core/src/program/blocks/join_block.rs +++ b/core/src/program/blocks/join_block.rs @@ -1,5 +1,5 @@ use super::{fmt, hasher, CodeBlock, Digest, Felt, Operation}; -use crate::utils::boxed::*; +use alloc::boxed::Box; // JOIN BLOCKS // ================================================================================================ diff --git a/core/src/program/blocks/loop_block.rs b/core/src/program/blocks/loop_block.rs index eb68df6324..3f6c8fbdca 100644 --- a/core/src/program/blocks/loop_block.rs +++ b/core/src/program/blocks/loop_block.rs @@ -1,5 +1,5 @@ use super::{fmt, hasher, CodeBlock, Digest, Felt, Operation}; -use crate::utils::boxed::*; +use alloc::boxed::Box; // LOOP BLOCK // ================================================================================================ diff --git a/core/src/program/blocks/mod.rs b/core/src/program/blocks/mod.rs index 1fc7328600..f06bff6acb 100644 --- a/core/src/program/blocks/mod.rs +++ b/core/src/program/blocks/mod.rs @@ -1,6 +1,6 @@ use super::{hasher, Digest, Felt, Operation}; -use crate::utils::collections::*; use crate::DecoratorList; +use alloc::vec::Vec; use core::fmt; mod call_block; diff --git a/core/src/program/blocks/span_block.rs b/core/src/program/blocks/span_block.rs index 8ba4a8c74b..d0d7f7f15f 100644 --- a/core/src/program/blocks/span_block.rs +++ b/core/src/program/blocks/span_block.rs @@ -1,5 +1,6 @@ use super::{fmt, hasher, Digest, Felt, Operation}; -use crate::{utils::collections::*, DecoratorIterator, DecoratorList, ZERO}; +use crate::{DecoratorIterator, DecoratorList, ZERO}; +use alloc::vec::Vec; use winter_utils::flatten_slice_elements; // CONSTANTS diff --git a/core/src/program/blocks/split_block.rs b/core/src/program/blocks/split_block.rs index 91c4e36f54..2c7f37156f 100644 --- a/core/src/program/blocks/split_block.rs +++ b/core/src/program/blocks/split_block.rs @@ -1,5 +1,5 @@ use super::{fmt, hasher, CodeBlock, Digest, Felt, Operation}; -use crate::utils::boxed::*; +use alloc::boxed::Box; // SPLIT BLOCK // ================================================================================================ diff --git a/core/src/program/info.rs b/core/src/program/info.rs index b51f6405de..083fcb0c23 100644 --- a/core/src/program/info.rs +++ b/core/src/program/info.rs @@ -3,7 +3,7 @@ use super::{ ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Felt, Kernel, Program, Serializable, }; -use crate::utils::collections::*; +use alloc::vec::Vec; // PROGRAM INFO // ================================================================================================ diff --git a/core/src/program/mod.rs b/core/src/program/mod.rs index 5205fcfbdd..1de4bba969 100644 --- a/core/src/program/mod.rs +++ b/core/src/program/mod.rs @@ -2,9 +2,8 @@ use super::{ chiplets::hasher::{self, Digest}, errors, Felt, Operation, }; -use crate::utils::{ - collections::*, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable, -}; +use crate::utils::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; +use alloc::{collections::BTreeMap, vec::Vec}; use core::fmt; pub mod blocks; diff --git a/core/src/program/tests.rs b/core/src/program/tests.rs index ab11bac3e4..3e5e0a5329 100644 --- a/core/src/program/tests.rs +++ b/core/src/program/tests.rs @@ -1,5 +1,6 @@ use super::{blocks::Dyn, Deserializable, Digest, Felt, Kernel, ProgramInfo, Serializable}; use crate::{chiplets::hasher, Word}; +use alloc::vec::Vec; use proptest::prelude::*; use rand_utils::prng_array; diff --git a/core/src/stack/inputs.rs b/core/src/stack/inputs.rs index b05e35bd84..32845306b7 100644 --- a/core/src/stack/inputs.rs +++ b/core/src/stack/inputs.rs @@ -1,4 +1,6 @@ -use crate::utils::{collections::*, ByteReader, Deserializable, DeserializationError}; +use alloc::vec::Vec; + +use crate::utils::{ByteReader, Deserializable, DeserializationError}; use super::{ByteWriter, Felt, InputError, Serializable, ToElements}; use core::slice; @@ -75,7 +77,7 @@ impl<'a> IntoIterator for &'a StackInputs { impl IntoIterator for StackInputs { type Item = Felt; - type IntoIter = vec::IntoIter; + type IntoIter = alloc::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { self.values.into_iter() diff --git a/core/src/stack/outputs.rs b/core/src/stack/outputs.rs index 3e1cc891da..2277ad0dce 100644 --- a/core/src/stack/outputs.rs +++ b/core/src/stack/outputs.rs @@ -1,4 +1,5 @@ -use crate::utils::{collections::*, range, ByteReader, Deserializable, DeserializationError}; +use crate::utils::{range, ByteReader, Deserializable, DeserializationError}; +use alloc::vec::Vec; use miden_crypto::{Word, ZERO}; use super::{ diff --git a/core/src/utils/mod.rs b/core/src/utils/mod.rs index c90ceb8cd1..f39dd058ec 100644 --- a/core/src/utils/mod.rs +++ b/core/src/utils/mod.rs @@ -1,9 +1,9 @@ use crate::Felt; +use alloc::{string::String, vec::Vec}; use core::{ fmt::{self, Debug, Write}, ops::{Bound, Range}, }; -use {collections::*, string::*}; // RE-EXPORTS // ================================================================================================ @@ -11,8 +11,8 @@ use {collections::*, string::*}; pub use winter_utils::{group_slice_elements, group_vector_elements}; pub use miden_crypto::utils::{ - boxed, collections, string, uninit_vector, vec, Box, ByteReader, ByteWriter, Deserializable, - DeserializationError, Serializable, SliceReader, + collections, uninit_vector, ByteReader, ByteWriter, Deserializable, DeserializationError, + Serializable, SliceReader, }; pub mod math { diff --git a/miden/src/tools/mod.rs b/miden/src/tools/mod.rs index f3ad1f2923..57cd505d4f 100644 --- a/miden/src/tools/mod.rs +++ b/miden/src/tools/mod.rs @@ -1,7 +1,7 @@ use super::{cli::InputFile, ProgramError}; use clap::Parser; use core::fmt; -use miden_vm::{utils::collections::*, Assembler, DefaultHost, Host, Operation, StackInputs}; +use miden_vm::{Assembler, DefaultHost, Host, Operation, StackInputs}; use processor::{AsmOpInfo, TraceLenSummary}; use std::{fs, path::PathBuf}; use stdlib::StdLibrary; diff --git a/processor/src/chiplets/aux_trace/mod.rs b/processor/src/chiplets/aux_trace/mod.rs index 7292da2c19..ffc7bd3759 100644 --- a/processor/src/chiplets/aux_trace/mod.rs +++ b/processor/src/chiplets/aux_trace/mod.rs @@ -1,6 +1,6 @@ use super::{super::trace::AuxColumnBuilder, Felt, FieldElement}; -use crate::utils::collections::*; +use alloc::vec::Vec; use miden_air::trace::{ chiplets::{ bitwise::OP_CYCLE_LEN as BITWISE_OP_CYCLE_LEN, diff --git a/processor/src/chiplets/bitwise/mod.rs b/processor/src/chiplets/bitwise/mod.rs index bdf18f5c52..b7212c8a06 100644 --- a/processor/src/chiplets/bitwise/mod.rs +++ b/processor/src/chiplets/bitwise/mod.rs @@ -1,5 +1,5 @@ use super::{utils::get_trace_len, ExecutionError, Felt, TraceFragment, ZERO}; -use crate::utils::collections::*; +use alloc::vec::Vec; use miden_air::trace::chiplets::bitwise::{ A_COL_IDX, A_COL_RANGE, BITWISE_AND, BITWISE_XOR, B_COL_IDX, B_COL_RANGE, OUTPUT_COL_IDX, PREV_OUTPUT_COL_IDX, TRACE_WIDTH, diff --git a/processor/src/chiplets/bitwise/tests.rs b/processor/src/chiplets/bitwise/tests.rs index 1ea5e89df1..ed38bff39c 100644 --- a/processor/src/chiplets/bitwise/tests.rs +++ b/processor/src/chiplets/bitwise/tests.rs @@ -1,10 +1,11 @@ use super::{Bitwise, Felt, TraceFragment}; +use alloc::vec::Vec; use miden_air::trace::chiplets::bitwise::{ A_COL_IDX, A_COL_RANGE, BITWISE_AND, BITWISE_XOR, B_COL_IDX, B_COL_RANGE, OP_CYCLE_LEN, OUTPUT_COL_IDX, PREV_OUTPUT_COL_IDX, TRACE_WIDTH, }; use test_utils::rand::rand_value; -use vm_core::{utils::collections::*, ZERO}; +use vm_core::ZERO; #[test] fn bitwise_init() { diff --git a/processor/src/chiplets/hasher/mod.rs b/processor/src/chiplets/hasher/mod.rs index cdcf7e2e84..d81de16746 100644 --- a/processor/src/chiplets/hasher/mod.rs +++ b/processor/src/chiplets/hasher/mod.rs @@ -1,7 +1,7 @@ use super::{ - BTreeMap, Felt, HasherState, MerklePath, MerkleRootUpdate, OpBatch, TraceFragment, Word, ONE, - ZERO, + Felt, HasherState, MerklePath, MerkleRootUpdate, OpBatch, TraceFragment, Word, ONE, ZERO, }; +use alloc::collections::BTreeMap; use miden_air::trace::chiplets::hasher::{ Digest, Selectors, DIGEST_LEN, DIGEST_RANGE, LINEAR_HASH, MP_VERIFY, MR_UPDATE_NEW, MR_UPDATE_OLD, RATE_LEN, RETURN_HASH, RETURN_STATE, STATE_WIDTH, TRACE_WIDTH, diff --git a/processor/src/chiplets/hasher/tests.rs b/processor/src/chiplets/hasher/tests.rs index b595a5474b..dca1baa5ca 100644 --- a/processor/src/chiplets/hasher/tests.rs +++ b/processor/src/chiplets/hasher/tests.rs @@ -3,7 +3,7 @@ use super::{ Word, LINEAR_HASH, MP_VERIFY, MR_UPDATE_NEW, MR_UPDATE_OLD, RETURN_HASH, RETURN_STATE, TRACE_WIDTH, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use miden_air::trace::chiplets::hasher::{ DIGEST_LEN, HASH_CYCLE_LEN, NUM_ROUNDS, NUM_SELECTORS, STATE_COL_RANGE, diff --git a/processor/src/chiplets/hasher/trace.rs b/processor/src/chiplets/hasher/trace.rs index e19174907a..a443793a5a 100644 --- a/processor/src/chiplets/hasher/trace.rs +++ b/processor/src/chiplets/hasher/trace.rs @@ -1,5 +1,5 @@ use super::{Felt, HasherState, Selectors, TraceFragment, STATE_WIDTH, TRACE_WIDTH, ZERO}; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::ops::Range; use miden_air::trace::chiplets::hasher::NUM_ROUNDS; use vm_core::chiplets::hasher::apply_round; diff --git a/processor/src/chiplets/kernel_rom/mod.rs b/processor/src/chiplets/kernel_rom/mod.rs index 8e5c0100ae..e310111805 100644 --- a/processor/src/chiplets/kernel_rom/mod.rs +++ b/processor/src/chiplets/kernel_rom/mod.rs @@ -1,4 +1,5 @@ -use super::{BTreeMap, Digest, ExecutionError, Felt, Kernel, TraceFragment, Word, ONE, ZERO}; +use super::{Digest, ExecutionError, Felt, Kernel, TraceFragment, Word, ONE, ZERO}; +use alloc::collections::BTreeMap; use miden_air::trace::chiplets::kernel_rom::TRACE_WIDTH; #[cfg(test)] diff --git a/processor/src/chiplets/kernel_rom/tests.rs b/processor/src/chiplets/kernel_rom/tests.rs index a2cf510b60..9b2ccbcd2d 100644 --- a/processor/src/chiplets/kernel_rom/tests.rs +++ b/processor/src/chiplets/kernel_rom/tests.rs @@ -1,5 +1,5 @@ use super::{Felt, Kernel, KernelRom, TraceFragment, Word, ONE, TRACE_WIDTH, ZERO}; -use vm_core::utils::collections::*; +use alloc::vec::Vec; // CONSTANTS // ================================================================================================ diff --git a/processor/src/chiplets/memory/mod.rs b/processor/src/chiplets/memory/mod.rs index a2a522b44e..0dea505f6c 100644 --- a/processor/src/chiplets/memory/mod.rs +++ b/processor/src/chiplets/memory/mod.rs @@ -2,7 +2,8 @@ use super::{ utils::{split_element_u32_into_u16, split_u32_into_u16}, Felt, FieldElement, RangeChecker, TraceFragment, Word, EMPTY_WORD, ONE, }; -use crate::{system::ContextId, utils::collections::*}; +use crate::system::ContextId; +use alloc::{collections::BTreeMap, vec::Vec}; use miden_air::trace::chiplets::memory::{ ADDR_COL_IDX, CLK_COL_IDX, CTX_COL_IDX, D0_COL_IDX, D1_COL_IDX, D_INV_COL_IDX, V_COL_RANGE, }; diff --git a/processor/src/chiplets/memory/segment.rs b/processor/src/chiplets/memory/segment.rs index e6ee97210c..b3137d3185 100644 --- a/processor/src/chiplets/memory/segment.rs +++ b/processor/src/chiplets/memory/segment.rs @@ -1,9 +1,9 @@ +use alloc::{collections::BTreeMap, vec::Vec}; use miden_air::trace::chiplets::memory::{ Selectors, MEMORY_COPY_READ, MEMORY_INIT_READ, MEMORY_WRITE, }; use super::{Felt, Word, INIT_MEM_VALUE}; -use crate::utils::collections::*; // MEMORY SEGMENT TRACE // ================================================================================================ diff --git a/processor/src/chiplets/memory/tests.rs b/processor/src/chiplets/memory/tests.rs index ebb98db017..a99d59bb5e 100644 --- a/processor/src/chiplets/memory/tests.rs +++ b/processor/src/chiplets/memory/tests.rs @@ -3,10 +3,11 @@ use super::{ D0_COL_IDX, D1_COL_IDX, D_INV_COL_IDX, EMPTY_WORD, ONE, V_COL_RANGE, }; use crate::ContextId; +use alloc::vec::Vec; use miden_air::trace::chiplets::memory::{ Selectors, MEMORY_COPY_READ, MEMORY_INIT_READ, MEMORY_WRITE, TRACE_WIDTH as MEMORY_TRACE_WIDTH, }; -use vm_core::{utils::collections::*, Word}; +use vm_core::Word; #[test] fn mem_init() { diff --git a/processor/src/chiplets/mod.rs b/processor/src/chiplets/mod.rs index 74654a81a5..74cc276efa 100644 --- a/processor/src/chiplets/mod.rs +++ b/processor/src/chiplets/mod.rs @@ -4,7 +4,7 @@ use super::{ crypto::MerklePath, utils, ChipletsTrace, ExecutionError, Felt, FieldElement, RangeChecker, TraceFragment, Word, CHIPLETS_WIDTH, EMPTY_WORD, ONE, ZERO, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use miden_air::trace::chiplets::hasher::{Digest, HasherState}; use vm_core::{code_blocks::OpBatch, Kernel}; diff --git a/processor/src/chiplets/tests.rs b/processor/src/chiplets/tests.rs index 4042d1c604..ee9939e4fd 100644 --- a/processor/src/chiplets/tests.rs +++ b/processor/src/chiplets/tests.rs @@ -1,7 +1,8 @@ use crate::{ - utils::collections::*, CodeBlock, DefaultHost, ExecutionOptions, ExecutionTrace, Kernel, - Operation, Process, StackInputs, + CodeBlock, DefaultHost, ExecutionOptions, ExecutionTrace, Kernel, Operation, Process, + StackInputs, }; +use alloc::vec::Vec; use miden_air::trace::{ chiplets::{ bitwise::{BITWISE_XOR, OP_CYCLE_LEN, TRACE_WIDTH as BITWISE_TRACE_WIDTH}, diff --git a/processor/src/debug.rs b/processor/src/debug.rs index 48df4dfde8..d87275d5b1 100644 --- a/processor/src/debug.rs +++ b/processor/src/debug.rs @@ -1,10 +1,9 @@ use crate::{ - range::RangeChecker, - system::ContextId, - utils::{collections::*, string::*}, - Chiplets, ChipletsLengths, Decoder, ExecutionError, Felt, Host, Process, Stack, System, - TraceLenSummary, + range::RangeChecker, system::ContextId, Chiplets, ChipletsLengths, Decoder, ExecutionError, + Felt, Host, Process, Stack, System, TraceLenSummary, }; +use alloc::string::{String, ToString}; +use alloc::vec::Vec; use core::fmt; use vm_core::{AssemblyOp, Operation, StackOutputs, Word}; diff --git a/processor/src/decoder/aux_trace/mod.rs b/processor/src/decoder/aux_trace/mod.rs index 8b083f99ba..819b843d48 100644 --- a/processor/src/decoder/aux_trace/mod.rs +++ b/processor/src/decoder/aux_trace/mod.rs @@ -1,5 +1,6 @@ use super::{Felt, ONE, ZERO}; -use crate::{trace::AuxColumnBuilder, utils::collections::*}; +use crate::trace::AuxColumnBuilder; +use alloc::vec::Vec; use miden_air::trace::main_trace::MainTrace; use vm_core::{FieldElement, Operation}; diff --git a/processor/src/decoder/block_stack.rs b/processor/src/decoder/block_stack.rs index c478829694..662d06270a 100644 --- a/processor/src/decoder/block_stack.rs +++ b/processor/src/decoder/block_stack.rs @@ -1,5 +1,6 @@ use super::{Felt, Word, ONE, ZERO}; -use crate::{system::ContextId, utils::collections::*}; +use crate::system::ContextId; +use alloc::vec::Vec; // BLOCK STACK // ================================================================================================ @@ -94,13 +95,14 @@ impl BlockStack { // ================================================================================================ /// Contains basic information about a code block. -#[derive(Debug, Clone, Copy)] +#[derive(Debug)] pub struct BlockInfo { pub addr: Felt, block_type: BlockType, pub parent_addr: Felt, pub ctx_info: Option, pub is_loop_body: bool, + #[allow(dead_code)] // TODO: remove this filed pub is_first_child: bool, } diff --git a/processor/src/decoder/mod.rs b/processor/src/decoder/mod.rs index 7b012d27d4..cabc8e1054 100644 --- a/processor/src/decoder/mod.rs +++ b/processor/src/decoder/mod.rs @@ -2,7 +2,7 @@ use super::{ Call, Dyn, ExecutionError, Felt, Host, Join, Loop, OpBatch, Operation, Process, Span, Split, Word, EMPTY_WORD, MIN_TRACE_LEN, ONE, OP_BATCH_SIZE, ZERO, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use miden_air::trace::{ chiplets::hasher::DIGEST_LEN, decoder::{ diff --git a/processor/src/decoder/tests.rs b/processor/src/decoder/tests.rs index 64418a88ce..b751ad3432 100644 --- a/processor/src/decoder/tests.rs +++ b/processor/src/decoder/tests.rs @@ -5,6 +5,7 @@ use super::{ build_op_group, }; use crate::DefaultHost; +use alloc::vec::Vec; use miden_air::trace::{ decoder::{ ADDR_COL_IDX, GROUP_COUNT_COL_IDX, HASHER_STATE_RANGE, IN_SPAN_COL_IDX, NUM_HASHER_COLUMNS, @@ -18,7 +19,6 @@ use miden_air::trace::{ use test_utils::rand::rand_value; use vm_core::{ code_blocks::{CodeBlock, Span, OP_BATCH_SIZE}, - utils::collections::*, CodeBlockTable, EMPTY_WORD, ONE, ZERO, }; diff --git a/processor/src/decoder/trace.rs b/processor/src/decoder/trace.rs index 59d0f4c9c5..84ba0a9482 100644 --- a/processor/src/decoder/trace.rs +++ b/processor/src/decoder/trace.rs @@ -4,7 +4,7 @@ use super::{ ONE, OP_BATCH_1_GROUPS, OP_BATCH_2_GROUPS, OP_BATCH_4_GROUPS, OP_BATCH_8_GROUPS, OP_BATCH_SIZE, ZERO, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::ops::Range; use vm_core::utils::new_array_vec; diff --git a/processor/src/errors.rs b/processor/src/errors.rs index 46587b2424..2702a1a7ea 100644 --- a/processor/src/errors.rs +++ b/processor/src/errors.rs @@ -3,7 +3,7 @@ use super::{ system::{FMP_MAX, FMP_MIN}, CodeBlock, Digest, Felt, QuadFelt, Word, }; -use crate::utils::string::*; +use alloc::string::String; use core::fmt::{Display, Formatter}; use vm_core::{stack::STACK_TOP_SIZE, utils::to_hex}; use winter_prover::{math::FieldElement, ProverError}; diff --git a/processor/src/host/advice/injectors/adv_map_injectors.rs b/processor/src/host/advice/injectors/adv_map_injectors.rs index 5b479848c2..10035f44c6 100644 --- a/processor/src/host/advice/injectors/adv_map_injectors.rs +++ b/processor/src/host/advice/injectors/adv_map_injectors.rs @@ -1,5 +1,6 @@ use super::super::{AdviceProvider, ExecutionError, Felt, HostResponse}; -use crate::{utils::collections::*, ProcessState}; +use crate::ProcessState; +use alloc::vec::Vec; use vm_core::{ crypto::hash::{Rpo256, RpoDigest}, EMPTY_WORD, WORD_SIZE, diff --git a/processor/src/host/advice/injectors/adv_stack_injectors.rs b/processor/src/host/advice/injectors/adv_stack_injectors.rs index 028901600f..9ab4c91ffd 100644 --- a/processor/src/host/advice/injectors/adv_stack_injectors.rs +++ b/processor/src/host/advice/injectors/adv_stack_injectors.rs @@ -1,7 +1,6 @@ use super::super::{AdviceSource, ExecutionError, Felt, HostResponse}; -use crate::{ - utils::collections::*, AdviceProvider, Ext2InttError, FieldElement, ProcessState, ZERO, -}; +use crate::{AdviceProvider, Ext2InttError, FieldElement, ProcessState, ZERO}; +use alloc::vec::Vec; use vm_core::{QuadExtension, SignatureKind}; use winter_prover::math::fft; diff --git a/processor/src/host/advice/injectors/dsa.rs b/processor/src/host/advice/injectors/dsa.rs index 64083cfa17..a64519bb84 100644 --- a/processor/src/host/advice/injectors/dsa.rs +++ b/processor/src/host/advice/injectors/dsa.rs @@ -1,12 +1,8 @@ use super::super::{ExecutionError, Felt, Word}; -use crate::utils::collections::*; -use vm_core::{ - crypto::dsa::rpo_falcon512::{KeyPair, Polynomial}, - utils::Deserializable, -}; +use alloc::vec::Vec; -/// Gets as input a vector containing an expanded public key and its associated secret key, and a -/// word representing a message and outputs a vector of values to be pushed onto the advice stack. +/// Gets as input a vector containing a secret key, and a word representing a message and outputs a +/// vector of values to be pushed onto the advice stack. /// The values are the ones required for a Falcon signature verification inside the VM and they are: /// /// 1. The nonce represented as 8 field elements. @@ -17,27 +13,30 @@ use vm_core::{ /// /// # Errors /// Will return an error if either: -/// - The keys are malformed due to either incorrect length or failed decoding. +/// - The secret key is malformed due to either incorrect length or failed decoding. /// - The signature generation failed. #[cfg(feature = "std")] -pub fn falcon_sign(pk_sk: &[Felt], msg: Word) -> Result, ExecutionError> { - // Create the corresponding key pair - let mut key_pair_bytes = Vec::with_capacity(pk_sk.len()); - for element in pk_sk { +pub fn falcon_sign(sk: &[Felt], msg: Word) -> Result, ExecutionError> { + use vm_core::{ + crypto::dsa::rpo_falcon512::{Polynomial, SecretKey}, + utils::Deserializable, + }; + + // Create the corresponding secret key + let mut sk_bytes = Vec::with_capacity(sk.len()); + for element in sk { let value = element.as_int(); if value > u8::MAX as u64 { return Err(ExecutionError::MalformedSignatureKey("RPO Falcon512")); } - key_pair_bytes.push(value as u8); + sk_bytes.push(value as u8); } - let key_pair = KeyPair::read_from_bytes(&key_pair_bytes) + let sk = SecretKey::read_from_bytes(&sk_bytes) .map_err(|_| ExecutionError::MalformedSignatureKey("RPO Falcon512"))?; // We can now generate the signature - let sig = key_pair - .sign(msg) - .map_err(|_| ExecutionError::FailedSignatureGeneration("RPO Falcon512"))?; + let sig = sk.sign(msg); // The signature is composed of a nonce and a polynomial s2 @@ -45,29 +44,29 @@ pub fn falcon_sign(pk_sk: &[Felt], msg: Word) -> Result, ExecutionErro let nonce = sig.nonce(); // We convert the signature to a polynomial - let s2: Polynomial = sig.sig_poly(); + let s2 = sig.sig_poly(); // We also need in the VM the expanded key corresponding to the public key the was provided // via the operand stack - let h: Polynomial = sig.pub_key_poly(); + let h = sk.compute_pub_key_poly().0; // Lastly, for the probabilistic product routine that is part of the verification procedure, // we need to compute the product of the expanded key and the signature polynomial in // the ring of polynomials with coefficients in the Miden field. - let pi = Polynomial::mul_modulo_p(&h, &s2); + let pi = Polynomial::mul_modulo_p(&h, s2); // We now push the nonce, the expanded key, the signature polynomial, and the product of the // expanded key and the signature polynomial to the advice stack. - let mut result: Vec = nonce.to_vec(); - result.extend(h.inner().iter().map(|a| Felt::from(*a))); - result.extend(s2.inner().iter().map(|a| Felt::from(*a))); + let mut result: Vec = nonce.to_elements().to_vec(); + result.extend(h.coefficients.iter().map(|a| Felt::from(a.value() as u32))); + result.extend(s2.coefficients.iter().map(|a| Felt::from(a.value() as u32))); result.extend(pi.iter().map(|a| Felt::new(*a))); result.reverse(); Ok(result) } #[cfg(not(feature = "std"))] -pub fn falcon_sign(pk_sk: &[Felt], msg: Word) -> Result, ExecutionError> { +pub fn falcon_sign(sk: &[Felt], msg: Word) -> Result, ExecutionError> { Err(ExecutionError::FailedSignatureGeneration( "RPO Falcon512 signature generation is not available in no_std context", )) diff --git a/processor/src/host/advice/injectors/smt.rs b/processor/src/host/advice/injectors/smt.rs index f7c96d7f62..4438f4abf5 100644 --- a/processor/src/host/advice/injectors/smt.rs +++ b/processor/src/host/advice/injectors/smt.rs @@ -1,5 +1,6 @@ use super::super::{AdviceSource, ExecutionError, Felt, HostResponse, Word}; -use crate::{utils::collections::*, AdviceProvider, ProcessState}; +use crate::{AdviceProvider, ProcessState}; +use alloc::vec::Vec; use vm_core::{ crypto::{ hash::RpoDigest, diff --git a/processor/src/host/advice/inputs.rs b/processor/src/host/advice/inputs.rs index c289222aae..c23dd59368 100644 --- a/processor/src/host/advice/inputs.rs +++ b/processor/src/host/advice/inputs.rs @@ -1,7 +1,6 @@ -use vm_core::crypto::hash::RpoDigest; - use super::{AdviceMap, Felt, InnerNodeInfo, InputError, MerkleStore}; -use crate::utils::collections::*; +use alloc::vec::Vec; +use vm_core::crypto::hash::RpoDigest; // ADVICE INPUTS // ================================================================================================ diff --git a/processor/src/host/advice/map.rs b/processor/src/host/advice/map.rs index 62a0b393ce..aeb3217334 100644 --- a/processor/src/host/advice/map.rs +++ b/processor/src/host/advice/map.rs @@ -1,6 +1,8 @@ use super::Felt; -use crate::utils::collections::*; -use vm_core::{crypto::hash::RpoDigest, utils::collections::btree_map::IntoIter}; +use alloc::collections::btree_map::IntoIter; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; +use vm_core::crypto::hash::RpoDigest; // ADVICE MAP // ================================================================================================ diff --git a/processor/src/host/advice/mod.rs b/processor/src/host/advice/mod.rs index a217462f0a..98723e5c0f 100644 --- a/processor/src/host/advice/mod.rs +++ b/processor/src/host/advice/mod.rs @@ -1,12 +1,12 @@ use super::HostResponse; use crate::{ExecutionError, Felt, InputError, ProcessState, Word}; +use alloc::vec::Vec; use core::borrow::Borrow; use vm_core::{ crypto::{ hash::RpoDigest, merkle::{InnerNodeInfo, MerklePath, MerkleStore, NodeIndex, StoreNode}, }, - utils::collections::*, AdviceInjector, SignatureKind, }; diff --git a/processor/src/host/advice/providers.rs b/processor/src/host/advice/providers.rs index 6453f7d1da..3b5b6e186e 100644 --- a/processor/src/host/advice/providers.rs +++ b/processor/src/host/advice/providers.rs @@ -1,8 +1,13 @@ +use crate::ProcessState; + use super::{ injectors, AdviceInputs, AdviceProvider, AdviceSource, ExecutionError, Felt, MerklePath, MerkleStore, NodeIndex, RpoDigest, StoreNode, Word, }; -use crate::{utils::collections::*, ProcessState}; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; +use vm_core::utils::collections::KvMap; +use vm_core::utils::collections::RecordingMap; use vm_core::SignatureKind; // TYPE ALIASES diff --git a/processor/src/host/debug.rs b/processor/src/host/debug.rs index 1cd9810e13..a72188768b 100644 --- a/processor/src/host/debug.rs +++ b/processor/src/host/debug.rs @@ -1,5 +1,8 @@ +use std::{print, println}; + use super::ProcessState; -use crate::{system::ContextId, utils::collections::*}; +use crate::system::ContextId; +use alloc::vec::Vec; use vm_core::{DebugOptions, Word}; // DEBUG HANDLER diff --git a/processor/src/host/mod.rs b/processor/src/host/mod.rs index c2817ff55b..7886563aeb 100644 --- a/processor/src/host/mod.rs +++ b/processor/src/host/mod.rs @@ -62,7 +62,7 @@ pub trait Host { event_id: u32, ) -> Result { #[cfg(feature = "std")] - println!( + std::println!( "Event with id {} emitted at step {} in context {}", event_id, process.clk(), @@ -89,7 +89,7 @@ pub trait Host { trace_id: u32, ) -> Result { #[cfg(feature = "std")] - println!( + std::println!( "Trace with id {} emitted at step {} in context {}", trace_id, process.clk(), diff --git a/processor/src/lib.rs b/processor/src/lib.rs index 1db3b5d73d..d885436c61 100644 --- a/processor/src/lib.rs +++ b/processor/src/lib.rs @@ -1,9 +1,12 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] + +#[cfg(feature = "std")] +extern crate std; -#[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; +use alloc::vec::Vec; use core::cell::RefCell; use miden_air::trace::{ @@ -20,7 +23,6 @@ use vm_core::{ code_blocks::{ Call, CodeBlock, Dyn, Join, Loop, OpBatch, Span, Split, OP_BATCH_SIZE, OP_GROUP_SIZE, }, - utils::collections::*, CodeBlockTable, Decorator, DecoratorIterator, FieldElement, StackTopState, }; diff --git a/processor/src/operations/comb_ops.rs b/processor/src/operations/comb_ops.rs index 4ef439bb61..1139ce06de 100644 --- a/processor/src/operations/comb_ops.rs +++ b/processor/src/operations/comb_ops.rs @@ -171,12 +171,12 @@ where #[cfg(test)] mod tests { - use crate::utils::collections::*; + use crate::{ContextId, Process, QuadFelt}; + use alloc::borrow::ToOwned; + use alloc::vec::Vec; use test_utils::{build_test, rand::rand_array}; use vm_core::{Felt, FieldElement, Operation, StackInputs, ONE, ZERO}; - use crate::{ContextId, Process, QuadFelt}; - #[test] fn rcombine_main() { // --- build stack inputs ----------------------------------------------------------------- diff --git a/processor/src/operations/crypto_ops.rs b/processor/src/operations/crypto_ops.rs index 1c4118883e..9bde3bc835 100644 --- a/processor/src/operations/crypto_ops.rs +++ b/processor/src/operations/crypto_ops.rs @@ -185,11 +185,11 @@ mod tests { Process, }; use crate::{AdviceInputs, StackInputs, Word, ZERO}; + use alloc::vec::Vec; use test_utils::rand::rand_vector; use vm_core::{ chiplets::hasher::{apply_permutation, STATE_WIDTH}, crypto::merkle::{MerkleStore, MerkleTree, NodeIndex}, - utils::collections::*, }; #[test] diff --git a/processor/src/operations/fri_ops.rs b/processor/src/operations/fri_ops.rs index 72646c4792..30f13358c7 100644 --- a/processor/src/operations/fri_ops.rs +++ b/processor/src/operations/fri_ops.rs @@ -243,8 +243,9 @@ mod tests { use super::{ ExtensionOf, Felt, FieldElement, Operation, Process, QuadFelt, StarkField, TWO, TWO_INV, }; + use alloc::vec::Vec; use test_utils::rand::{rand_array, rand_value, rand_vector}; - use vm_core::{utils::collections::*, StackInputs}; + use vm_core::StackInputs; use winter_prover::math::{fft, get_power_series_with_offset}; use winter_utils::transpose_slice; diff --git a/processor/src/range/aux_trace.rs b/processor/src/range/aux_trace.rs index cd93359f45..71b47f7bb6 100644 --- a/processor/src/range/aux_trace.rs +++ b/processor/src/range/aux_trace.rs @@ -1,5 +1,6 @@ use super::{uninit_vector, Felt, FieldElement, NUM_RAND_ROWS}; -use crate::utils::collections::*; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; use miden_air::trace::main_trace::MainTrace; use miden_air::trace::range::{M_COL_IDX, V_COL_IDX}; diff --git a/processor/src/range/mod.rs b/processor/src/range/mod.rs index 51f4a220cb..4512e96d52 100644 --- a/processor/src/range/mod.rs +++ b/processor/src/range/mod.rs @@ -1,5 +1,7 @@ use super::{trace::NUM_RAND_ROWS, Felt, FieldElement, RangeCheckTrace, ZERO}; -use crate::utils::{collections::*, uninit_vector}; +use crate::utils::uninit_vector; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; mod aux_trace; pub use aux_trace::AuxTraceBuilder; diff --git a/processor/src/range/tests.rs b/processor/src/range/tests.rs index 650ff58c03..9eb173aa59 100644 --- a/processor/src/range/tests.rs +++ b/processor/src/range/tests.rs @@ -1,7 +1,8 @@ use super::{Felt, RangeChecker, ZERO}; use crate::{utils::get_trace_len, RangeCheckTrace}; +use alloc::{collections::BTreeMap, vec::Vec}; use test_utils::rand::rand_array; -use vm_core::utils::{collections::*, ToElements}; +use vm_core::utils::ToElements; #[test] fn range_checks() { diff --git a/processor/src/stack/aux_trace.rs b/processor/src/stack/aux_trace.rs index 325a642227..2f42ca816a 100644 --- a/processor/src/stack/aux_trace.rs +++ b/processor/src/stack/aux_trace.rs @@ -1,5 +1,6 @@ use super::{Felt, FieldElement, OverflowTableRow}; -use crate::{trace::AuxColumnBuilder, utils::collections::*}; +use crate::trace::AuxColumnBuilder; +use alloc::vec::Vec; use miden_air::trace::main_trace::MainTrace; // AUXILIARY TRACE BUILDER diff --git a/processor/src/stack/mod.rs b/processor/src/stack/mod.rs index 492fd388ba..f5035c04cc 100644 --- a/processor/src/stack/mod.rs +++ b/processor/src/stack/mod.rs @@ -1,5 +1,5 @@ use super::{Felt, FieldElement, StackInputs, StackOutputs, ONE, STACK_TRACE_WIDTH, ZERO}; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::cmp; use vm_core::{stack::STACK_TOP_SIZE, Word, WORD_SIZE}; diff --git a/processor/src/stack/overflow.rs b/processor/src/stack/overflow.rs index 96be4bf725..e4c2e3dc29 100644 --- a/processor/src/stack/overflow.rs +++ b/processor/src/stack/overflow.rs @@ -1,5 +1,6 @@ use super::{AuxTraceBuilder, Felt, FieldElement, ZERO}; -use crate::utils::collections::*; +use alloc::collections::BTreeMap; +use alloc::vec::Vec; use vm_core::{utils::uninit_vector, StarkField}; // OVERFLOW TABLE diff --git a/processor/src/stack/tests.rs b/processor/src/stack/tests.rs index 78c5b3517a..c7a9a06a07 100644 --- a/processor/src/stack/tests.rs +++ b/processor/src/stack/tests.rs @@ -1,11 +1,12 @@ use super::{ super::StackTopState, Felt, OverflowTableRow, Stack, StackInputs, ONE, STACK_TOP_SIZE, ZERO, }; +use alloc::vec::Vec; use miden_air::trace::{ stack::{B0_COL_IDX, B1_COL_IDX, H0_COL_IDX, NUM_STACK_HELPER_COLS}, STACK_TRACE_WIDTH, }; -use vm_core::{utils::collections::*, FieldElement, StarkField}; +use vm_core::{FieldElement, StarkField}; // TYPE ALIASES // ================================================================================================ diff --git a/processor/src/stack/trace.rs b/processor/src/stack/trace.rs index a4fbee690b..a3eec3abe2 100644 --- a/processor/src/stack/trace.rs +++ b/processor/src/stack/trace.rs @@ -1,7 +1,8 @@ use super::{ super::utils::get_trace_len, Felt, FieldElement, MAX_TOP_IDX, ONE, STACK_TRACE_WIDTH, ZERO, }; -use crate::utils::{collections::*, math::batch_inversion}; +use crate::utils::math::batch_inversion; +use alloc::vec::Vec; use miden_air::trace::stack::{H0_COL_IDX, NUM_STACK_HELPER_COLS, STACK_TOP_SIZE}; // STACK TRACE diff --git a/processor/src/system/mod.rs b/processor/src/system/mod.rs index 7c4cceb05c..3a4ec059c6 100644 --- a/processor/src/system/mod.rs +++ b/processor/src/system/mod.rs @@ -1,5 +1,5 @@ use super::{ExecutionError, Felt, FieldElement, SysTrace, Word, EMPTY_WORD, ONE, ZERO}; -use crate::utils::collections::*; +use alloc::vec::Vec; use core::fmt::{self, Display}; #[cfg(test)] diff --git a/processor/src/trace/mod.rs b/processor/src/trace/mod.rs index 0124e41d9e..38ee581400 100644 --- a/processor/src/trace/mod.rs +++ b/processor/src/trace/mod.rs @@ -5,7 +5,7 @@ use super::{ stack::AuxTraceBuilder as StackAuxTraceBuilder, ColMatrix, Digest, Felt, FieldElement, Host, Process, StackTopState, }; -use crate::utils::collections::*; +use alloc::vec::Vec; use miden_air::trace::{ decoder::{NUM_USER_OP_HELPERS, USER_OP_HELPERS_OFFSET}, main_trace::MainTrace, @@ -165,7 +165,7 @@ impl ExecutionTrace { let mut row = [ZERO; TRACE_WIDTH]; for i in 0..self.length() { self.main_trace.read_row_into(i, &mut row); - println!("{:?}", row.iter().map(|v| v.as_int()).collect::>()); + std::println!("{:?}", row.iter().map(|v| v.as_int()).collect::>()); } } diff --git a/processor/src/trace/tests/chiplets/hasher.rs b/processor/src/trace/tests/chiplets/hasher.rs index f661718a31..e33fe4630b 100644 --- a/processor/src/trace/tests/chiplets/hasher.rs +++ b/processor/src/trace/tests/chiplets/hasher.rs @@ -4,6 +4,7 @@ use super::{ Trace, AUX_TRACE_RAND_ELEMENTS, CHIPLETS_AUX_TRACE_OFFSET, NUM_RAND_ROWS, ONE, ZERO, }; use crate::StackInputs; +use alloc::vec::Vec; use core::ops::Range; use miden_air::trace::{ chiplets::{ @@ -22,7 +23,7 @@ use vm_core::{ chiplets::hasher::apply_permutation, code_blocks::CodeBlock, crypto::merkle::{MerkleStore, MerkleTree, NodeIndex}, - utils::{collections::*, range}, + utils::range, Word, }; diff --git a/processor/src/trace/tests/hasher.rs b/processor/src/trace/tests/hasher.rs index aa3ae82bf5..9122e2f38e 100644 --- a/processor/src/trace/tests/hasher.rs +++ b/processor/src/trace/tests/hasher.rs @@ -3,7 +3,8 @@ use super::{ build_trace_from_ops_with_inputs, rand_array, AdviceInputs, Felt, Operation, Word, ONE, ZERO, }; -use crate::{utils::collections::*, StackInputs}; +use crate::StackInputs; +use alloc::vec::Vec; use miden_air::trace::{ chiplets::hasher::P1_COL_IDX, main_trace::MainTrace, AUX_TRACE_RAND_ELEMENTS, }; diff --git a/processor/src/trace/tests/mod.rs b/processor/src/trace/tests/mod.rs index 2fd2c5b4bc..35e41e26d2 100644 --- a/processor/src/trace/tests/mod.rs +++ b/processor/src/trace/tests/mod.rs @@ -2,10 +2,8 @@ use super::{ super::chiplets::init_state_from_words, ExecutionTrace, Felt, FieldElement, Process, Trace, NUM_RAND_ROWS, }; -use crate::{ - utils::collections::*, AdviceInputs, DefaultHost, ExecutionOptions, MemAdviceProvider, - StackInputs, -}; +use crate::{AdviceInputs, DefaultHost, ExecutionOptions, MemAdviceProvider, StackInputs}; +use alloc::vec::Vec; use test_utils::rand::rand_array; use vm_core::{ code_blocks::CodeBlock, CodeBlockTable, Kernel, Operation, StackOutputs, Word, ONE, ZERO, diff --git a/processor/src/trace/tests/stack.rs b/processor/src/trace/tests/stack.rs index ec32f2e3b1..38698f892d 100644 --- a/processor/src/trace/tests/stack.rs +++ b/processor/src/trace/tests/stack.rs @@ -2,7 +2,8 @@ use super::{ build_trace_from_ops, rand_array, Felt, FieldElement, Operation, Trace, NUM_RAND_ROWS, ONE, ZERO, }; -use crate::{stack::OverflowTableRow, utils::collections::*}; +use crate::stack::OverflowTableRow; +use alloc::vec::Vec; use miden_air::trace::{AUX_TRACE_RAND_ELEMENTS, STACK_AUX_TRACE_OFFSET}; // CONSTANTS diff --git a/processor/src/trace/utils.rs b/processor/src/trace/utils.rs index 848e63f8a5..e321aaa344 100644 --- a/processor/src/trace/utils.rs +++ b/processor/src/trace/utils.rs @@ -1,8 +1,6 @@ use super::{Felt, FieldElement, NUM_RAND_ROWS}; -use crate::{ - chiplets::Chiplets, - utils::{collections::*, uninit_vector}, -}; +use crate::{chiplets::Chiplets, utils::uninit_vector}; +use alloc::vec::Vec; use core::slice; use miden_air::trace::main_trace::MainTrace; diff --git a/processor/src/utils.rs b/processor/src/utils.rs index 7c316a1699..503b7e122b 100644 --- a/processor/src/utils.rs +++ b/processor/src/utils.rs @@ -1,5 +1,5 @@ use super::Felt; -use collections::*; +use alloc::vec::Vec; // RE-EXPORTS // ================================================================================================ diff --git a/stdlib/tests/collections/mmr.rs b/stdlib/tests/collections/mmr.rs index 83f3c02402..315b4176b6 100644 --- a/stdlib/tests/collections/mmr.rs +++ b/stdlib/tests/collections/mmr.rs @@ -1,5 +1,4 @@ use test_utils::{ - collections::*, crypto::{ init_merkle_leaf, init_merkle_leaves, MerkleError, MerkleStore, MerkleTree, Mmr, NodeIndex, RpoDigest, diff --git a/stdlib/tests/crypto/falcon.rs b/stdlib/tests/crypto/falcon.rs index c0e5aa306a..9b9a6b50bc 100644 --- a/stdlib/tests/crypto/falcon.rs +++ b/stdlib/tests/crypto/falcon.rs @@ -1,18 +1,22 @@ use assembly::{utils::Serializable, Assembler}; use miden_air::{Felt, ProvingOptions}; use miden_stdlib::StdLibrary; -use processor::{AdviceInputs, DefaultHost, Digest, MemAdviceProvider, StackInputs}; +use processor::{ + crypto::RpoRandomCoin, AdviceInputs, DefaultHost, Digest, MemAdviceProvider, StackInputs, +}; use test_utils::{ - crypto::{rpo_falcon512::KeyPair, MerkleStore}, + crypto::{rpo_falcon512::SecretKey, MerkleStore}, rand::rand_vector, ProgramInfo, Word, }; #[test] fn falcon_execution() { - let keypair = KeyPair::new().unwrap(); + let seed = Word::default(); + let mut rng = RpoRandomCoin::new(seed); + let sk = SecretKey::with_rng(&mut rng); let message = rand_vector::(4).try_into().unwrap(); - let (source, op_stack, adv_stack, store, advice_map) = generate_test(keypair, message); + let (source, op_stack, adv_stack, store, advice_map) = generate_test(sk, message); let test = build_test!(source, &op_stack, &adv_stack, store, advice_map.into_iter()); test.expect_stack(&[]) @@ -21,9 +25,9 @@ fn falcon_execution() { #[test] #[ignore] fn falcon_prove_verify() { - let keypair = KeyPair::new().unwrap(); + let sk = SecretKey::new(); let message = rand_vector::(4).try_into().unwrap(); - let (source, op_stack, _, _, advice_map) = generate_test(keypair, message); + let (source, op_stack, _, _, advice_map) = generate_test(sk, message); let program = Assembler::default() .with_library(&StdLibrary::default()) @@ -47,7 +51,7 @@ fn falcon_prove_verify() { } fn generate_test( - keypair: KeyPair, + sk: SecretKey, message: Word, ) -> (&'static str, Vec, Vec, MerkleStore, Vec<(Digest, Vec)>) { let source = " @@ -58,11 +62,11 @@ fn generate_test( end "; - let pk: Word = keypair.public_key().into(); + let pk: Word = sk.public_key().into(); let pk: Digest = pk.into(); - let pk_sk_bytes = keypair.to_bytes(); + let sk_bytes = sk.to_bytes(); - let to_adv_map = pk_sk_bytes.iter().map(|a| Felt::new(*a as u64)).collect::>(); + let to_adv_map = sk_bytes.iter().map(|a| Felt::new(*a as u64)).collect::>(); let advice_map: Vec<(Digest, Vec)> = vec![(pk, to_adv_map)]; diff --git a/stdlib/tests/crypto/fri/mod.rs b/stdlib/tests/crypto/fri/mod.rs index 69b6350235..6e27294517 100644 --- a/stdlib/tests/crypto/fri/mod.rs +++ b/stdlib/tests/crypto/fri/mod.rs @@ -1,5 +1,6 @@ use processor::Digest; -use test_utils::{collections::BTreeMap, crypto::MerkleStore, Felt, StarkField}; +use std::collections::BTreeMap; +use test_utils::{crypto::MerkleStore, Felt, StarkField}; mod channel; diff --git a/stdlib/tests/crypto/stark/verifier_recursive/channel.rs b/stdlib/tests/crypto/stark/verifier_recursive/channel.rs index 61864c34f3..e2aedaeae3 100644 --- a/stdlib/tests/crypto/stark/verifier_recursive/channel.rs +++ b/stdlib/tests/crypto/stark/verifier_recursive/channel.rs @@ -3,7 +3,6 @@ use miden_air::ProcessorAir; use test_utils::{ - collections::*, crypto::{BatchMerkleProof, MerklePath, PartialMerkleTree, Rpo256, RpoDigest}, group_vector_elements, math::{FieldElement, QuadExtension, StarkField}, diff --git a/stdlib/tests/crypto/stark/verifier_recursive/mod.rs b/stdlib/tests/crypto/stark/verifier_recursive/mod.rs index e698b9092a..a84caa5399 100644 --- a/stdlib/tests/crypto/stark/verifier_recursive/mod.rs +++ b/stdlib/tests/crypto/stark/verifier_recursive/mod.rs @@ -1,7 +1,6 @@ use miden_air::ProcessorAir; use processor::crypto::RpoRandomCoin; use test_utils::{ - collections::*, crypto::{MerkleStore, RandomCoin, Rpo256, RpoDigest}, math::{fft, FieldElement, QuadExtension, StarkField, ToElements}, Felt, VerifierError, diff --git a/test-utils/src/crypto.rs b/test-utils/src/crypto.rs index c4ffe45c6c..953c8ca851 100644 --- a/test-utils/src/crypto.rs +++ b/test-utils/src/crypto.rs @@ -1,4 +1,5 @@ -use super::{collections::*, Felt, Word, ZERO}; +use super::{Felt, Word, ZERO}; +use alloc::vec::Vec; // RE-EXPORTS // ================================================================================================ diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs index f7c7f28bc2..1ef1712fad 100644 --- a/test-utils/src/lib.rs +++ b/test-utils/src/lib.rs @@ -1,18 +1,18 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] + +#[cfg(feature = "std")] +extern crate std; -#[cfg(not(feature = "std"))] #[macro_use] extern crate alloc; +use alloc::{string::String, vec::Vec}; // IMPORTS // ================================================================================================ #[cfg(not(target_family = "wasm"))] use proptest::prelude::{Arbitrary, Strategy}; -use vm_core::{ - chiplets::hasher::apply_permutation, - utils::{collections::*, string::*}, -}; +use vm_core::chiplets::hasher::apply_permutation; // EXPORTS // ================================================================================================ diff --git a/test-utils/src/test_builders.rs b/test-utils/src/test_builders.rs index dbcec147ee..564594e5d3 100644 --- a/test-utils/src/test_builders.rs +++ b/test-utils/src/test_builders.rs @@ -107,7 +107,7 @@ macro_rules! build_test_by_mode { .with_merkle_store(store); $crate::Test { - source: String::from($source), + source: std::string::String::from($source), kernel: None, stack_inputs, advice_inputs, diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index f704758ec6..63a53a4b23 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -1,13 +1,16 @@ -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] + +#[cfg(feature = "std")] +extern crate std; + +#[macro_use] +extern crate alloc; use air::{HashFunction, ProcessorAir, ProvingOptions, PublicInputs}; use core::fmt; -use vm_core::{ - crypto::{ - hash::{Blake3_192, Blake3_256, Rpo256}, - random::{RpoRandomCoin, WinterRandomCoin}, - }, - utils::vec, +use vm_core::crypto::{ + hash::{Blake3_192, Blake3_256, Rpo256}, + random::{RpoRandomCoin, WinterRandomCoin}, }; use winter_verifier::verify as verify_proof;