@ -1,12 +1,20 @@ |
|||||
[package] |
[package] |
||||
name = "crypto" |
name = "crypto" |
||||
version = "0.1.0" |
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" |
edition = "2021" |
||||
|
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html |
|
||||
|
|
||||
[dependencies] |
[dependencies] |
||||
winterfell = { git = "https://github.com/novifinancial/winterfell"} |
winterfell = { git = "https://github.com/novifinancial/winterfell"} |
||||
winter_utils = { version = "0.4", package = "winter-utils" } |
winter_utils = { version = "0.4", package = "winter-utils" } |
||||
rand_utils = { version = "0.4", package = "winter-rand-utils" } |
rand_utils = { version = "0.4", package = "winter-rand-utils" } |
||||
proptest = "1.0.0" |
|
||||
|
|
||||
|
|
||||
|
[dev-dependencies] |
||||
|
proptest = "1.0.0" |
@ -1 +1,32 @@ |
|||||
|
use winterfell::crypto::{ElementHasher};
|
||||
|
use winterfell::math::StarkField;
|
||||
|
use winterfell::crypto::Hasher as HashFn;
|
||||
|
use winterfell::crypto::hashers::Rp64_256 as Hasher;
|
||||
|
|
||||
|
mod rpo;
|
||||
|
pub use rpo::Rpo;
|
||||
|
|
||||
|
|
||||
|
// TYPE ALIASES
|
||||
|
// ================================================================================================
|
||||
|
|
||||
|
pub type Digest = <Hasher as HashFn>::Digest;
|
||||
|
|
||||
|
|
||||
|
// HELPER FUNCTIONS
|
||||
|
// ================================================================================================
|
||||
|
|
||||
|
#[inline(always)]
|
||||
|
fn exp_acc<B: StarkField, const N: usize, const M: usize>(base: [B; N], tail: [B; N]) -> [B; N] {
|
||||
|
let mut result = base;
|
||||
|
for _ in 0..M {
|
||||
|
result.iter_mut().for_each(|r| *r = r.square());
|
||||
|
}
|
||||
|
result.iter_mut().zip(tail).for_each(|(r, t)| *r *= t);
|
||||
|
result
|
||||
|
}
|
||||
|
|
||||
|
#[inline(always)]
|
||||
|
pub fn merge(values: &[Digest; 2]) -> Digest {
|
||||
|
Hasher::merge(values)
|
||||
|
}
|