refactor: flattened repo structure
Bobbin Threadbare bobbinth@protonmail.com
Wed, 26 Oct 2022 14:54:38 -0700
11 files changed,
33 insertions(+),
34 deletions(-)
M
Cargo.toml
→
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" }
D
crypto/Cargo.toml
@@ -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" }
M
crypto/src/hash/rpo/digest.rs
→
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
M
crypto/src/hash/rpo/mds_freq.rs
→
src/hash/rpo/mds_freq.rs
@@ -34,11 +34,11 @@ let (u4, u5, u6) = fft4_real([s1, s4, s7, s10]);
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 @@
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);
M
crypto/src/hash/rpo/mod.rs
→
src/hash/rpo/mod.rs
@@ -5,11 +5,11 @@
mod digest; pub use digest::RpoDigest256; -#[cfg(test)] -mod tests; - mod mds_freq; use mds_freq::mds_multiply_freq; + +#[cfg(test)] +mod tests; // CONSTANTS // ================================================================================================
M
crypto/src/hash/rpo/tests.rs
→
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 @@ }
#[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 @@ Felt::new(18),
]; 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); }