Skip to content

Commit

Permalink
okready
Browse files Browse the repository at this point in the history
  • Loading branch information
cf committed Mar 31, 2024
1 parent 97a49a3 commit 7880577
Show file tree
Hide file tree
Showing 25 changed files with 586 additions and 131 deletions.
247 changes: 247 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ edition = "2021"
[dependencies]
blake2 = "0.10.6"
blake3 = "1.5.0"
sha2 = "0.10.8"
hex = "0.4.3"
itertools = "0.12.0"
num-traits = "0.2.17"
thiserror = "1.0.56"
merging-iterator = "1.3.0"
bytemuck = { version = "1.14.3", features = ["derive"] }

serde = { version = "1.0.145", features = ["derive"] }
serde_with = { version = "2.2.0", features = ["hex"] }
serde_json = "1.0.86"


[dev-dependencies]
criterion = { version = "0.5.1", features = ["html_reports"] }
rand = { version = "0.8.5", features = ["small_rng"] }
Expand Down
13 changes: 9 additions & 4 deletions src/commitment_scheme/blake2_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ use std::fmt;

use blake2::digest::{Update, VariableOutput};
use blake2::{Blake2s256, Blake2sVar, Digest};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;



#[serde_as]
#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Default, Eq)]
pub struct Blake2sHash(#[serde_as(as = "serde_with::hex::Hex")] pub [u8; 32]);

// Wrapper for the blake2s hash type.
#[derive(Clone, Copy, PartialEq, Default, Eq)]
pub struct Blake2sHash([u8; 32]);

impl From<Blake2sHash> for Vec<u8> {
fn from(value: Blake2sHash) -> Self {
Expand Down Expand Up @@ -115,7 +120,7 @@ impl super::hasher::Hasher for Blake2sHasher {
})
}

fn hash_with_nonce(&self, seed: &[Self::NativeType], nonce: u64) -> Self::Hash {
fn hash_with_nonce(seed: &[Self::NativeType], nonce: u64) -> Self::Hash {
let hash_input = seed
.iter()
.chain(nonce.to_le_bytes().iter())
Expand Down
Loading

0 comments on commit 7880577

Please sign in to comment.