Browse Source

refactor: flattened repo structure

al-gkr-basic-workflow
Bobbin Threadbare 2 years ago
parent
commit
7395697a68
11 changed files with 33 additions and 34 deletions
  1. +20
    -4
      Cargo.toml
  2. +0
    -20
      crypto/Cargo.toml
  3. +0
    -0
      src/hash/mod.rs
  4. +4
    -2
      src/hash/rpo/digest.rs
  5. +3
    -3
      src/hash/rpo/mds_freq.rs
  6. +3
    -3
      src/hash/rpo/mod.rs
  7. +3
    -2
      src/hash/rpo/tests.rs
  8. +0
    -0
      src/lib.rs
  9. +0
    -0
      src/merkle/merkle_path_set.rs
  10. +0
    -0
      src/merkle/merkle_tree.rs
  11. +0
    -0
      src/merkle/mod.rs

+ 20
- 4
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" }

+ 0
- 20
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" }

crypto/src/hash/mod.rs → src/hash/mod.rs


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

crypto/src/hash/rpo/mds_freq.rs → 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);

crypto/src/hash/rpo/mod.rs → src/hash/rpo/mod.rs


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 @@ 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);
}

crypto/src/lib.rs → src/lib.rs


crypto/src/merkle/merkle_path_set.rs → src/merkle/merkle_path_set.rs


crypto/src/merkle/merkle_tree.rs → src/merkle/merkle_tree.rs


crypto/src/merkle/mod.rs → src/merkle/mod.rs


Loading…
Cancel
Save