Skip to content

Commit

Permalink
Remove nonce hashing & resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
expede committed Mar 27, 2024
1 parent 3e8826b commit 4d8ca6d
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions src/crypto/nonce.rs
Expand Up @@ -4,11 +4,7 @@

use enum_as_inner::EnumAsInner;
use getrandom::getrandom;
use libipld_core::{
ipld::Ipld,
multibase::Base::Base32HexLower,
multihash::{Hasher, Sha2_256},
};
use libipld_core::{ipld::Ipld, multibase::Base::Base32HexLower};
use serde::{Deserialize, Serialize};
use std::fmt;

Expand Down Expand Up @@ -86,19 +82,7 @@ impl Nonce {
pub fn generate_16() -> Nonce {
let mut buf = [0; 16];
getrandom(&mut buf).expect("irrecoverable getrandom failure");

let mut hasher = Sha2_256::default();
hasher.update(&mut buf);

let bytes = hasher
.finalize()
.chunks(16)
.next()
.expect("SHA2_256 is 32 bytes")
.try_into()
.expect("we set the length to 16 earlier");

Nonce::Nonce16(bytes)
Nonce::Nonce16(buf)
}
}

Expand Down

0 comments on commit 4d8ca6d

Please sign in to comment.