diff --git a/Cargo.toml b/Cargo.toml index 33788f5..01d456d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,20 @@ -[workspace] -members = [ - "crypto" -] +[package] +name = "miden-crypto" +version = "0.1.0" +description="Miden Cryptographic primitives" +authors = ["miden contributors"] +readme="README.md" +license = "MIT" +repository = "https://github.com/0xPolygonMiden/crypto" +categories = ["cryptography", "no-std"] +keywords = ["miden", "crypto", "hash", "merkle"] +edition = "2021" + +[dependencies] +winter_crypto = { version = "0.4.1", package = "winter-crypto" } +winter_math = { version = "0.4.1", package = "winter-math" } +winter_utils = { version = "0.4.1", package = "winter-utils" } + +[dev-dependencies] +proptest = "1.0.0" +rand_utils = { version = "0.4", package = "winter-rand-utils" } diff --git a/crypto/Cargo.toml b/crypto/Cargo.toml deleted file mode 100644 index 7d5b908..0000000 --- a/crypto/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "crypto" -version = "0.1.0" -description="Miden Cryptographic primitives" -authors = ["miden contributors"] -readme="README.md" -license = "MIT" -repository = "https://github.com/0xPolygonMiden/crypto" -categories = ["cryptography", "no-std"] -keywords = ["miden", "crypto", "hash", "merkle"] -edition = "2021" - -[dependencies] -winter_utils = { version = "0.4.1", package = "winter-utils" } -winter_math = { version = "0.4.1", package = "winter-math" } -winter_crypto = { version = "0.4.1", package = "winter-crypto" } - -[dev-dependencies] -proptest = "1.0.0" -rand_utils = { version = "0.4", package = "winter-rand-utils" } \ No newline at end of file diff --git a/crypto/src/hash/mod.rs b/src/hash/mod.rs similarity index 100% rename from crypto/src/hash/mod.rs rename to src/hash/mod.rs diff --git a/crypto/src/hash/rpo/digest.rs b/src/hash/rpo/digest.rs similarity index 95% rename from crypto/src/hash/rpo/digest.rs rename to src/hash/rpo/digest.rs index 3eef96f..ce31f3e 100644 --- a/crypto/src/hash/rpo/digest.rs +++ b/src/hash/rpo/digest.rs @@ -1,6 +1,8 @@ use super::DIGEST_SIZE; -use crate::{ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable}; -use crate::{Digest, Felt, StarkField, ZERO}; +use crate::{ + ByteReader, ByteWriter, Deserializable, DeserializationError, Digest, Felt, Serializable, + StarkField, ZERO, +}; use core::ops::Deref; // DIGEST TRAIT IMPLEMENTATIONS diff --git a/crypto/src/hash/rpo/mds_freq.rs b/src/hash/rpo/mds_freq.rs similarity index 97% rename from crypto/src/hash/rpo/mds_freq.rs rename to src/hash/rpo/mds_freq.rs index 8766bed..217ef51 100644 --- a/crypto/src/hash/rpo/mds_freq.rs +++ b/src/hash/rpo/mds_freq.rs @@ -34,11 +34,11 @@ pub(crate) const fn mds_multiply_freq(state: [u64; 12]) -> [u64; 12] { let (u8, u9, u10) = fft4_real([s2, s5, s8, s11]); // This where the multiplication in frequency domain is done. More precisely, and with - // the appropriate permuations in between, the sequence of + // the appropriate permutations in between, the sequence of // 3-point FFTs --> multiplication by twiddle factors --> Hadamard multiplication --> // 3 point iFFTs --> multiplication by (inverse) twiddle factors // is "squashed" into one step composed of the functions "block1", "block2" and "block3". - // The expressions in the aformentioned functions are the result of explicit computations + // The expressions in the aforementioned functions are the result of explicit computations // combined with the Karatsuba trick for the multiplication of Complex numbers. let [v0, v4, v8] = block1([u0, u4, u8], MDS_FREQ_BLOCK_ONE); @@ -184,7 +184,7 @@ mod tests { for i in 0..STATE_WIDTH { v1[i] = Felt::new(a[i]); } - v2 = v1.clone(); + v2 = v1; apply_mds_naive(&mut v1); Rpo256::apply_mds(&mut v2); diff --git a/crypto/src/hash/rpo/mod.rs b/src/hash/rpo/mod.rs similarity index 100% rename from crypto/src/hash/rpo/mod.rs rename to src/hash/rpo/mod.rs index 5a88eb8..4f82205 100644 --- a/crypto/src/hash/rpo/mod.rs +++ b/src/hash/rpo/mod.rs @@ -5,12 +5,12 @@ use core::{convert::TryInto, ops::Range}; mod digest; pub use digest::RpoDigest256; -#[cfg(test)] -mod tests; - mod mds_freq; use mds_freq::mds_multiply_freq; +#[cfg(test)] +mod tests; + // CONSTANTS // ================================================================================================ diff --git a/crypto/src/hash/rpo/tests.rs b/src/hash/rpo/tests.rs similarity index 98% rename from crypto/src/hash/rpo/tests.rs rename to src/hash/rpo/tests.rs index 7f3bc37..5d2be38 100644 --- a/crypto/src/hash/rpo/tests.rs +++ b/src/hash/rpo/tests.rs @@ -6,6 +6,7 @@ use core::convert::TryInto; use rand_utils::rand_value; #[test] +#[allow(clippy::needless_range_loop)] fn mds_inv_test() { let mut mul_result = [[Felt::new(0); STATE_WIDTH]; STATE_WIDTH]; for i in 0..STATE_WIDTH { @@ -29,7 +30,7 @@ fn mds_inv_test() { #[test] fn test_alphas() { let e: Felt = Felt::new(rand_value()); - let e_exp = e.exp(ALPHA.into()); + let e_exp = e.exp(ALPHA); assert_eq!(e, e_exp.exp(INV_ALPHA)); } @@ -181,7 +182,7 @@ fn hash_test_vectors() { ]; for i in 0..elements.len() { - let expected = RpoDigest256::new(EXPECTED[i].try_into().unwrap()); + let expected = RpoDigest256::new(EXPECTED[i]); let result = Rpo256::hash_elements(&elements[..(i + 1)]); assert_eq!(result, expected); } diff --git a/crypto/src/lib.rs b/src/lib.rs similarity index 100% rename from crypto/src/lib.rs rename to src/lib.rs diff --git a/crypto/src/merkle/merkle_path_set.rs b/src/merkle/merkle_path_set.rs similarity index 100% rename from crypto/src/merkle/merkle_path_set.rs rename to src/merkle/merkle_path_set.rs diff --git a/crypto/src/merkle/merkle_tree.rs b/src/merkle/merkle_tree.rs similarity index 100% rename from crypto/src/merkle/merkle_tree.rs rename to src/merkle/merkle_tree.rs diff --git a/crypto/src/merkle/mod.rs b/src/merkle/mod.rs similarity index 100% rename from crypto/src/merkle/mod.rs rename to src/merkle/mod.rs