From 44a031e033f417032d5c45f430fb8b02e2fe3a93 Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Fri, 22 Mar 2024 19:41:15 +0100 Subject: [PATCH 01/12] chore: fix no-std errors --- air/src/constraints/chiplets/bitwise/mod.rs | 3 ++- air/src/constraints/chiplets/hasher/mod.rs | 3 ++- air/src/constraints/chiplets/hasher/tests.rs | 2 +- air/src/constraints/chiplets/memory/mod.rs | 3 ++- air/src/constraints/chiplets/memory/tests.rs | 3 ++- air/src/constraints/chiplets/mod.rs | 3 ++- air/src/constraints/range.rs | 4 +++- air/src/constraints/stack/field_ops/mod.rs | 3 ++- air/src/constraints/stack/io_ops/mod.rs | 6 ++---- air/src/constraints/stack/mod.rs | 3 ++- air/src/constraints/stack/overflow/mod.rs | 3 ++- .../constraints/stack/stack_manipulation/mod.rs | 3 ++- air/src/constraints/stack/system_ops/mod.rs | 6 ++---- air/src/constraints/stack/u32_ops/mod.rs | 3 ++- air/src/errors.rs | 3 ++- air/src/lib.rs | 14 +++++++++----- air/src/proof.rs | 5 ++--- air/src/trace/main_trace.rs | 2 +- air/src/utils.rs | 4 ++-- assembly/src/assembler/context.rs | 8 ++++---- .../src/assembler/instruction/procedures.rs | 2 +- assembly/src/assembler/mod.rs | 10 +++++----- assembly/src/assembler/module_provider.rs | 3 ++- assembly/src/assembler/procedure_cache.rs | 5 ++--- assembly/src/assembler/span_builder.rs | 3 ++- assembly/src/assembler/tests.rs | 2 ++ assembly/src/ast/code_body.rs | 2 +- assembly/src/ast/format.rs | 2 +- assembly/src/ast/imports.rs | 4 +++- assembly/src/ast/mod.rs | 4 +++- assembly/src/ast/module.rs | 3 ++- assembly/src/ast/nodes/advice.rs | 2 +- assembly/src/ast/nodes/mod.rs | 2 +- assembly/src/ast/nodes/serde/debug.rs | 2 +- assembly/src/ast/nodes/serde/deserialization.rs | 2 +- assembly/src/ast/nodes/serde/mod.rs | 2 +- assembly/src/ast/nodes/serde/signatures.rs | 2 +- assembly/src/ast/parsers/constants.rs | 4 +++- assembly/src/ast/parsers/context.rs | 3 ++- assembly/src/ast/parsers/io_ops.rs | 3 ++- assembly/src/ast/parsers/labels.rs | 3 ++- assembly/src/ast/parsers/mod.rs | 7 +++---- assembly/src/ast/procedure.rs | 6 +++++- assembly/src/ast/program.rs | 3 ++- assembly/src/ast/tests.rs | 6 +++++- assembly/src/errors.rs | 5 ++++- assembly/src/lib.rs | 7 ++++--- assembly/src/library/masl.rs | 4 +++- assembly/src/library/mod.rs | 2 +- assembly/src/library/path.rs | 2 +- assembly/src/library/tests.rs | 1 + assembly/src/procedures/mod.rs | 6 +++++- assembly/src/tests.rs | 1 + assembly/src/tokens/lines.rs | 2 +- assembly/src/tokens/mod.rs | 6 +++++- assembly/src/tokens/stream.rs | 2 +- core/src/errors.rs | 3 ++- core/src/lib.rs | 6 ++++-- core/src/operations/decorators/assembly_op.rs | 2 +- core/src/operations/decorators/mod.rs | 2 +- core/src/program/blocks/join_block.rs | 2 +- core/src/program/blocks/loop_block.rs | 2 +- core/src/program/blocks/mod.rs | 2 +- core/src/program/blocks/span_block.rs | 3 ++- core/src/program/blocks/split_block.rs | 2 +- core/src/program/info.rs | 2 +- core/src/program/mod.rs | 5 ++--- core/src/program/tests.rs | 1 + core/src/stack/inputs.rs | 6 ++++-- core/src/stack/outputs.rs | 3 ++- core/src/utils/mod.rs | 6 +++--- processor/src/debug.rs | 9 ++++----- processor/src/errors.rs | 2 +- processor/src/host/advice/injectors/smt.rs | 3 ++- processor/src/host/advice/inputs.rs | 5 ++--- processor/src/host/advice/map.rs | 6 ++++-- processor/src/host/advice/mod.rs | 2 +- processor/src/host/advice/providers.rs | 7 ++++++- processor/src/host/debug.rs | 5 ++++- processor/src/host/mod.rs | 2 ++ processor/src/lib.rs | 8 +++++--- processor/src/operations/comb_ops.rs | 4 ++-- processor/src/range/aux_trace.rs | 3 ++- processor/src/range/mod.rs | 4 +++- processor/src/stack/aux_trace.rs | 3 ++- processor/src/stack/mod.rs | 2 +- processor/src/stack/overflow.rs | 3 ++- processor/src/stack/trace.rs | 3 ++- processor/src/system/mod.rs | 2 +- processor/src/trace/mod.rs | 4 ++-- processor/src/trace/utils.rs | 6 ++---- processor/src/utils.rs | 2 +- test-utils/src/lib.rs | 12 ++++++------ test-utils/src/test_builders.rs | 2 +- verifier/src/lib.rs | 17 ++++++++++------- 95 files changed, 224 insertions(+), 148 deletions(-) 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/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..3407afbcdd 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 winter_utils::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/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/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/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..b18c93af58 100644 --- a/processor/src/host/mod.rs +++ b/processor/src/host/mod.rs @@ -1,3 +1,5 @@ +use std::println; + use super::{ExecutionError, Felt, ProcessState}; use crate::MemAdviceProvider; use vm_core::{crypto::merkle::MerklePath, AdviceInjector, DebugOptions, Word}; 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..19ce0ef593 100644 --- a/processor/src/operations/comb_ops.rs +++ b/processor/src/operations/comb_ops.rs @@ -172,11 +172,11 @@ where #[cfg(test)] mod tests { use crate::utils::collections::*; + use crate::{ContextId, Process, QuadFelt}; + use alloc::borrow::ToOwned; 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/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/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/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/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/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; From ef19206291e9fb9dc1556f6f12adcaabff7c435f Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Tue, 28 May 2024 12:06:09 +0200 Subject: [PATCH 02/12] feat: migrate to new padding rule --- Cargo.lock | 234 +++++++++--------- .../src/assembler/instruction/crypto_ops.rs | 12 +- core/Cargo.toml | 3 +- stdlib/asm/crypto/hashes/native.masm | 10 +- stdlib/asm/mem.masm | 15 +- 5 files changed, 143 insertions(+), 131 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fd88568cf..5bee90e488 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,18 +4,18 @@ version = 3 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -129,23 +129,23 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -219,7 +219,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", - "regex-automata 0.4.7", + "regex-automata 0.4.8", "serde", ] @@ -243,9 +243,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.13" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "jobserver", "libc", @@ -287,9 +287,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -297,9 +297,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -309,9 +309,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck", "proc-macro2", @@ -342,9 +342,9 @@ checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core-foundation" @@ -375,9 +375,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -556,9 +556,9 @@ dependencies = [ [[package]] name = "error-code" -version = "3.2.0" +version = "3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" [[package]] name = "escargot" @@ -574,9 +574,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "fixedbitset" @@ -689,9 +689,9 @@ dependencies = [ [[package]] name = "generator" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "979f00864edc7516466d6b3157706e06c032f22715700ddd878228a91d02bc56" +checksum = "dbb949699c3e4df3a183b1d2142cb24277057055ed23c68ed58894f76c517223" dependencies = [ "cfg-if", "libc", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "glob" @@ -775,9 +775,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", @@ -870,7 +870,7 @@ dependencies = [ "lalrpop-util", "petgraph", "regex", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "string_cache", "term", "tiny-keccak", @@ -892,9 +892,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libm" @@ -1024,7 +1024,7 @@ dependencies = [ "miden-thiserror", "pretty_assertions", "regex", - "rustc_version 0.4.0", + "rustc_version 0.4.1", "smallvec", "tracing", "unicode-width", @@ -1052,9 +1052,8 @@ dependencies = [ [[package]] name = "miden-crypto" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6fad06fc3af260ed3c4235821daa2132813d993f96d446856036ae97e9606dd" +version = "0.10.1" +source = "git+https://github.com/0xPolygonMiden/crypto?branch=al-rpo-new-padding-rule#c83729c46fceb4b0c18e69cec016d25df9cfb742" dependencies = [ "blake3", "cc", @@ -1259,11 +1258,11 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -1405,18 +1404,21 @@ dependencies = [ [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "oorandom" @@ -1432,9 +1434,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "4.0.0" +version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" +checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" [[package]] name = "parking_lot" @@ -1498,9 +1500,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -1511,15 +1513,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -1530,6 +1532,12 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -1577,9 +1585,9 @@ dependencies = [ [[package]] name = "pretty_assertions" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" dependencies = [ "diff", "yansi", @@ -1608,7 +1616,7 @@ dependencies = [ "rand", "rand_chacha", "rand_xorshift", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", "rusty-fork", "tempfile", "unarray", @@ -1622,9 +1630,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1690,9 +1698,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -1710,14 +1718,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.7", - "regex-syntax 0.8.4", + "regex-automata 0.4.8", + "regex-syntax 0.8.5", ] [[package]] @@ -1731,13 +1739,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.4", + "regex-syntax 0.8.5", ] [[package]] @@ -1748,9 +1756,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-demangle" @@ -1769,18 +1777,18 @@ dependencies = [ [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver 1.0.23", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -1876,18 +1884,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -1896,9 +1904,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", "memchr", @@ -1908,9 +1916,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -2011,9 +2019,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "supports-color" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" +checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" dependencies = [ "is_ci", ] @@ -2032,9 +2040,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "syn" -version = "2.0.75" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -2043,9 +2051,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -2136,18 +2144,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -2206,9 +2214,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "serde", @@ -2320,9 +2328,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-linebreak" @@ -2332,21 +2340,21 @@ checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "utf8parse" @@ -2727,9 +2735,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -2772,9 +2780,9 @@ dependencies = [ [[package]] name = "winter-math" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "004f85bb051ce986ec0b9a2bd90aaf81b83e3c67464becfdf7db31f14c1019ba" +checksum = "5b0e685b3b872d82e58a86519294a814b7bc7a4d3cd2c93570a7d80c0c5a1aba" dependencies = [ "winter-utils", ] @@ -2817,9 +2825,9 @@ dependencies = [ [[package]] name = "winter-utils" -version = "0.9.1" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0568612a95bcae3c94fb14da2686f8279ca77723dbdf1e97cf3673798faf6485" +checksum = "961e81e9388877a25db1c034ba38253de2055f569633ae6a665d857a0556391b" dependencies = [ "rayon", ] @@ -2839,9 +2847,9 @@ dependencies = [ [[package]] name = "yansi" -version = "0.5.1" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" [[package]] name = "zerocopy" diff --git a/assembly/src/assembler/instruction/crypto_ops.rs b/assembly/src/assembler/instruction/crypto_ops.rs index 0031f1a79d..ef980e898c 100644 --- a/assembly/src/assembler/instruction/crypto_ops.rs +++ b/assembly/src/assembler/instruction/crypto_ops.rs @@ -1,4 +1,5 @@ -use vm_core::{AdviceInjector, Operation::*}; +use super::SpanBuilder; +use vm_core::{AdviceInjector, Felt, Operation::*}; use super::BasicBlockBuilder; use crate::AssemblyError; @@ -28,14 +29,15 @@ use crate::AssemblyError; pub(super) fn hash(block_builder: &mut BasicBlockBuilder) { #[rustfmt::skip] let ops = [ - // add 4 elements to the stack to be used as the capacity elements for the RPO permutation - Pad, Incr, Pad, Pad, Pad, + // add 4 elements to the stack to be used as the capacity elements for the RPO permutation. + // Since we are hashing 4 field elements, the first capacity element is set to 4. + Push(Felt::from(4_u32)), Pad, Pad, Pad, // swap capacity elements such that they are below the elements to be hashed SwapW, - // Duplicate capacity elements in the rate portion of the stack - Dup7, Dup7, Dup7, Dup7, + // add 4 ZERO elements for the second half of the rate portion + Pad, Dup7, Dup7, Dup7, // Apply a hashing permutation on the top 12 elements in the stack HPerm, diff --git a/core/Cargo.toml b/core/Cargo.toml index ae7da5c505..3dd8eeea4b 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -34,7 +34,8 @@ std = [ lock_api = { version = "0.4", features = ["arc_lock"] } math = { package = "winter-math", version = "0.9", default-features = false } memchr = { version = "2.7", default-features = false } -miden-crypto = { version = "0.10", default-features = false } +#miden-crypto = { version = "0.10", default-features = false } +miden-crypto = { git = "https://github.com/0xPolygonMiden/crypto", branch = "al-rpo-new-padding-rule", default-features = false } miden-formatting = { version = "0.1", default-features = false } miette = { package = "miden-miette", version = "7.1", default-features = false, features = [ "fancy-no-syscall", diff --git a/stdlib/asm/crypto/hashes/native.masm b/stdlib/asm/crypto/hashes/native.masm index 1cd8ac3355..4e8d572aaf 100644 --- a/stdlib/asm/crypto/hashes/native.masm +++ b/stdlib/asm/crypto/hashes/native.masm @@ -54,8 +54,8 @@ end #! Input: [start_addr, end_addr, ...] #! Output: [H, ...] #! Cycles: -#! even words: 48 cycles + 3 * words -#! odd words: 60 cycles + 3 * words +#! even words: 50 cycles + 3 * words +#! odd words: 62 cycles + 3 * words export.hash_memory # enforce `start_addr < end_addr` dup.1 dup.1 u32assert2 u32gt assert @@ -72,8 +72,8 @@ export.hash_memory movup.2 # stack: [start_addr, end_addr, is_odd, ...] - # prepare hasher state (12 cycles) - dup.2 push.0.0.0 padw padw + # prepare hasher state (14 cycles) + dup.2 mul.4 push.0.0.0 padw padw # stack: [C, B, A, start_addr, end_addr, is_odd, ...] # (4 + 3 * words cycles) @@ -89,7 +89,7 @@ export.hash_memory dup.13 mem_loadw # set the padding (9 cycles) - swapw dropw push.1.0.0.0 + swapw dropw push.0.0.0.0 # (1 cycles) hperm diff --git a/stdlib/asm/mem.masm b/stdlib/asm/mem.masm index f81508faf4..e4117a609f 100644 --- a/stdlib/asm/mem.masm +++ b/stdlib/asm/mem.masm @@ -84,8 +84,8 @@ end #! Input: [num_words, write_ptr, ...] #! Output: [HASH, write_ptr', ...] #! Cycles: -#! even num_words: 48 + 9 * num_words / 2 -#! odd num_words: 65 + 9 * round_down(num_words / 2) +#! even num_words: 50 + 9 * num_words / 2 +#! odd num_words: 67 + 9 * round_down(num_words / 2) export.pipe_words_to_memory.0 # check if there is an odd number of words (6 cycles) dup is_odd @@ -99,10 +99,11 @@ export.pipe_words_to_memory.0 sub dup.1 add swap # => [write_ptr, end_ptr, needs_padding, ...] - # Prepare the capacity word. For rescue prime optimized the first element is - # set to `1` when padding is used and `0` otherwse, this is determined by the - # `needs_padding` flag. (4 cycles) - dup.2 push.0.0.0 + # Prepare the capacity word. We use the padding rule which sets the first capacity + # element to `len % 8` where `len` is the length of the hashed sequence. Since `len % 8` + # is either equal to 0 or 4, this is determined by the `needs_padding` flag multiplied + # by 4. (6 cycles) + dup.2 mul.4 push.0.0.0 # => [A, write_ptr, end_ptr, needs_padding, ...] # set initial hasher state (8 cycles) @@ -141,7 +142,7 @@ export.pipe_words_to_memory.0 # => [B', A, write_ptr+1, ...] # Push padding word (4 cycles) - push.1.0.0.0 + push.0.0.0.0 # => [C, B', A, write_ptr+1, ...] # Run RPO permutation (1 cycles) From d636b2616468932e3219badc6b509106bedd4977 Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Tue, 28 May 2024 12:55:07 +0200 Subject: [PATCH 03/12] fix: clippy --- stdlib/docs/crypto/hashes/native.md | 2 +- stdlib/docs/mem.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/docs/crypto/hashes/native.md b/stdlib/docs/crypto/hashes/native.md index db8dc41628..5fbdec4796 100644 --- a/stdlib/docs/crypto/hashes/native.md +++ b/stdlib/docs/crypto/hashes/native.md @@ -4,4 +4,4 @@ Prepares the top of the stack with the hasher initial state.

This pro | ----------- | ------------- | | state_to_digest | Given the hasher state, returns the hash output

Input: [C, B, A, ...]
Ouptut: [HASH, ...]
Where: For the native RPO hasher HASH is B.
Cycles: 9
| | hash_memory_even | Hashes the memory `start_addr` to `end_addr`.

This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite
loop. `end_addr` is not inclusive.

Stack transition:
Input: [C, B, A, start_addr, end_addr, ...]
Output: [C', B', A', end_addr, end_addr ...]
Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1`

Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output.
| -| hash_memory | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 48 cycles + 3 * words
odd words: 60 cycles + 3 * words
| +| hash_memory | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 50 cycles + 3 * words
odd words: 62 cycles + 3 * words
| diff --git a/stdlib/docs/mem.md b/stdlib/docs/mem.md index 4aa67c46b7..2013c68546 100644 --- a/stdlib/docs/mem.md +++ b/stdlib/docs/mem.md @@ -4,5 +4,5 @@ | ----------- | ------------- | | memcopy | Copies `n` words from `read_ptr` to `write_ptr`.

Stack transition looks as follows:
[n, read_ptr, write_ptr, ...] -> [...]
cycles: 15 + 16n
| | pipe_double_words_to_memory | Copies an even number of words from the advice_stack to memory.

Input: [C, B, A, write_ptr, end_ptr, ...]
Output: [C, B, A, write_ptr, ...]

Where:
- The words C, B, and A are the RPO hasher state
- A is the capacity
- C,B are the rate portion of the state
- The value `words = end_ptr - write_ptr` must be positive and even

Cycles: 10 + 9 * word_pairs
| -| pipe_words_to_memory | Copies an arbitrary number of words from the advice stack to memory

Input: [num_words, write_ptr, ...]
Output: [HASH, write_ptr', ...]
Cycles:
even num_words: 48 + 9 * num_words / 2
odd num_words: 65 + 9 * round_down(num_words / 2)
| +| pipe_words_to_memory | Copies an arbitrary number of words from the advice stack to memory

Input: [num_words, write_ptr, ...]
Output: [HASH, write_ptr', ...]
Cycles:
even num_words: 50 + 9 * num_words / 2
odd num_words: 67 + 9 * round_down(num_words / 2)
| | pipe_preimage_to_memory | Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment.

Input: [num_words, write_ptr, COM, ...]
Output: [write_ptr', ...]
Cycles:
even num_words: 58 + 9 * num_words / 2
odd num_words: 75 + 9 * round_down(num_words / 2)
| From 13078303a742327e83f1f39ac15b639c609c5866 Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Wed, 29 May 2024 14:28:30 +0200 Subject: [PATCH 04/12] fix: update namings and optimize masm code --- .../src/assembler/instruction/crypto_ops.rs | 8 ++-- stdlib/asm/collections/mmr.masm | 6 +-- .../crypto/hashes/{native.masm => rpo.masm} | 26 ++++++------ stdlib/asm/mem.masm | 24 ++++++----- stdlib/docs/crypto/hashes/native.md | 7 ---- stdlib/docs/crypto/hashes/rpo.md | 7 ++++ stdlib/docs/mem.md | 4 +- stdlib/tests/crypto/native.rs | 42 +++++++++---------- stdlib/tests/mem/mod.rs | 2 + 9 files changed, 65 insertions(+), 61 deletions(-) rename stdlib/asm/crypto/hashes/{native.masm => rpo.masm} (80%) delete mode 100644 stdlib/docs/crypto/hashes/native.md create mode 100644 stdlib/docs/crypto/hashes/rpo.md diff --git a/assembly/src/assembler/instruction/crypto_ops.rs b/assembly/src/assembler/instruction/crypto_ops.rs index ef980e898c..6dc8965236 100644 --- a/assembly/src/assembler/instruction/crypto_ops.rs +++ b/assembly/src/assembler/instruction/crypto_ops.rs @@ -17,10 +17,10 @@ use crate::AssemblyError; /// To perform the operation we do the following: /// 1. Prepare the stack with 12 elements for HPERM by pushing 4 more elements for the capacity, /// then reordering the stack and pushing an additional 4 elements so that the stack looks like: -/// [0, 0, 0, 1, a3, a2, a1, a0, 0, 0, 0, 1, ...]. The first capacity element is set to ONE as -/// we are hashing a number of elements which is not a multiple of the rate width. We also set -/// the next element in the rate after `A` to ONE. All other capacity and rate elements are set -/// to ZERO, in accordance with the RPO rules. +/// [0, 0, 0, 0, a3, a2, a1, a0, 0, 0, 0, 4, ...]. The first capacity element is set to Felt(4) +/// as we are hashing a number of elements which is equal to 4 modulo the rate width, while the +/// other capacity elements are set to ZERO. A sequence of 4 ZERO elements is used as padding. +/// The padding rule used follows the one described in this [work](https://eprint.iacr.org/2023/1045). /// 2. Append the HPERM operation, which performs a permutation of RPO on the top 12 elements and /// leaves the an output of [D, C, B, ...] on the stack. C is our 1-to-1 has result. /// 3. Drop D and B to achieve our result [C, ...] diff --git a/stdlib/asm/collections/mmr.masm b/stdlib/asm/collections/mmr.masm index 3f50adfb09..04f6c627a3 100644 --- a/stdlib/asm/collections/mmr.masm +++ b/stdlib/asm/collections/mmr.masm @@ -1,5 +1,5 @@ use.std::mem -use.std::crypto::hashes::native +use.std::crypto::hashes::rpo use.std::math::u64 #! Loads the leaf at the absolute `pos` in the MMR. @@ -196,8 +196,8 @@ export.pack # hash the memory contents (25 + 3 * num_peaks) padw padw padw - exec.native::hash_memory_even - exec.native::state_to_digest + exec.rpo::absorb_double_words_from_memory + exec.rpo::squeeze_digest # => [HASH, peaks_end, peaks_end, mmr_ptr, ...] # prepare stack for adv.insert_mem (4 cycles) diff --git a/stdlib/asm/crypto/hashes/native.masm b/stdlib/asm/crypto/hashes/rpo.masm similarity index 80% rename from stdlib/asm/crypto/hashes/native.masm rename to stdlib/asm/crypto/hashes/rpo.masm index 4e8d572aaf..4913020310 100644 --- a/stdlib/asm/crypto/hashes/native.masm +++ b/stdlib/asm/crypto/hashes/rpo.masm @@ -10,13 +10,13 @@ export.init_no_padding padw padw padw end -#! Given the hasher state, returns the hash output +#! Given the hasher state, returns the hash output. #! #! Input: [C, B, A, ...] #! Ouptut: [HASH, ...] -#! Where: For the native RPO hasher HASH is B. +#! where: For the native RPO hasher HASH is B. #! Cycles: 9 -export.state_to_digest +export.squeeze_digest # drop the first rate word (4 cycles) dropw @@ -38,7 +38,7 @@ end #! Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1` #! #! Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output. -export.hash_memory_even +export.absorb_double_words_from_memory dup.13 dup.13 neq # (4 cycles ) while.true mem_stream hperm # (2 cycles) @@ -54,8 +54,8 @@ end #! Input: [start_addr, end_addr, ...] #! Output: [H, ...] #! Cycles: -#! even words: 50 cycles + 3 * words -#! odd words: 62 cycles + 3 * words +#! even words: 49 cycles + 3 * words +#! odd words: 61 cycles + 3 * words export.hash_memory # enforce `start_addr < end_addr` dup.1 dup.1 u32assert2 u32gt assert @@ -77,25 +77,25 @@ export.hash_memory # stack: [C, B, A, start_addr, end_addr, is_odd, ...] # (4 + 3 * words cycles) - exec.hash_memory_even + exec.absorb_double_words_from_memory # (1 cycles) movup.14 # handle the odd element, if any (12 cycles) if.true - # start_addr and end_addr are equal after calling `hash_memory_even`, and both point - # to the last element. Load the last word (2 cycles) - dup.13 mem_loadw + # start_addr and end_addr are equal after calling `absorb_double_words_from_memory`, and both point + # to the last element. Load the last word (6 cycles) + dropw dup.9 mem_loadw - # set the padding (9 cycles) - swapw dropw push.0.0.0.0 + # set the padding (4 cycles) + padw # (1 cycles) hperm end - exec.state_to_digest + exec.squeeze_digest # drop start_addr/end_addr (4 cycles) movup.4 drop movup.4 drop diff --git a/stdlib/asm/mem.masm b/stdlib/asm/mem.masm index e4117a609f..d984dc4968 100644 --- a/stdlib/asm/mem.masm +++ b/stdlib/asm/mem.masm @@ -1,3 +1,5 @@ +use.std::crypto::hashes::rpo + # ===== MEMORY FUNCTIONS ========================================================================== #! Copies `n` words from `read_ptr` to `write_ptr`. @@ -82,10 +84,10 @@ end #! Copies an arbitrary number of words from the advice stack to memory #! #! Input: [num_words, write_ptr, ...] -#! Output: [HASH, write_ptr', ...] +#! Output: [C, B, A, write_ptr', ...] #! Cycles: -#! even num_words: 50 + 9 * num_words / 2 -#! odd num_words: 67 + 9 * round_down(num_words / 2) +#! even num_words: 41 + 9 * num_words / 2 +#! odd num_words: 58 + 9 * round_down(num_words / 2) export.pipe_words_to_memory.0 # check if there is an odd number of words (6 cycles) dup is_odd @@ -142,17 +144,13 @@ export.pipe_words_to_memory.0 # => [B', A, write_ptr+1, ...] # Push padding word (4 cycles) - push.0.0.0.0 + padw # => [C, B', A, write_ptr+1, ...] # Run RPO permutation (1 cycles) hperm # => [C', B', A', write_ptr+1, ...] end - - # The RPO result is word B, discard the unused portion of the rate and the capacity. (9 cycles) - dropw swapw dropw - # => [rpo_hash, write_ptr', ...] end #! Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment. @@ -160,12 +158,16 @@ end #! Input: [num_words, write_ptr, COM, ...] #! Output: [write_ptr', ...] #! Cycles: -#! even num_words: 58 + 9 * num_words / 2 -#! odd num_words: 75 + 9 * round_down(num_words / 2) +#! even num_words: 67 + 9 * num_words / 2 +#! odd num_words: 84 + 9 * round_down(num_words / 2) export.pipe_preimage_to_memory.0 # Copies the advice stack data to memory exec.pipe_words_to_memory - # => [HASH, write_ptr', COM, ...] + # => [C, B, A, write_ptr', COM, ...] + + # Leave only the digest on the stack + exec.rpo::squeeze_digest + # => [B, write_ptr', COM, ...] # Save the write_ptr (2 cycles) movup.4 movdn.8 diff --git a/stdlib/docs/crypto/hashes/native.md b/stdlib/docs/crypto/hashes/native.md deleted file mode 100644 index 5fbdec4796..0000000000 --- a/stdlib/docs/crypto/hashes/native.md +++ /dev/null @@ -1,7 +0,0 @@ -Prepares the top of the stack with the hasher initial state.

This procedures does not handle padding, therefore, the user is expected to
consume an amount of data which is a multiple of the rate (2 words).

Input: []
Ouptut: [PERM, PERM, PERM, ...]
Cycles: 12
-## std::crypto::hashes::native -| Procedure | Description | -| ----------- | ------------- | -| state_to_digest | Given the hasher state, returns the hash output

Input: [C, B, A, ...]
Ouptut: [HASH, ...]
Where: For the native RPO hasher HASH is B.
Cycles: 9
| -| hash_memory_even | Hashes the memory `start_addr` to `end_addr`.

This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite
loop. `end_addr` is not inclusive.

Stack transition:
Input: [C, B, A, start_addr, end_addr, ...]
Output: [C', B', A', end_addr, end_addr ...]
Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1`

Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output.
| -| hash_memory | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 50 cycles + 3 * words
odd words: 62 cycles + 3 * words
| diff --git a/stdlib/docs/crypto/hashes/rpo.md b/stdlib/docs/crypto/hashes/rpo.md new file mode 100644 index 0000000000..cbeb54b721 --- /dev/null +++ b/stdlib/docs/crypto/hashes/rpo.md @@ -0,0 +1,7 @@ +Prepares the top of the stack with the hasher initial state.

This procedures does not handle padding, therefore, the user is expected to
consume an amount of data which is a multiple of the rate (2 words).

Input: []
Ouptut: [PERM, PERM, PERM, ...]
Cycles: 12
+## std::crypto::hashes::rpo +| Procedure | Description | +| ----------- | ------------- | +| squeeze_digest | Given the hasher state, returns the hash output.

Input: [C, B, A, ...]
Ouptut: [HASH, ...]
where: For the native RPO hasher HASH is B.
Cycles: 9
| +| absorb_double_words_from_memory | Hashes the memory `start_addr` to `end_addr`.

This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite
loop. `end_addr` is not inclusive.

Stack transition:
Input: [C, B, A, start_addr, end_addr, ...]
Output: [C', B', A', end_addr, end_addr ...]
Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1`

Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output.
| +| hash_memory | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 49 cycles + 3 * words
odd words: 61 cycles + 3 * words
| diff --git a/stdlib/docs/mem.md b/stdlib/docs/mem.md index 2013c68546..8267ca28e1 100644 --- a/stdlib/docs/mem.md +++ b/stdlib/docs/mem.md @@ -4,5 +4,5 @@ | ----------- | ------------- | | memcopy | Copies `n` words from `read_ptr` to `write_ptr`.

Stack transition looks as follows:
[n, read_ptr, write_ptr, ...] -> [...]
cycles: 15 + 16n
| | pipe_double_words_to_memory | Copies an even number of words from the advice_stack to memory.

Input: [C, B, A, write_ptr, end_ptr, ...]
Output: [C, B, A, write_ptr, ...]

Where:
- The words C, B, and A are the RPO hasher state
- A is the capacity
- C,B are the rate portion of the state
- The value `words = end_ptr - write_ptr` must be positive and even

Cycles: 10 + 9 * word_pairs
| -| pipe_words_to_memory | Copies an arbitrary number of words from the advice stack to memory

Input: [num_words, write_ptr, ...]
Output: [HASH, write_ptr', ...]
Cycles:
even num_words: 50 + 9 * num_words / 2
odd num_words: 67 + 9 * round_down(num_words / 2)
| -| pipe_preimage_to_memory | Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment.

Input: [num_words, write_ptr, COM, ...]
Output: [write_ptr', ...]
Cycles:
even num_words: 58 + 9 * num_words / 2
odd num_words: 75 + 9 * round_down(num_words / 2)
| +| pipe_words_to_memory | Copies an arbitrary number of words from the advice stack to memory

Input: [num_words, write_ptr, ...]
Output: [C, B, A, write_ptr', ...]
Cycles:
even num_words: 41 + 9 * num_words / 2
odd num_words: 58 + 9 * round_down(num_words / 2)
| +| pipe_preimage_to_memory | Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment.

Input: [num_words, write_ptr, COM, ...]
Output: [write_ptr', ...]
Cycles:
even num_words: 67 + 9 * num_words / 2
odd num_words: 84 + 9 * round_down(num_words / 2)
| diff --git a/stdlib/tests/crypto/native.rs b/stdlib/tests/crypto/native.rs index e63c77a247..174719a371 100644 --- a/stdlib/tests/crypto/native.rs +++ b/stdlib/tests/crypto/native.rs @@ -5,13 +5,13 @@ use test_utils::{build_expected_hash, build_expected_perm, expect_exec_error}; fn test_invalid_end_addr() { // end_addr can not be smaller than start_addr let empty_range = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.0999 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; let test = build_test!(empty_range, &[]); @@ -26,13 +26,13 @@ fn test_invalid_end_addr() { // address range can not contain zero elements let empty_range = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1000 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; let test = build_test!(empty_range, &[]); @@ -69,13 +69,13 @@ fn test_hash_empty() { // checks the hash compute from 8 zero elements is the same when using hash_memory let two_zeros = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1002 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; @@ -110,7 +110,7 @@ fn test_single_iteration() { // Note: This is testing the hashing of two words, so no padding is added // here let one_element = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin # insert 1 to memory @@ -119,7 +119,7 @@ fn test_single_iteration() { push.1002 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; @@ -139,7 +139,7 @@ fn test_hash_one_word() { // checks the hash of 1 is the same when using hash_memory let one_element = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1.1000 mem_store # push data to memory @@ -147,7 +147,7 @@ fn test_hash_one_word() { push.1001 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; @@ -158,7 +158,7 @@ fn test_hash_one_word() { fn test_hash_even_words() { // checks the hash of two words let even_words = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1.0.0.0.1000 mem_storew dropw @@ -167,7 +167,7 @@ fn test_hash_even_words() { push.1002 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; @@ -183,7 +183,7 @@ fn test_hash_even_words() { fn test_hash_odd_words() { // checks the hash of three words let odd_words = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1.0.0.0.1000 mem_storew dropw @@ -193,7 +193,7 @@ fn test_hash_odd_words() { push.1003 # end address push.1000 # start address - exec.native::hash_memory + exec.rpo::hash_memory end "; @@ -207,9 +207,9 @@ fn test_hash_odd_words() { } #[test] -fn test_hash_memory_even() { +fn test_absorb_double_words_from_memory() { let even_words = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1.0.0.0.1000 mem_storew dropw @@ -218,7 +218,7 @@ fn test_hash_memory_even() { push.1002 # end address push.1000 # start address padw padw padw # hasher state - exec.native::hash_memory_even + exec.rpo::absorb_double_words_from_memory end "; @@ -237,9 +237,9 @@ fn test_hash_memory_even() { } #[test] -fn test_state_to_digest() { +fn test_squeeze_digest() { let even_words = " - use.std::crypto::hashes::native + use.std::crypto::hashes::rpo begin push.1.0.0.0.1000 mem_storew dropw @@ -250,9 +250,9 @@ fn test_state_to_digest() { push.1004 # end address push.1000 # start address padw padw padw # hasher state - exec.native::hash_memory_even + exec.rpo::absorb_double_words_from_memory - exec.native::state_to_digest + exec.rpo::squeeze_digest end "; diff --git a/stdlib/tests/mem/mod.rs b/stdlib/tests/mem/mod.rs index 6802a2620d..fa39b3eb28 100644 --- a/stdlib/tests/mem/mod.rs +++ b/stdlib/tests/mem/mod.rs @@ -133,6 +133,7 @@ fn test_pipe_words_to_memory() { push.1 # number of words exec.mem::pipe_words_to_memory + dropw swapw dropw end", mem_addr ); @@ -155,6 +156,7 @@ fn test_pipe_words_to_memory() { push.3 # number of words exec.mem::pipe_words_to_memory + dropw swapw dropw end", mem_addr ); From 551218a85c98280c8ad523bbb8ce014cb6a99988 Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:37:58 +0200 Subject: [PATCH 05/12] chore: minor nits and comment updates --- assembly/src/ast/instruction/print.rs | 2 +- stdlib/asm/collections/mmr.masm | 2 +- stdlib/asm/crypto/dsa/rpo_falcon512.masm | 4 +++- stdlib/asm/crypto/hashes/rpo.masm | 2 +- stdlib/asm/crypto/stark/ood_frames.masm | 3 ++- stdlib/asm/crypto/stark/random_coin.masm | 6 +++--- stdlib/asm/mem.masm | 4 ++-- stdlib/docs/crypto/hashes/rpo.md | 2 +- stdlib/docs/mem.md | 2 +- stdlib/tests/crypto/falcon.rs | 3 ++- stdlib/tests/crypto/native.rs | 8 ++++++-- stdlib/tests/mem/mod.rs | 6 ++++-- 12 files changed, 27 insertions(+), 17 deletions(-) diff --git a/assembly/src/ast/instruction/print.rs b/assembly/src/ast/instruction/print.rs index a76239f70e..b7ca11c37c 100644 --- a/assembly/src/ast/instruction/print.rs +++ b/assembly/src/ast/instruction/print.rs @@ -427,7 +427,7 @@ mod tests { let target = InvocationTarget::MastRoot(Span::unknown(digest)); let instruction = format!("{}", Instruction::Exec(target)); assert_eq!( - "exec.0x03b49d98981575360dd1f8c8b5a7feefcadadd56ec2a33e3e43edae3577de150", + "exec.0x90b3926941061b28638b6cc0bbdb3bcb335e834dc9ab8044250875055202d2fe", instruction ); } diff --git a/stdlib/asm/collections/mmr.masm b/stdlib/asm/collections/mmr.masm index 04f6c627a3..4ed948fc62 100644 --- a/stdlib/asm/collections/mmr.masm +++ b/stdlib/asm/collections/mmr.masm @@ -165,7 +165,7 @@ export.unpack # => [C, B, A, mmr_ptr+17, HASH, ...] # drop anything but the hash result, word B (11 cycles) - dropw swapw dropw movup.4 drop + exec.rpo::squeeze_digest movup.4 drop # => [B, HASH, ...] # assert on the resulting hash (11 cycles) diff --git a/stdlib/asm/crypto/dsa/rpo_falcon512.masm b/stdlib/asm/crypto/dsa/rpo_falcon512.masm index 5cb418dce3..637f490bf9 100644 --- a/stdlib/asm/crypto/dsa/rpo_falcon512.masm +++ b/stdlib/asm/crypto/dsa/rpo_falcon512.masm @@ -1,3 +1,5 @@ +use.std::crypto::hashes::rpo + # CONSTANTS # ================================================================================================= @@ -224,7 +226,7 @@ export.load_h_s2_and_product.1 end # 6) Return the challenge point and the incremented pointer - dropw swapw dropw + exec.rpo::squeeze_digest drop drop #=> [tau1, tau0, ptr + 512] end diff --git a/stdlib/asm/crypto/hashes/rpo.masm b/stdlib/asm/crypto/hashes/rpo.masm index 4913020310..27c6b12aec 100644 --- a/stdlib/asm/crypto/hashes/rpo.masm +++ b/stdlib/asm/crypto/hashes/rpo.masm @@ -27,7 +27,7 @@ export.squeeze_digest dropw end -#! Hashes the memory `start_addr` to `end_addr`. +#! Hashes the memory `start_addr` to `end_addr` given an RPO state specified by 3 words. #! #! This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite #! loop. `end_addr` is not inclusive. diff --git a/stdlib/asm/crypto/stark/ood_frames.masm b/stdlib/asm/crypto/stark/ood_frames.masm index c6b9e50f26..bb3fabc1bc 100644 --- a/stdlib/asm/crypto/stark/ood_frames.masm +++ b/stdlib/asm/crypto/stark/ood_frames.masm @@ -1,4 +1,5 @@ use.std::crypto::stark::constants +use.std::crypto::hashes::rpo #! Loads OOD evaluation frame, with current and next rows interleaved, into memory. This ouputs @@ -105,7 +106,7 @@ export.load_constraint_evaluations hperm - dropw swapw dropw + exec.rpo::squeeze_digest end #! Computes the H(z) evaluation of the constraint composition polynomial at the OOD element z. diff --git a/stdlib/asm/crypto/stark/random_coin.masm b/stdlib/asm/crypto/stark/random_coin.masm index e66b024a40..07f431cb22 100644 --- a/stdlib/asm/crypto/stark/random_coin.masm +++ b/stdlib/asm/crypto/stark/random_coin.masm @@ -1,6 +1,6 @@ use.std::crypto::stark::constants use.std::crypto::stark::utils - +use.std::crypto::hashes::rpo #! Helper procedure to compute addition of two words component-wise. #! Input: [b3, b2, b1, b0, a3, a2, a1, a0] @@ -665,7 +665,7 @@ export.generate_list_indices exec.get_rate_2 hperm - dropw swapw dropw + exec.rpo::squeeze_digest #=> [R1, query_ptr, mask, depth, num_queries, ...] @@ -698,7 +698,7 @@ export.generate_list_indices exec.get_rate_2 hperm - dropw swapw dropw + exec.rpo::squeeze_digest #=> [R1, query_ptr, mask, depth, num_queries, ...] movup.7 sub.1 dup movdn.8 push.0 neq diff --git a/stdlib/asm/mem.masm b/stdlib/asm/mem.masm index d984dc4968..b420ab944a 100644 --- a/stdlib/asm/mem.masm +++ b/stdlib/asm/mem.masm @@ -158,8 +158,8 @@ end #! Input: [num_words, write_ptr, COM, ...] #! Output: [write_ptr', ...] #! Cycles: -#! even num_words: 67 + 9 * num_words / 2 -#! odd num_words: 84 + 9 * round_down(num_words / 2) +#! even num_words: 62 + 9 * num_words / 2 +#! odd num_words: 79 + 9 * round_down(num_words / 2) export.pipe_preimage_to_memory.0 # Copies the advice stack data to memory exec.pipe_words_to_memory diff --git a/stdlib/docs/crypto/hashes/rpo.md b/stdlib/docs/crypto/hashes/rpo.md index cbeb54b721..eb10fb3cfb 100644 --- a/stdlib/docs/crypto/hashes/rpo.md +++ b/stdlib/docs/crypto/hashes/rpo.md @@ -3,5 +3,5 @@ Prepares the top of the stack with the hasher initial state.

This pro | Procedure | Description | | ----------- | ------------- | | squeeze_digest | Given the hasher state, returns the hash output.

Input: [C, B, A, ...]
Ouptut: [HASH, ...]
where: For the native RPO hasher HASH is B.
Cycles: 9
| -| absorb_double_words_from_memory | Hashes the memory `start_addr` to `end_addr`.

This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite
loop. `end_addr` is not inclusive.

Stack transition:
Input: [C, B, A, start_addr, end_addr, ...]
Output: [C', B', A', end_addr, end_addr ...]
Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1`

Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output.
| +| absorb_double_words_from_memory | Hashes the memory `start_addr` to `end_addr` given an RPO state specified by 3 words.

This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite
loop. `end_addr` is not inclusive.

Stack transition:
Input: [C, B, A, start_addr, end_addr, ...]
Output: [C', B', A', end_addr, end_addr ...]
Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1`

Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output.
| | hash_memory | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 49 cycles + 3 * words
odd words: 61 cycles + 3 * words
| diff --git a/stdlib/docs/mem.md b/stdlib/docs/mem.md index 8267ca28e1..84fdb8134e 100644 --- a/stdlib/docs/mem.md +++ b/stdlib/docs/mem.md @@ -5,4 +5,4 @@ | memcopy | Copies `n` words from `read_ptr` to `write_ptr`.

Stack transition looks as follows:
[n, read_ptr, write_ptr, ...] -> [...]
cycles: 15 + 16n
| | pipe_double_words_to_memory | Copies an even number of words from the advice_stack to memory.

Input: [C, B, A, write_ptr, end_ptr, ...]
Output: [C, B, A, write_ptr, ...]

Where:
- The words C, B, and A are the RPO hasher state
- A is the capacity
- C,B are the rate portion of the state
- The value `words = end_ptr - write_ptr` must be positive and even

Cycles: 10 + 9 * word_pairs
| | pipe_words_to_memory | Copies an arbitrary number of words from the advice stack to memory

Input: [num_words, write_ptr, ...]
Output: [C, B, A, write_ptr', ...]
Cycles:
even num_words: 41 + 9 * num_words / 2
odd num_words: 58 + 9 * round_down(num_words / 2)
| -| pipe_preimage_to_memory | Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment.

Input: [num_words, write_ptr, COM, ...]
Output: [write_ptr', ...]
Cycles:
even num_words: 67 + 9 * num_words / 2
odd num_words: 84 + 9 * round_down(num_words / 2)
| +| pipe_preimage_to_memory | Moves an arbitrary number of words from the advice stack to memory and asserts it matches the commitment.

Input: [num_words, write_ptr, COM, ...]
Output: [write_ptr', ...]
Cycles:
even num_words: 62 + 9 * num_words / 2
odd num_words: 79 + 9 * round_down(num_words / 2)
| diff --git a/stdlib/tests/crypto/falcon.rs b/stdlib/tests/crypto/falcon.rs index 260136a467..dec3498167 100644 --- a/stdlib/tests/crypto/falcon.rs +++ b/stdlib/tests/crypto/falcon.rs @@ -173,7 +173,8 @@ fn test_falcon512_probabilistic_product_failure() { expect_exec_error!( test, ExecutionError::FailedAssertion { - clk: 17490.into(), + //clk: 17490.into(), + clk: 17498, err_code: 0, err_msg: None, } diff --git a/stdlib/tests/crypto/native.rs b/stdlib/tests/crypto/native.rs index 174719a371..da0d0c9d44 100644 --- a/stdlib/tests/crypto/native.rs +++ b/stdlib/tests/crypto/native.rs @@ -50,13 +50,15 @@ fn test_invalid_end_addr() { fn test_hash_empty() { // computes the hash for 8 consecutive zeros using mem_stream directly let two_zeros_mem_stream = " + use.std::crypto::hashes::rpo + begin # mem_stream state push.1000 padw padw padw mem_stream hperm # drop everything except the hash - dropw swapw dropw movup.4 drop + exec.rpo::squeeze_digest movup.4 drop end "; @@ -86,6 +88,8 @@ fn test_hash_empty() { fn test_single_iteration() { // computes the hash of 1 using mem_stream let one_memstream = " + use.std::crypto::hashes::rpo + begin # insert 1 to memory push.1.1000 mem_store @@ -95,7 +99,7 @@ fn test_single_iteration() { mem_stream hperm # drop everything except the hash - dropw swapw dropw movup.4 drop + exec.rpo::squeeze_digest movup.4 drop end "; diff --git a/stdlib/tests/mem/mod.rs b/stdlib/tests/mem/mod.rs index fa39b3eb28..8f756de776 100644 --- a/stdlib/tests/mem/mod.rs +++ b/stdlib/tests/mem/mod.rs @@ -127,13 +127,14 @@ fn test_pipe_words_to_memory() { let mem_addr = 1000; let one_word = format!( "use.std::mem + use.std::crypto::hashes::rpo begin push.{} # target address push.1 # number of words exec.mem::pipe_words_to_memory - dropw swapw dropw + exec.rpo::squeeze_digest end", mem_addr ); @@ -150,13 +151,14 @@ fn test_pipe_words_to_memory() { let three_words = format!( "use.std::mem + use.std::crypto::hashes::rpo begin push.{} # target address push.3 # number of words exec.mem::pipe_words_to_memory - dropw swapw dropw + exec.rpo::squeeze_digest end", mem_addr ); From e01e8224be4c0df558e6fe32e05eb7d7f1a11b3f Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:42:17 +0200 Subject: [PATCH 06/12] chore: change file name --- stdlib/tests/crypto/mod.rs | 2 +- stdlib/tests/crypto/{native.rs => rpo.rs} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename stdlib/tests/crypto/{native.rs => rpo.rs} (100%) diff --git a/stdlib/tests/crypto/mod.rs b/stdlib/tests/crypto/mod.rs index 848b9e1f62..e68dbc291e 100644 --- a/stdlib/tests/crypto/mod.rs +++ b/stdlib/tests/crypto/mod.rs @@ -6,6 +6,6 @@ mod ecdsa_secp256k1; mod elgamal; mod fri; mod keccak256; -mod native; +mod rpo; mod sha256; mod stark; diff --git a/stdlib/tests/crypto/native.rs b/stdlib/tests/crypto/rpo.rs similarity index 100% rename from stdlib/tests/crypto/native.rs rename to stdlib/tests/crypto/rpo.rs From 18ea698c08b615c1759da518694722086e8b7a5e Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:06:13 +0200 Subject: [PATCH 07/12] fix: after rebase --- assembly/src/assembler/instruction/crypto_ops.rs | 1 - stdlib/tests/collections/mmr.rs | 10 +++++----- stdlib/tests/crypto/falcon.rs | 3 +-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/assembly/src/assembler/instruction/crypto_ops.rs b/assembly/src/assembler/instruction/crypto_ops.rs index 6dc8965236..54e6a2acff 100644 --- a/assembly/src/assembler/instruction/crypto_ops.rs +++ b/assembly/src/assembler/instruction/crypto_ops.rs @@ -1,4 +1,3 @@ -use super::SpanBuilder; use vm_core::{AdviceInjector, Felt, Operation::*}; use super::BasicBlockBuilder; diff --git a/stdlib/tests/collections/mmr.rs b/stdlib/tests/collections/mmr.rs index c998f8dc2c..263e62537c 100644 --- a/stdlib/tests/collections/mmr.rs +++ b/stdlib/tests/collections/mmr.rs @@ -427,7 +427,7 @@ fn test_mmr_pack_roundtrip() { mmr.add(init_merkle_leaf(2).into()); mmr.add(init_merkle_leaf(3).into()); - let accumulator = mmr.peaks(mmr.forest()).unwrap(); + let accumulator = mmr.peaks(); let hash = accumulator.hash_peaks(); // Set up the VM stack with the MMR hash, and its target address @@ -560,7 +560,7 @@ fn test_mmr_two() { mmr.add([ONE, Felt::new(2), Felt::new(3), Felt::new(4)].into()); mmr.add([Felt::new(5), Felt::new(6), Felt::new(7), Felt::new(8)].into()); - let accumulator = mmr.peaks(mmr.forest()).unwrap(); + let accumulator = mmr.peaks(); let peak = accumulator.peaks()[0]; let num_leaves = accumulator.num_leaves() as u64; @@ -600,7 +600,7 @@ fn test_mmr_large() { mmr.add([ZERO, ZERO, ZERO, Felt::new(6)].into()); mmr.add([ZERO, ZERO, ZERO, Felt::new(7)].into()); - let accumulator = mmr.peaks(mmr.forest()).unwrap(); + let accumulator = mmr.peaks(); let num_leaves = accumulator.num_leaves() as u64; let mut expected_memory = vec![num_leaves, 0, 0, 0]; @@ -625,7 +625,7 @@ fn test_mmr_large_add_roundtrip() { [ZERO, ZERO, ZERO, Felt::new(7)].into(), ]); - let old_accumulator = mmr.peaks(mmr.forest()).unwrap(); + let old_accumulator = mmr.peaks(); let hash = old_accumulator.hash_peaks(); // Set up the VM stack with the MMR hash, and its target address @@ -664,7 +664,7 @@ fn test_mmr_large_add_roundtrip() { mmr.add([ZERO, ZERO, ZERO, Felt::new(8)].into()); - let new_accumulator = mmr.peaks(mmr.forest()).unwrap(); + let new_accumulator = mmr.peaks(); let num_leaves = new_accumulator.num_leaves() as u64; let mut expected_memory = vec![num_leaves, 0, 0, 0]; let mut new_peaks = new_accumulator.peaks().to_vec(); diff --git a/stdlib/tests/crypto/falcon.rs b/stdlib/tests/crypto/falcon.rs index dec3498167..260136a467 100644 --- a/stdlib/tests/crypto/falcon.rs +++ b/stdlib/tests/crypto/falcon.rs @@ -173,8 +173,7 @@ fn test_falcon512_probabilistic_product_failure() { expect_exec_error!( test, ExecutionError::FailedAssertion { - //clk: 17490.into(), - clk: 17498, + clk: 17490.into(), err_code: 0, err_msg: None, } From d528436af6871d5384155c42446d4ed1a6a33d2c Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:09:19 +0200 Subject: [PATCH 08/12] fix: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77d4f16d43..01e04d0846 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Debug instructions can be enabled in the cli `run` command using `--debug` flag (#1502) - [BREAKING] ExecutionOptions::new constructor requires a boolean to explicitly set debug mode (#1502) - [BREAKING] The `run` and the `prove` commands in the cli will accept `--trace` flag instead of `--tracing` (#1502) +- Migrated to new padding rule for RPO (#1343). #### Fixes From b9c2c589a0b543bd4027c2aaa46e2379dd039719 Mon Sep 17 00:00:00 2001 From: Al-Kindi-0 <82364884+Al-Kindi-0@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:12:11 +0200 Subject: [PATCH 09/12] fix: changelog --- miden/src/repl/mod.rs | 274 +++++++++++++++++++++--------------------- 1 file changed, 137 insertions(+), 137 deletions(-) diff --git a/miden/src/repl/mod.rs b/miden/src/repl/mod.rs index b0c41f4e2c..692e29df52 100644 --- a/miden/src/repl/mod.rs +++ b/miden/src/repl/mod.rs @@ -6,141 +6,141 @@ use processor::ContextId; use rustyline::{error::ReadlineError, DefaultEditor}; use stdlib::StdLibrary; -/// This work is in continuation to the amazing work done by team `Scribe` -/// [here](https://github.com/ControlCplusControlV/Scribe/blob/main/transpiler/src/repl.rs#L8) -/// -/// The Miden Read–eval–print loop (REPL) is a Miden shell that allows for quick and easy debugging -/// of Miden assembly. To use the repl, simply type "miden repl" after building it with feature -/// "executable" (cargo build --release --feature executable) when in the miden home -/// crate and the repl will launch. After the REPL gets initialized, you can execute any Miden -/// instruction, undo executed instructions, check the state of the stack and memory at a given -/// point, and do many other useful things! When the REPL is exited, a `history.txt` file is saved. -/// One thing to note is that all the REPL native commands start with an `!` to differentiate them -/// from regular assembly instructions. -/// -/// Miden Instructions -/// All Miden instructions mentioned in the -/// [Miden Assembly section](https://0xpolygonmiden.github.io/miden-vm/user_docs/assembly/main.html) -/// are valid. -/// One can either input instructions one by one or multiple instructions in one input. -/// For example, the below two commands will result in the same output. -/// >> push.1 -/// >> push.2 -/// >> push.3 -/// -/// >> push.1 push.2 push.3 -/// -/// In order to execute a control flow operation, one needs to write the entire flow operation in -/// a single line with spaces between individual operations. -/// Ex. -/// ``` -/// repeat.20 -/// pow2 -/// end -/// ``` -/// should be written as -/// `repeat.20 pow2 end` -/// -/// To execute a control flow operation, one must write the entire statement in a single line with -/// spaces between individual operations. -/// ``` -/// >> repeat.20 -/// pow2 -/// end -/// ``` -/// -/// The above example should be written as follows in the REPL tool: -/// >> repeat.20 pow2 end -/// -/// `!stack` -/// The `!stack` command prints out the state of the stack at the last executed instruction. Since -/// the stack always contains at least 16 elements, 16 or more elements will be printed out (even -/// if all of them are zeros). -/// >> push.1 push.2 push.3 push.4 push.5 -/// >> exp -/// >> u32wrapping_mul -/// >> swap -/// >> eq.2 -/// >> assert -/// -/// The `!stack` command will print out the following state of the stack: -/// ``` -/// >> !stack -/// 3072 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -/// ``` -/// -/// `!undo` -/// The `!undo` command reverts to the previous state of the stack and memory by dropping off the -/// last executed assembly instruction from the program. One could use `!undo` as often as they want -/// to restore the state of a stack and memory $n$ instructions ago (provided there are $n$ -/// instructions in the program). The `!undo` command will result in an error if no remaining -/// instructions are left in the miden program. -/// ``` -/// >> push.1 push.2 push.3 -/// >> push.4 -/// >> !stack -/// 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 -/// >> push.5 -/// >> !stack -/// 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 -/// >> !undo -/// 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 -/// >> !undo -/// 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 -/// ``` -/// -///`!program` -/// The `!program` command prints out the entire miden program getting executed. E.g., in the below -/// ``` -/// scenario: >> push.1 -/// >> push.2 -/// >> push.3 -/// >> add -/// >> add -/// >> !program -/// begin -/// push.1 -/// push.2 -/// push.3 -/// add -/// add -/// end -/// ``` -/// -/// `!help` -/// The `!help` command prints out all the available commands in the REPL tool. -/// -/// `!mem` -/// The `!mem` command prints out the contents of all initialized memory locations. For each such -/// location, the address, along with its memory values, is printed. Recall that four elements are -/// stored at each memory address. -/// If the memory has at least one value that has been initialized: -/// ``` -/// >> !mem -/// 7: [1, 2, 0, 3] -/// 8: [5, 7, 3, 32] -/// 9: [9, 10, 2, 0] -/// ``` -/// -/// If the memory is not yet been initialized: -/// ``` -/// >> !mem -/// The memory has not been initialized yet -/// ``` -/// -/// `!mem[addr]` -/// The `!mem[addr]` command prints out memory contents at the address specified by `addr`. -/// If the `addr` has been initialized: -/// ``` -/// >> !mem[9] -/// 9: [9, 10, 2, 0] -/// ``` -/// -/// If the `addr` has not been initialized: -/// ``` -/// >> !mem[87] -/// Memory at address 87 is empty -/// ``` +// This work is in continuation to the amazing work done by team `Scribe` +// [here](https://github.com/ControlCplusControlV/Scribe/blob/main/transpiler/src/repl.rs#L8) +// +// The Miden Read–eval–print loop (REPL) is a Miden shell that allows for quick and easy debugging +// of Miden assembly. To use the repl, simply type "miden repl" after building it with feature +// "executable" (cargo build --release --feature executable) when in the miden home +// crate and the repl will launch. After the REPL gets initialized, you can execute any Miden +// instruction, undo executed instructions, check the state of the stack and memory at a given +// point, and do many other useful things! When the REPL is exited, a `history.txt` file is saved. +// One thing to note is that all the REPL native commands start with an `!` to differentiate them +// from regular assembly instructions. +// +// Miden Instructions +// All Miden instructions mentioned in the +// [Miden Assembly section](https://0xpolygonmiden.github.io/miden-vm/user_docs/assembly/main.html) +// are valid. +// One can either input instructions one by one or multiple instructions in one input. +// For example, the below two commands will result in the same output. +// >> push.1 +// >> push.2 +// >> push.3 +// +// >> push.1 push.2 push.3 +// +// In order to execute a control flow operation, one needs to write the entire flow operation in +// a single line with spaces between individual operations. +// Ex. +// ``` +// repeat.20 +// pow2 +// end +// ``` +// should be written as +// `repeat.20 pow2 end` +// +// To execute a control flow operation, one must write the entire statement in a single line with +// spaces between individual operations. +// ``` +// >> repeat.20 +// pow2 +// end +// ``` +// +// The above example should be written as follows in the REPL tool: +// >> repeat.20 pow2 end +// +// `!stack` +// The `!stack` command prints out the state of the stack at the last executed instruction. Since +// the stack always contains at least 16 elements, 16 or more elements will be printed out (even +// if all of them are zeros). +// >> push.1 push.2 push.3 push.4 push.5 +// >> exp +// >> u32wrapping_mul +// >> swap +// >> eq.2 +// >> assert +// +// The `!stack` command will print out the following state of the stack: +// ``` +// >> !stack +// 3072 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +// ``` +// +// `!undo` +// The `!undo` command reverts to the previous state of the stack and memory by dropping off the +// last executed assembly instruction from the program. One could use `!undo` as often as they want +// to restore the state of a stack and memory $n$ instructions ago (provided there are $n$ +// instructions in the program). The `!undo` command will result in an error if no remaining +// instructions are left in the miden program. +// ``` +// >> push.1 push.2 push.3 +// >> push.4 +// >> !stack +// 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 +// >> push.5 +// >> !stack +// 5 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 +// >> !undo +// 4 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 +// >> !undo +// 3 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 +// ``` +// +//`!program` +// The `!program` command prints out the entire miden program getting executed. E.g., in the below +// ``` +// scenario: >> push.1 +// >> push.2 +// >> push.3 +// >> add +// >> add +// >> !program +// begin +// push.1 +// push.2 +// push.3 +// add +// add +// end +// ``` +// +// `!help` +// The `!help` command prints out all the available commands in the REPL tool. +// +// `!mem` +// The `!mem` command prints out the contents of all initialized memory locations. For each such +// location, the address, along with its memory values, is printed. Recall that four elements are +// stored at each memory address. +// If the memory has at least one value that has been initialized: +// ``` +// >> !mem +// 7: [1, 2, 0, 3] +// 8: [5, 7, 3, 32] +// 9: [9, 10, 2, 0] +// ``` +// +// If the memory is not yet been initialized: +// ``` +// >> !mem +// The memory has not been initialized yet +// ``` +// +// `!mem[addr]` +// The `!mem[addr]` command prints out memory contents at the address specified by `addr`. +// If the `addr` has been initialized: +// ``` +// >> !mem[9] +// 9: [9, 10, 2, 0] +// ``` +// +// If the `addr` has not been initialized: +// ``` +// >> !mem[87] +// Memory at address 87 is empty +// ``` /// Initiates the Miden Repl tool. pub fn start_repl(library_paths: &Vec, use_stdlib: bool) { @@ -295,8 +295,8 @@ pub fn start_repl(library_paths: &Vec, use_stdlib: bool) { .expect("Couldn't dump the program into the history file"); } -/// HELPER METHODS -/// -------------------------------------------------------------------------------------------- +// HELPER METHODS +// -------------------------------------------------------------------------------------------- /// Compiles and executes a compiled Miden program, returning the stack, memory and any Miden /// errors. The program is passed in as a String, passed to the Miden Assembler, and then passed From 8316863d5885005b3207b50ed48fa673a1bb2235 Mon Sep 17 00:00:00 2001 From: Andrey Khmuro Date: Tue, 15 Oct 2024 10:56:52 +0300 Subject: [PATCH 10/12] feat: implement new `hash_memory` proc (#1519) --- CHANGELOG.md | 2 + assembly/src/assembler/basic_block_builder.rs | 8 +- assembly/src/assembler/module_graph/debug.rs | 8 +- assembly/src/assembler/module_graph/mod.rs | 2 +- assembly/src/ast/attribute/set.rs | 4 +- assembly/src/ast/visit.rs | 4 +- assembly/src/compile.rs | 12 +- assembly/src/library/path.rs | 10 +- assembly/src/parser/mod.rs | 2 +- assembly/src/parser/token.rs | 2 +- assembly/src/sema/passes/const_eval.rs | 4 +- assembly/src/sema/passes/verify_invoke.rs | 4 +- core/src/mast/node/basic_block_node/mod.rs | 4 +- core/src/mast/node/call_node.rs | 6 +- core/src/mast/node/dyn_node.rs | 6 +- core/src/mast/node/external.rs | 6 +- core/src/mast/node/join_node.rs | 4 +- core/src/mast/node/loop_node.rs | 4 +- core/src/mast/node/mod.rs | 4 +- core/src/mast/node/split_node.rs | 4 +- core/src/mast/serialization/basic_blocks.rs | 2 +- processor/src/chiplets/mod.rs | 2 + processor/src/host/advice/mod.rs | 2 +- processor/src/host/mod.rs | 2 +- prover/src/gpu/metal/mod.rs | 2 +- stdlib/asm/crypto/hashes/rpo.masm | 212 ++++++++++++++++-- stdlib/docs/crypto/hashes/rpo.md | 3 +- stdlib/tests/crypto/rpo.rs | 166 +++++++++++--- 28 files changed, 383 insertions(+), 108 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01e04d0846..788623c9fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -158,6 +158,8 @@ #### Stdlib - Added `init_no_padding` procedure to `std::crypto::hashes::native` (#1313). +- [BREAKING] `native` module was renamed to the `rpo`, `hash_memory` procedure was renamed to the `hash_memory_words` (#1368). +- Added `hash_memory` procedure to `std::crypto::hashes::rpo` (#1368). #### VM Internals diff --git a/assembly/src/assembler/basic_block_builder.rs b/assembly/src/assembler/basic_block_builder.rs index 1113e1fead..3246484d21 100644 --- a/assembly/src/assembler/basic_block_builder.rs +++ b/assembly/src/assembler/basic_block_builder.rs @@ -60,7 +60,7 @@ impl<'a> BasicBlockBuilder<'a> { } /// Accessors -impl<'a> BasicBlockBuilder<'a> { +impl BasicBlockBuilder<'_> { /// Returns a reference to the internal [`MastForestBuilder`]. pub fn mast_forest_builder(&self) -> &MastForestBuilder { self.mast_forest_builder @@ -73,7 +73,7 @@ impl<'a> BasicBlockBuilder<'a> { } /// Operations -impl<'a> BasicBlockBuilder<'a> { +impl BasicBlockBuilder<'_> { /// Adds the specified operation to the list of basic block operations. pub fn push_op(&mut self, op: Operation) { self.ops.push(op); @@ -96,7 +96,7 @@ impl<'a> BasicBlockBuilder<'a> { } /// Decorators -impl<'a> BasicBlockBuilder<'a> { +impl BasicBlockBuilder<'_> { /// Add the specified decorator to the list of basic block decorators. pub fn push_decorator(&mut self, decorator: Decorator) -> Result<(), AssemblyError> { let decorator_id = self.mast_forest_builder.ensure_decorator(decorator)?; @@ -159,7 +159,7 @@ impl<'a> BasicBlockBuilder<'a> { } /// Span Constructors -impl<'a> BasicBlockBuilder<'a> { +impl BasicBlockBuilder<'_> { /// Creates and returns a new basic block node from the operations and decorators currently in /// this builder. /// diff --git a/assembly/src/assembler/module_graph/debug.rs b/assembly/src/assembler/module_graph/debug.rs index bf584fad1b..eea58adf48 100644 --- a/assembly/src/assembler/module_graph/debug.rs +++ b/assembly/src/assembler/module_graph/debug.rs @@ -14,7 +14,7 @@ impl fmt::Debug for ModuleGraph { #[doc(hidden)] struct DisplayModuleGraph<'a>(&'a ModuleGraph); -impl<'a> fmt::Debug for DisplayModuleGraph<'a> { +impl fmt::Debug for DisplayModuleGraph<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_set() .entries(self.0.modules.iter().enumerate().flat_map(|(module_index, m)| { @@ -56,7 +56,7 @@ impl<'a> fmt::Debug for DisplayModuleGraph<'a> { #[doc(hidden)] struct DisplayModuleGraphNodes<'a>(&'a Vec); -impl<'a> fmt::Debug for DisplayModuleGraphNodes<'a> { +impl fmt::Debug for DisplayModuleGraphNodes<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_list() .entries(self.0.iter().enumerate().flat_map(|(module_index, m)| { @@ -111,7 +111,7 @@ struct DisplayModuleGraphNode<'a> { ty: GraphNodeType, } -impl<'a> fmt::Debug for DisplayModuleGraphNode<'a> { +impl fmt::Debug for DisplayModuleGraphNode<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Node") .field("id", &format_args!("{}:{}", &self.module.as_usize(), &self.index.as_usize())) @@ -128,7 +128,7 @@ struct DisplayModuleGraphNodeWithEdges<'a> { out_edges: &'a [GlobalProcedureIndex], } -impl<'a> fmt::Debug for DisplayModuleGraphNodeWithEdges<'a> { +impl fmt::Debug for DisplayModuleGraphNodeWithEdges<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Edge") .field( diff --git a/assembly/src/assembler/module_graph/mod.rs b/assembly/src/assembler/module_graph/mod.rs index c96617a314..f8116f9985 100644 --- a/assembly/src/assembler/module_graph/mod.rs +++ b/assembly/src/assembler/module_graph/mod.rs @@ -39,7 +39,7 @@ pub enum ProcedureWrapper<'a> { Info(&'a ProcedureInfo), } -impl<'a> ProcedureWrapper<'a> { +impl ProcedureWrapper<'_> { /// Returns the name of the procedure. pub fn name(&self) -> &ProcedureName { match self { diff --git a/assembly/src/ast/attribute/set.rs b/assembly/src/ast/attribute/set.rs index bbf69698a5..f215f96db0 100644 --- a/assembly/src/ast/attribute/set.rs +++ b/assembly/src/ast/attribute/set.rs @@ -197,7 +197,7 @@ pub struct AttributeSetOccupiedEntry<'a> { set: &'a mut AttributeSet, index: usize, } -impl<'a> AttributeSetOccupiedEntry<'a> { +impl AttributeSetOccupiedEntry<'_> { #[inline] pub fn get(&self) -> &Attribute { &self.set.attrs[self.index] @@ -228,7 +228,7 @@ pub struct AttributeSetVacantEntry<'a> { key: Ident, index: usize, } -impl<'a> AttributeSetVacantEntry<'a> { +impl AttributeSetVacantEntry<'_> { pub fn insert(self, attr: Attribute) { if self.key != attr.id() { self.set.insert(attr); diff --git a/assembly/src/ast/visit.rs b/assembly/src/ast/visit.rs index b9d60cbe65..ecd11fb86e 100644 --- a/assembly/src/ast/visit.rs +++ b/assembly/src/ast/visit.rs @@ -139,7 +139,7 @@ pub trait Visit { } } -impl<'a, V, T> Visit for &'a mut V +impl Visit for &mut V where V: ?Sized + Visit, { @@ -575,7 +575,7 @@ pub trait VisitMut { } } -impl<'a, V, T> VisitMut for &'a mut V +impl VisitMut for &mut V where V: ?Sized + VisitMut, { diff --git a/assembly/src/compile.rs b/assembly/src/compile.rs index 1d2fda3a45..2e36858cdd 100644 --- a/assembly/src/compile.rs +++ b/assembly/src/compile.rs @@ -130,7 +130,7 @@ impl Compile for Module { } } -impl<'a> Compile for &'a Module { +impl Compile for &Module { #[inline(always)] fn compile_with_options( self, @@ -197,7 +197,7 @@ impl Compile for Arc { } } -impl<'a> Compile for &'a str { +impl Compile for &str { #[inline(always)] fn compile_with_options( self, @@ -208,7 +208,7 @@ impl<'a> Compile for &'a str { } } -impl<'a> Compile for &'a String { +impl Compile for &String { #[inline(always)] fn compile_with_options( self, @@ -251,7 +251,7 @@ impl Compile for Box { } } -impl<'a> Compile for Cow<'a, str> { +impl Compile for Cow<'_, str> { #[inline(always)] fn compile_with_options( self, @@ -265,7 +265,7 @@ impl<'a> Compile for Cow<'a, str> { // COMPILE IMPLEMENTATIONS FOR BYTES // ------------------------------------------------------------------------------------------------ -impl<'a> Compile for &'a [u8] { +impl Compile for &[u8] { #[inline] fn compile_with_options( self, @@ -350,7 +350,7 @@ where // ------------------------------------------------------------------------------------------------ #[cfg(feature = "std")] -impl<'a> Compile for &'a std::path::Path { +impl Compile for &std::path::Path { fn compile_with_options( self, source_manager: &dyn SourceManager, diff --git a/assembly/src/library/path.rs b/assembly/src/library/path.rs index a77ea1b287..22e5fe8479 100644 --- a/assembly/src/library/path.rs +++ b/assembly/src/library/path.rs @@ -65,9 +65,9 @@ impl<'a> LibraryPathComponent<'a> { } } -impl<'a> Eq for LibraryPathComponent<'a> {} +impl Eq for LibraryPathComponent<'_> {} -impl<'a> PartialEq for LibraryPathComponent<'a> { +impl PartialEq for LibraryPathComponent<'_> { fn eq(&self, other: &Self) -> bool { match (self, other) { (Self::Namespace(a), Self::Namespace(b)) => a == b, @@ -77,13 +77,13 @@ impl<'a> PartialEq for LibraryPathComponent<'a> { } } -impl<'a> PartialEq for LibraryPathComponent<'a> { +impl PartialEq for LibraryPathComponent<'_> { fn eq(&self, other: &str) -> bool { self.as_ref().eq(other) } } -impl<'a> AsRef for LibraryPathComponent<'a> { +impl AsRef for LibraryPathComponent<'_> { fn as_ref(&self) -> &str { match self { Self::Namespace(ns) => ns.as_str(), @@ -92,7 +92,7 @@ impl<'a> AsRef for LibraryPathComponent<'a> { } } -impl<'a> fmt::Display for LibraryPathComponent<'a> { +impl fmt::Display for LibraryPathComponent<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(self.as_ref()) } diff --git a/assembly/src/parser/mod.rs b/assembly/src/parser/mod.rs index d91f9e1024..d61e5619a1 100644 --- a/assembly/src/parser/mod.rs +++ b/assembly/src/parser/mod.rs @@ -304,7 +304,7 @@ mod module_walker { } } - impl<'a> Iterator for WalkModules<'a> { + impl Iterator for WalkModules<'_> { type Item = Result; fn next(&mut self) -> Option { diff --git a/assembly/src/parser/token.rs b/assembly/src/parser/token.rs index 8251278716..602e274912 100644 --- a/assembly/src/parser/token.rs +++ b/assembly/src/parser/token.rs @@ -316,7 +316,7 @@ pub enum Token<'input> { Eof, } -impl<'input> fmt::Display for Token<'input> { +impl fmt::Display for Token<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Token::Add => write!(f, "add"), diff --git a/assembly/src/sema/passes/const_eval.rs b/assembly/src/sema/passes/const_eval.rs index f76de03ad2..8394bc5402 100644 --- a/assembly/src/sema/passes/const_eval.rs +++ b/assembly/src/sema/passes/const_eval.rs @@ -17,7 +17,7 @@ impl<'analyzer> ConstEvalVisitor<'analyzer> { } } -impl<'analyzer> ConstEvalVisitor<'analyzer> { +impl ConstEvalVisitor<'_> { fn eval_const(&mut self, imm: &mut Immediate) -> ControlFlow<()> where T: TryFrom, @@ -45,7 +45,7 @@ impl<'analyzer> ConstEvalVisitor<'analyzer> { } } -impl<'analyzer> VisitMut for ConstEvalVisitor<'analyzer> { +impl VisitMut for ConstEvalVisitor<'_> { fn visit_mut_immediate_u8(&mut self, imm: &mut Immediate) -> ControlFlow<()> { self.eval_const(imm) } diff --git a/assembly/src/sema/passes/verify_invoke.rs b/assembly/src/sema/passes/verify_invoke.rs index a1c38ba8ca..16c7ac5ba5 100644 --- a/assembly/src/sema/passes/verify_invoke.rs +++ b/assembly/src/sema/passes/verify_invoke.rs @@ -43,7 +43,7 @@ impl<'a> VerifyInvokeTargets<'a> { } } -impl<'a> VerifyInvokeTargets<'a> { +impl VerifyInvokeTargets<'_> { fn resolve_local(&mut self, name: &ProcedureName) -> ControlFlow<()> { if !self.procedures.contains(name) { self.analyzer @@ -72,7 +72,7 @@ impl<'a> VerifyInvokeTargets<'a> { } } -impl<'a> VisitMut for VerifyInvokeTargets<'a> { +impl VisitMut for VerifyInvokeTargets<'_> { fn visit_mut_inst(&mut self, inst: &mut Span) -> ControlFlow<()> { let span = inst.span(); match &**inst { diff --git a/core/src/mast/node/basic_block_node/mod.rs b/core/src/mast/node/basic_block_node/mod.rs index 81f0afa0a5..726decbc72 100644 --- a/core/src/mast/node/basic_block_node/mod.rs +++ b/core/src/mast/node/basic_block_node/mod.rs @@ -247,7 +247,7 @@ struct BasicBlockNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> PrettyPrint for BasicBlockNodePrettyPrint<'a> { +impl PrettyPrint for BasicBlockNodePrettyPrint<'_> { #[rustfmt::skip] fn render(&self) -> crate::prettier::Document { use crate::prettier::*; @@ -295,7 +295,7 @@ impl<'a> PrettyPrint for BasicBlockNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for BasicBlockNodePrettyPrint<'a> { +impl fmt::Display for BasicBlockNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::prettier::PrettyPrint; self.pretty_print(f) diff --git a/core/src/mast/node/call_node.rs b/core/src/mast/node/call_node.rs index c028a32456..7f207d386f 100644 --- a/core/src/mast/node/call_node.rs +++ b/core/src/mast/node/call_node.rs @@ -201,7 +201,7 @@ struct CallNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> CallNodePrettyPrint<'a> { +impl CallNodePrettyPrint<'_> { /// Concatenates the provided decorators in a single line. If the list of decorators is not /// empty, prepends `prepend` and appends `append` to the decorator document. fn concatenate_decorators( @@ -240,7 +240,7 @@ impl<'a> CallNodePrettyPrint<'a> { } } -impl<'a> PrettyPrint for CallNodePrettyPrint<'a> { +impl PrettyPrint for CallNodePrettyPrint<'_> { fn render(&self) -> Document { let call_or_syscall = { let callee_digest = self.mast_forest[self.node.callee].digest(); @@ -265,7 +265,7 @@ impl<'a> PrettyPrint for CallNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for CallNodePrettyPrint<'a> { +impl fmt::Display for CallNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::prettier::PrettyPrint; self.pretty_print(f) diff --git a/core/src/mast/node/dyn_node.rs b/core/src/mast/node/dyn_node.rs index 34e87610b8..91afeea798 100644 --- a/core/src/mast/node/dyn_node.rs +++ b/core/src/mast/node/dyn_node.rs @@ -91,7 +91,7 @@ struct DynNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> DynNodePrettyPrint<'a> { +impl DynNodePrettyPrint<'_> { /// Concatenates the provided decorators in a single line. If the list of decorators is not /// empty, prepends `prepend` and appends `append` to the decorator document. fn concatenate_decorators( @@ -130,7 +130,7 @@ impl<'a> DynNodePrettyPrint<'a> { } } -impl<'a> crate::prettier::PrettyPrint for DynNodePrettyPrint<'a> { +impl crate::prettier::PrettyPrint for DynNodePrettyPrint<'_> { fn render(&self) -> crate::prettier::Document { let dyn_text = const_text("dyn"); @@ -144,7 +144,7 @@ impl<'a> crate::prettier::PrettyPrint for DynNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for DynNodePrettyPrint<'a> { +impl fmt::Display for DynNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.pretty_print(f) } diff --git a/core/src/mast/node/external.rs b/core/src/mast/node/external.rs index 3b3f23e403..d966008009 100644 --- a/core/src/mast/node/external.rs +++ b/core/src/mast/node/external.rs @@ -89,7 +89,7 @@ struct ExternalNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> ExternalNodePrettyPrint<'a> { +impl ExternalNodePrettyPrint<'_> { /// Concatenates the provided decorators in a single line. If the list of decorators is not /// empty, prepends `prepend` and appends `append` to the decorator document. fn concatenate_decorators( @@ -128,7 +128,7 @@ impl<'a> ExternalNodePrettyPrint<'a> { } } -impl<'a> crate::prettier::PrettyPrint for ExternalNodePrettyPrint<'a> { +impl crate::prettier::PrettyPrint for ExternalNodePrettyPrint<'_> { fn render(&self) -> crate::prettier::Document { let external = const_text("external") + const_text(".") @@ -144,7 +144,7 @@ impl<'a> crate::prettier::PrettyPrint for ExternalNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for ExternalNodePrettyPrint<'a> { +impl fmt::Display for ExternalNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::prettier::PrettyPrint; self.pretty_print(f) diff --git a/core/src/mast/node/join_node.rs b/core/src/mast/node/join_node.rs index 17aaccd8ec..d3d04b4510 100644 --- a/core/src/mast/node/join_node.rs +++ b/core/src/mast/node/join_node.rs @@ -142,7 +142,7 @@ struct JoinNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> PrettyPrint for JoinNodePrettyPrint<'a> { +impl PrettyPrint for JoinNodePrettyPrint<'_> { #[rustfmt::skip] fn render(&self) -> crate::prettier::Document { use crate::prettier::*; @@ -195,7 +195,7 @@ impl<'a> PrettyPrint for JoinNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for JoinNodePrettyPrint<'a> { +impl fmt::Display for JoinNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::prettier::PrettyPrint; self.pretty_print(f) diff --git a/core/src/mast/node/loop_node.rs b/core/src/mast/node/loop_node.rs index 08933ac521..6091ce034d 100644 --- a/core/src/mast/node/loop_node.rs +++ b/core/src/mast/node/loop_node.rs @@ -131,7 +131,7 @@ struct LoopNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> crate::prettier::PrettyPrint for LoopNodePrettyPrint<'a> { +impl crate::prettier::PrettyPrint for LoopNodePrettyPrint<'_> { fn render(&self) -> crate::prettier::Document { use crate::prettier::*; @@ -175,7 +175,7 @@ impl<'a> crate::prettier::PrettyPrint for LoopNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for LoopNodePrettyPrint<'a> { +impl fmt::Display for LoopNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::prettier::PrettyPrint; self.pretty_print(f) diff --git a/core/src/mast/node/mod.rs b/core/src/mast/node/mod.rs index cbb3192f40..2163565742 100644 --- a/core/src/mast/node/mod.rs +++ b/core/src/mast/node/mod.rs @@ -273,7 +273,7 @@ impl<'a> MastNodePrettyPrint<'a> { } } -impl<'a> PrettyPrint for MastNodePrettyPrint<'a> { +impl PrettyPrint for MastNodePrettyPrint<'_> { fn render(&self) -> Document { self.node_pretty_print.render() } @@ -289,7 +289,7 @@ impl<'a> MastNodeDisplay<'a> { } } -impl<'a> fmt::Display for MastNodeDisplay<'a> { +impl fmt::Display for MastNodeDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.node_display.fmt(f) } diff --git a/core/src/mast/node/split_node.rs b/core/src/mast/node/split_node.rs index 6b1b96e0cc..8a46fcdc70 100644 --- a/core/src/mast/node/split_node.rs +++ b/core/src/mast/node/split_node.rs @@ -144,7 +144,7 @@ struct SplitNodePrettyPrint<'a> { mast_forest: &'a MastForest, } -impl<'a> PrettyPrint for SplitNodePrettyPrint<'a> { +impl PrettyPrint for SplitNodePrettyPrint<'_> { #[rustfmt::skip] fn render(&self) -> crate::prettier::Document { use crate::prettier::*; @@ -190,7 +190,7 @@ impl<'a> PrettyPrint for SplitNodePrettyPrint<'a> { } } -impl<'a> fmt::Display for SplitNodePrettyPrint<'a> { +impl fmt::Display for SplitNodePrettyPrint<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { use crate::prettier::PrettyPrint; self.pretty_print(f) diff --git a/core/src/mast/serialization/basic_blocks.rs b/core/src/mast/serialization/basic_blocks.rs index e32caa6e99..86cf884717 100644 --- a/core/src/mast/serialization/basic_blocks.rs +++ b/core/src/mast/serialization/basic_blocks.rs @@ -67,7 +67,7 @@ impl<'a> BasicBlockDataDecoder<'a> { } /// Decoding methods -impl<'a> BasicBlockDataDecoder<'a> { +impl BasicBlockDataDecoder<'_> { pub fn decode_operations_and_decorators( &self, ops_offset: NodeDataOffset, diff --git a/processor/src/chiplets/mod.rs b/processor/src/chiplets/mod.rs index b098a57606..63a463141d 100644 --- a/processor/src/chiplets/mod.rs +++ b/processor/src/chiplets/mod.rs @@ -74,6 +74,7 @@ mod tests; /// - columns 3-17: unused columns padded with ZERO /// /// The following is a pictorial representation of the chiplet module: +/// ```text /// +---+-------------------------------------------------------+-------------+ /// | 0 | | |-------------| /// | . | Hash chiplet | Hash chiplet |-------------| @@ -111,6 +112,7 @@ mod tests; /// | . | . | . | . |---------------------------------------------------------| /// | 1 | 1 | 1 | 1 |---------------------------------------------------------| /// +---+---+---+---+---------------------------------------------------------+ +/// ``` pub struct Chiplets { /// Current clock cycle of the VM. clk: RowIndex, diff --git a/processor/src/host/advice/mod.rs b/processor/src/host/advice/mod.rs index 6dacc08b45..4eba93fe7c 100644 --- a/processor/src/host/advice/mod.rs +++ b/processor/src/host/advice/mod.rs @@ -718,7 +718,7 @@ pub trait AdviceProvider: Sized { R: Borrow; } -impl<'a, T> AdviceProvider for &'a mut T +impl AdviceProvider for &mut T where T: AdviceProvider, { diff --git a/processor/src/host/mod.rs b/processor/src/host/mod.rs index 10366e7c66..4e4289b331 100644 --- a/processor/src/host/mod.rs +++ b/processor/src/host/mod.rs @@ -176,7 +176,7 @@ pub trait Host { } } -impl<'a, H> Host for &'a mut H +impl Host for &mut H where H: Host, { diff --git a/prover/src/gpu/metal/mod.rs b/prover/src/gpu/metal/mod.rs index ab7132834e..930253b5fc 100644 --- a/prover/src/gpu/metal/mod.rs +++ b/prover/src/gpu/metal/mod.rs @@ -688,7 +688,7 @@ where E: FieldElement, I: IntoIterator>; -impl<'a, 'b, E, I, const N: usize> Iterator for SegmentIterator<'a, 'b, E, I, N> +impl Iterator for SegmentIterator where E: FieldElement, I: IntoIterator>, diff --git a/stdlib/asm/crypto/hashes/rpo.masm b/stdlib/asm/crypto/hashes/rpo.masm index 27c6b12aec..1035fa464d 100644 --- a/stdlib/asm/crypto/hashes/rpo.masm +++ b/stdlib/asm/crypto/hashes/rpo.masm @@ -5,6 +5,7 @@ #! #! Input: [] #! Ouptut: [PERM, PERM, PERM, ...] +#! #! Cycles: 12 export.init_no_padding padw padw padw @@ -14,7 +15,11 @@ end #! #! Input: [C, B, A, ...] #! Ouptut: [HASH, ...] -#! where: For the native RPO hasher HASH is B. +#! +#! Where : +#! - `A` is the capacity word that will be used by the hashing function. +#! - `B` is the hash output. +#! #! Cycles: 9 export.squeeze_digest # drop the first rate word (4 cycles) @@ -29,15 +34,17 @@ end #! Hashes the memory `start_addr` to `end_addr` given an RPO state specified by 3 words. #! -#! This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite -#! loop. `end_addr` is not inclusive. +#! This requires that `end_addr = start_addr + 2n` where n = {0, 1, 2 ...}, otherwise the procedure +#! will enter an infinite loop. #! -#! Stack transition: #! Input: [C, B, A, start_addr, end_addr, ...] #! Output: [C', B', A', end_addr, end_addr ...] -#! Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1` #! -#! Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output. +#! Where : +#! - `A` is the capacity word that will be used by the hashing function. +#! - `B` is the hash output. +#! +#! Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr` export.absorb_double_words_from_memory dup.13 dup.13 neq # (4 cycles ) while.true @@ -48,55 +55,212 @@ end #! Hashes the memory `start_addr` to `end_addr`, handles odd number of elements. #! -#! Requires `start_addr < end_addr`, `end_addr` is not inclusive. +#! Requires `start_addr ≤ end_addr`, `end_addr` is not inclusive. #! -#! Stack transition: #! Input: [start_addr, end_addr, ...] #! Output: [H, ...] +#! #! Cycles: -#! even words: 49 cycles + 3 * words -#! odd words: 61 cycles + 3 * words -export.hash_memory - # enforce `start_addr < end_addr` - dup.1 dup.1 u32assert2 u32gt assert +#! - even words: 49 cycles + 3 * words +#! - odd words: 61 cycles + 3 * words +#! where `words` is the `start_addr - end_addr - 1` +export.hash_memory_words + # enforce `start_addr ≤ end_addr` + dup.1 dup.1 u32assert2 u32gte assert # figure out if the range is for an odd number of words (9 cycles) dup.1 dup.1 sub is_odd - # stack: [is_odd, start_addr, end_addr, ...] + # => [is_odd, start_addr, end_addr, ...] # make the start/end range even (4 cycles) movup.2 dup.1 sub - # stack: [end_addr, is_odd, start_addr, ...] + # => [end_addr, is_odd, start_addr, ...] # move start_addr to the right stack position (1 cycles) movup.2 - # stack: [start_addr, end_addr, is_odd, ...] + # => [start_addr, end_addr, is_odd, ...] # prepare hasher state (14 cycles) dup.2 mul.4 push.0.0.0 padw padw - # stack: [C, B, A, start_addr, end_addr, is_odd, ...] + # => [C, B, A, start_addr, end_addr, is_odd, ...] # (4 + 3 * words cycles) exec.absorb_double_words_from_memory + # => [C', B', A', end_addr, end_addr, is_odd, ...] # (1 cycles) movup.14 + # => [is_odd, C', B', A', end_addr, end_addr, ...] # handle the odd element, if any (12 cycles) if.true - # start_addr and end_addr are equal after calling `absorb_double_words_from_memory`, and both point - # to the last element. Load the last word (6 cycles) + # start_addr and end_addr are equal after calling `absorb_double_words_from_memory`, and both + # point to the last element. Load the last word (6 cycles) dropw dup.9 mem_loadw + # => [D, A', end_addr, end_addr, ...] - # set the padding (4 cycles) - padw - - # (1 cycles) - hperm + # set the padding and compute the permutation (5 cycles) + padw hperm end exec.squeeze_digest + # => [HASH, end_addr, end_addr, ...] # drop start_addr/end_addr (4 cycles) movup.4 drop movup.4 drop + # => [HASH] +end + +#! Computes hash of Felt values starting at the specified memory address. +#! +#! This procedure divides the hashing process into two parts: hashing pairs of words using +#! `absorb_double_words_from_memory` procedure and hashing the remaining values using the `hperm` +#! instruction. +#! +#! Inputs: [ptr, num_elements] +#! Outputs: [HASH] +#! +#! Cycles: +#! - If number of elements divides by 8: 47 cycles + 3 * words +#! - Else: 180 cycles + 3 * words +#! where `words` is the number of quads of input values. +export.hash_memory + # move number of inputs to the top of the stack + swap + # => [num_elements, ptr] + + # get the number of double words + u32divmod.8 swap + # => [num_elements/8, num_elements%8, ptr] + + # get the end_addr for hash_memory_even procedure (end address for pairs of words) + mul.2 dup.2 add movup.2 + # => [ptr, end_addr, num_elements%8] + + # get the capacity element which is equal to num_elements%8 + dup.2 + # => [capacity, ptr, end_addr, num_elements%8] + + # prepare hasher state for RPO permutation + push.0.0.0 padw padw + # => [C, B, A, ptr, end_addr, num_elements%8] + + # hash every pair of words + exec.absorb_double_words_from_memory + # => [C', B', A', ptr', end_addr, num_elements%8] where ptr' = end_addr + + # hash remaining input values if there are any left + # if num_elements%8 is ZERO and there are no elements to hash + dup.14 eq.0 + if.true + # clean the stack + exec.squeeze_digest + swapw drop drop drop movdn.4 + # => [B'] + else + # load the remaining double word + mem_stream + # => [E, D, A', ptr'+2, end_addr, num_elements%8] + + # clean the stack + movup.12 drop movup.12 drop + # => [E, D, A', num_elements%8] + + # get the number of elements we need to drop + # notice that drop_counter could be any number from 1 to 7 + push.8 movup.13 sub movdn.12 + # => [E, D, A', drop_counter] + + ### 0th value ######################################################## + + # we need to drop first value anyway, since number of values is not divisible by 8 + # push the padding 0 on to the stack and move it down to the 6th position + drop push.0 movdn.6 + # => [e_2, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', drop_counter] + + ### 1st value ######################################################## + + # prepare the second element of the E Word for cdrop instruction + push.0 swap + # => [e_2, 0, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', drop_counter] + + # push latch variable onto the stack; this will be the control for the cdrop instruction + push.0 + # => [latch = 0, e_2, 0, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', drop_counter] + + # get the flag whether the drop counter is equal 1 + dup.14 eq.1 + # => [drop_counter == 1, latch = 0, e_2, 0, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', drop_counter] + + # update the latch: if drop_counter == 1, latch will become 1 + or + # => [latch', e_2, 0, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', drop_counter] + + # save the latch value + dup movdn.14 + # => [latch', e_2, 0, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', latch', drop_counter] + + # if latch == 1, drop 0; otherwise drop e_1 + cdrop + # => [e_2_or_0, e_1, e_0, d_3, d_2, d_1, 0, d_0, A', latch', drop_counter] + + # move the calculated value down the stack + movdn.6 + # => [e_1, e_0, d_3, d_2, d_1, 0, e_2_or_0, d_0, A', latch', drop_counter] + + ### 2nd value ######################################################## + + # repeat the above process but now compare drop_counter to 2 + push.0 swap + movup.13 dup.14 eq.2 or + dup movdn.14 + cdrop movdn.6 + # => [e_0, d_3, d_2, d_1, 0, e_2_or_0, e_1_or_0, d_0, A', latch', drop_counter] + + ### 3rd value ######################################################## + + # repeat the above process but now compare drop_counter to 3 + push.0 swap + movup.13 dup.14 eq.3 or + dup movdn.14 + cdrop movdn.6 + # => [d_3, d_2, d_1, 0, e_2_or_0, e_1_or_0, e_0_or_0, d_0, A', latch', drop_counter] + + ### 4th value ######################################################## + + # repeat the above process but now compare drop_counter to 4 + push.0 swap + movup.13 dup.14 eq.4 or + dup movdn.14 + cdrop movdn.6 + # => [d_2, d_1, 0, e_2_or_0, e_1_or_0, e_0_or_0, d_3_or_0, d_0, A', latch', drop_counter] + + ### 5th value ######################################################## + + # repeat the above process but now compare drop_counter to 5 + push.0 swap + movup.13 dup.14 eq.5 or + dup movdn.14 + cdrop movdn.6 + # => [d_1, 0, e_2_or_0, e_1_or_0, e_0_or_0, d_3_or_0, d_2_or_0, d_0, A', latch', drop_counter] + + ### 6th value ######################################################## + + # repeat the above process but now compare drop_counter to 6 + push.0 swap + movup.13 movup.14 eq.6 or + cdrop movdn.6 + # => [0, e_2_or_0, e_1_or_0, e_0_or_0, d_3_or_0, d_2_or_0, d_1_or_0, d_0, A'] + # or in other words + # => [C, B, A', ... ] + # notice that we don't need to check the d_0 value: entering the else branch means that + # we have number of elements not divisible by 8, so we will have at least one element to + # hash here (which turns out to be d_0) + + hperm + # => [F, E, D] + + exec.squeeze_digest + # => [E] + end end diff --git a/stdlib/docs/crypto/hashes/rpo.md b/stdlib/docs/crypto/hashes/rpo.md index eb10fb3cfb..da22de54cc 100644 --- a/stdlib/docs/crypto/hashes/rpo.md +++ b/stdlib/docs/crypto/hashes/rpo.md @@ -4,4 +4,5 @@ Prepares the top of the stack with the hasher initial state.

This pro | ----------- | ------------- | | squeeze_digest | Given the hasher state, returns the hash output.

Input: [C, B, A, ...]
Ouptut: [HASH, ...]
where: For the native RPO hasher HASH is B.
Cycles: 9
| | absorb_double_words_from_memory | Hashes the memory `start_addr` to `end_addr` given an RPO state specified by 3 words.

This requires that `end_addr=start_addr + 2n + 1`, otherwise the procedure will enter an infinite
loop. `end_addr` is not inclusive.

Stack transition:
Input: [C, B, A, start_addr, end_addr, ...]
Output: [C', B', A', end_addr, end_addr ...]
Cycles: 4 + 3 * words, where `words` is the `start_addr - end_addr - 1`

Where `A` is the capacity word that will be used by the hashing function, and `B'` the hash output.
| -| hash_memory | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 49 cycles + 3 * words
odd words: 61 cycles + 3 * words
| +| hash_memory_words | Hashes the memory `start_addr` to `end_addr`, handles odd number of elements.

Requires `start_addr < end_addr`, `end_addr` is not inclusive.

Stack transition:
Input: [start_addr, end_addr, ...]
Output: [H, ...]
Cycles:
even words: 49 cycles + 3 * words
odd words: 61 cycles + 3 * words
| +| hash_memory | Computes hash of Felt values starting at the specified memory address.

This procedure divides the hashing process into two parts: hashing pairs of words using
`absorb_double_words_from_memory` procedure and hashing the remaining values using the `hperm`
instruction.

Inputs: [ptr, num_elements]
Outputs: [HASH]
Cycles:
- If number of elements divides by 8: 47 cycles + 3 * words
- Else: 180 cycles + 3 * words

Panics if number of inputs equals 0.
| diff --git a/stdlib/tests/crypto/rpo.rs b/stdlib/tests/crypto/rpo.rs index da0d0c9d44..affc6d9d9c 100644 --- a/stdlib/tests/crypto/rpo.rs +++ b/stdlib/tests/crypto/rpo.rs @@ -11,28 +11,7 @@ fn test_invalid_end_addr() { push.0999 # end address push.1000 # start address - exec.rpo::hash_memory - end - "; - let test = build_test!(empty_range, &[]); - expect_exec_error!( - test, - ExecutionError::FailedAssertion { - clk: 18.into(), - err_code: 0, - err_msg: None, - } - ); - - // address range can not contain zero elements - let empty_range = " - use.std::crypto::hashes::rpo - - begin - push.1000 # end address - push.1000 # start address - - exec.rpo::hash_memory + exec.rpo::hash_memory_words end "; let test = build_test!(empty_range, &[]); @@ -69,7 +48,7 @@ fn test_hash_empty() { ]).into_iter().map(|e| e.as_int()).collect(); build_test!(two_zeros_mem_stream, &[]).expect_stack(&zero_hash); - // checks the hash compute from 8 zero elements is the same when using hash_memory + // checks the hash compute from 8 zero elements is the same when using hash_memory_words let two_zeros = " use.std::crypto::hashes::rpo @@ -77,7 +56,7 @@ fn test_hash_empty() { push.1002 # end address push.1000 # start address - exec.rpo::hash_memory + exec.rpo::hash_memory_words end "; @@ -110,7 +89,7 @@ fn test_single_iteration() { ]).into_iter().map(|e| e.as_int()).collect(); build_test!(one_memstream, &[]).expect_stack(&one_hash); - // checks the hash of 1 is the same when using hash_memory + // checks the hash of 1 is the same when using hash_memory_words // Note: This is testing the hashing of two words, so no padding is added // here let one_element = " @@ -123,7 +102,7 @@ fn test_single_iteration() { push.1002 # end address push.1000 # start address - exec.rpo::hash_memory + exec.rpo::hash_memory_words end "; @@ -141,7 +120,7 @@ fn test_hash_one_word() { 1, 0, 0, 0, ]).into_iter().map(|e| e.as_int()).collect(); - // checks the hash of 1 is the same when using hash_memory + // checks the hash of 1 is the same when using hash_memory_words let one_element = " use.std::crypto::hashes::rpo @@ -151,7 +130,7 @@ fn test_hash_one_word() { push.1001 # end address push.1000 # start address - exec.rpo::hash_memory + exec.rpo::hash_memory_words end "; @@ -171,7 +150,7 @@ fn test_hash_even_words() { push.1002 # end address push.1000 # start address - exec.rpo::hash_memory + exec.rpo::hash_memory_words end "; @@ -197,7 +176,7 @@ fn test_hash_odd_words() { push.1003 # end address push.1000 # start address - exec.rpo::hash_memory + exec.rpo::hash_memory_words end "; @@ -274,3 +253,130 @@ fn test_squeeze_digest() { build_test!(even_words, &[]).expect_stack(&even_hash); } + +#[test] +fn test_hash_memory() { + // hash fewer than 8 elements + let compute_inputs_hash_5 = " + use.std::crypto::hashes::rpo + + begin + push.1.2.3.4.1000 mem_storew dropw + push.5.0.0.0.1001 mem_storew dropw + push.11 + + push.5.1000 + + exec.rpo::hash_memory + end + "; + + #[rustfmt::skip] + let mut expected_hash: Vec = build_expected_hash(&[ + 1, 2, 3, 4, 5 + ]).into_iter().map(|e| e.as_int()).collect(); + // make sure that value `11` stays unchanged + expected_hash.push(11); + build_test!(compute_inputs_hash_5, &[]).expect_stack(&expected_hash); + + // hash exactly 8 elements + let compute_inputs_hash_8 = " + use.std::crypto::hashes::rpo + + begin + push.1.2.3.4.1000 mem_storew dropw + push.5.6.7.8.1001 mem_storew dropw + push.11 + + push.8.1000 + + exec.rpo::hash_memory + end + "; + + #[rustfmt::skip] + let mut expected_hash: Vec = build_expected_hash(&[ + 1, 2, 3, 4, 5, 6, 7, 8 + ]).into_iter().map(|e| e.as_int()).collect(); + // make sure that value `11` stays unchanged + expected_hash.push(11); + build_test!(compute_inputs_hash_8, &[]).expect_stack(&expected_hash); + + // hash more than 8 elements + let compute_inputs_hash_15 = " + use.std::crypto::hashes::rpo + + begin + push.1.2.3.4.1000 mem_storew dropw + push.5.6.7.8.1001 mem_storew dropw + push.9.10.11.12.1002 mem_storew dropw + push.13.14.15.0.1003 mem_storew dropw + push.11 + + push.15.1000 + + exec.rpo::hash_memory + end + "; + + #[rustfmt::skip] + let mut expected_hash: Vec = build_expected_hash(&[ + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15 + ]).into_iter().map(|e| e.as_int()).collect(); + // make sure that value `11` stays unchanged + expected_hash.push(11); + build_test!(compute_inputs_hash_15, &[]).expect_stack(&expected_hash); +} + +#[test] +fn test_hash_memory_empty() { + // absorb_double_words_from_memory + let source = " + use.std::crypto::hashes::rpo + + begin + push.1000 # end address + push.1000 # start address + padw padw padw # hasher state + + exec.rpo::absorb_double_words_from_memory + end + "; + + let mut expected_stack = vec![0; 12]; + expected_stack.push(1000); + expected_stack.push(1000); + + build_test!(source, &[]).expect_stack(&expected_stack); + + // hash_memory_words + let source = " + use.std::crypto::hashes::rpo + + begin + push.1000 # end address + push.1000 # start address + + exec.rpo::hash_memory_words + end + "; + + build_test!(source, &[]).expect_stack(&[0; 4]); + + // hash_memory + let source = " + use.std::crypto::hashes::rpo + + begin + push.0 # number of elements to hash + push.1000 # start address + + exec.rpo::hash_memory + end + "; + + build_test!(source, &[]).expect_stack(&[0; 16]); +} From 816e28c8f53b8f15d9b50103e21ac6c59c145f01 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 18 Oct 2024 13:07:18 +0300 Subject: [PATCH 11/12] chore: migrate miden-vm to use miden-crypto v0.11.0 --- CHANGELOG.md | 8 ++------ Cargo.lock | 5 +++-- Cargo.toml | 2 +- core/Cargo.toml | 4 ++-- rust-toolchain.toml | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e62b3bbfbb..273cbb9dd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,7 @@ - [BREAKING] ExecutionOptions::new constructor requires a boolean to explicitly set debug mode (#1502) - [BREAKING] The `run` and the `prove` commands in the cli will accept `--trace` flag instead of `--tracing` (#1502) - Migrated to new padding rule for RPO (#1343). - +- Migrated to `miden-crypto` v0.11.0 (#1343). #### Fixes @@ -27,13 +27,9 @@ - Fixed a bug in the block stack table (#1511) (#1512) - Fixed the construction of the chiplets virtual table (#1514) - Fixed the construction of the chiplets bus (#1516) (#1525) - -#### Fixes - - Decorators are now allowed in empty basic blocks (#1466) - -## 0.10.6 (2024-09-12) - `miden-processor` crate only. +## 0.10.6 (2024-09-12) - `miden-processor` crate only #### Enhancements diff --git a/Cargo.lock b/Cargo.lock index 5bee90e488..314f8ec42b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1052,8 +1052,9 @@ dependencies = [ [[package]] name = "miden-crypto" -version = "0.10.1" -source = "git+https://github.com/0xPolygonMiden/crypto?branch=al-rpo-new-padding-rule#c83729c46fceb4b0c18e69cec016d25df9cfb742" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0ca714c8242f329b9ea6f1a5bf0e93f1490f348f982e3a606d91b884254308" dependencies = [ "blake3", "cc", diff --git a/Cargo.toml b/Cargo.toml index ac69f241ed..30d5cdbdff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ resolver = "2" [workspace.package] edition = "2021" -rust-version = "1.80" +rust-version = "1.82" license = "MIT" readme = "README.md" authors = ["Miden contributors"] diff --git a/core/Cargo.toml b/core/Cargo.toml index 3dd8eeea4b..28c7fdac3f 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -34,8 +34,8 @@ std = [ lock_api = { version = "0.4", features = ["arc_lock"] } math = { package = "winter-math", version = "0.9", default-features = false } memchr = { version = "2.7", default-features = false } -#miden-crypto = { version = "0.10", default-features = false } -miden-crypto = { git = "https://github.com/0xPolygonMiden/crypto", branch = "al-rpo-new-padding-rule", default-features = false } +miden-crypto = { version = "0.11", default-features = false } +#miden-crypto = { git = "https://github.com/0xPolygonMiden/crypto", branch = "al-rpo-new-padding-rule", default-features = false } miden-formatting = { version = "0.1", default-features = false } miette = { package = "miden-miette", version = "7.1", default-features = false, features = [ "fancy-no-syscall", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 11ec1f8414..a1c01e0415 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.80" +channel = "1.82" components = ["rustfmt", "rust-src", "clippy"] targets = ["wasm32-unknown-unknown"] profile = "minimal" From 2333ec3a3d70c3dc0356c420aa7801b369d19ce6 Mon Sep 17 00:00:00 2001 From: Andrey Date: Fri, 18 Oct 2024 19:05:10 +0300 Subject: [PATCH 12/12] refactor: remove commented dependency --- core/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 28c7fdac3f..aa23ce30d1 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -35,7 +35,6 @@ lock_api = { version = "0.4", features = ["arc_lock"] } math = { package = "winter-math", version = "0.9", default-features = false } memchr = { version = "2.7", default-features = false } miden-crypto = { version = "0.11", default-features = false } -#miden-crypto = { git = "https://github.com/0xPolygonMiden/crypto", branch = "al-rpo-new-padding-rule", default-features = false } miden-formatting = { version = "0.1", default-features = false } miette = { package = "miden-miette", version = "7.1", default-features = false, features = [ "fancy-no-syscall",