mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 14:48:08 -05:00
dao: replace use of blake3 hash with blake2b. See code comments for explanation of the rationale
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1955,7 +1955,7 @@ dependencies = [
|
||||
name = "darkfi_dao_contract"
|
||||
version = "0.4.1"
|
||||
dependencies = [
|
||||
"blake3 1.5.0",
|
||||
"blake2b_simd",
|
||||
"bs58",
|
||||
"chacha20poly1305",
|
||||
"darkfi",
|
||||
|
||||
@@ -9,7 +9,7 @@ edition = "2021"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
blake3 = "1.5.0"
|
||||
blake2b_simd = "1.0.2"
|
||||
bs58 = "0.5.0"
|
||||
darkfi-sdk = { path = "../../sdk" }
|
||||
darkfi-serial = { path = "../../serial", features = ["derive", "crypto"] }
|
||||
|
||||
@@ -118,12 +118,16 @@ pub trait VecAuthCallCommit {
|
||||
|
||||
impl VecAuthCallCommit for Vec<DaoAuthCall> {
|
||||
fn commit(&self) -> pallas::Base {
|
||||
let mut hasher = blake3::Hasher::new();
|
||||
// Hash a bunch of data, then convert it so pallas::Base
|
||||
// see https://docs.rs/ff/0.13.0/ff/trait.FromUniformBytes.html
|
||||
// We essentially create a really large value and reduce it modulo the field
|
||||
// to diminish the statistical significance of any overlap.
|
||||
let mut hasher =
|
||||
blake2b_simd::Params::new().hash_length(64).personal(b"justDAOthings").to_state();
|
||||
self.encode(&mut hasher).unwrap();
|
||||
let hash = hasher.finalize();
|
||||
let bytes = hash.as_bytes();
|
||||
let raw_base: [u64; 4] = Decodable::decode(&mut bytes.as_slice()).unwrap();
|
||||
pallas::Base::from_raw(raw_base)
|
||||
let bytes = hash.as_array();
|
||||
pallas::Base::from_uniform_bytes(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ pub mod pasta_prelude {
|
||||
pub use pasta_curves::{
|
||||
arithmetic::{CurveAffine, CurveExt},
|
||||
group::{
|
||||
ff::{Field, PrimeField},
|
||||
ff::{Field, FromUniformBytes, PrimeField},
|
||||
Curve, Group,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user