Cleanup
This commit is contained in:
parent
4d89ce6fc4
commit
88429bfc1a
|
@ -43,7 +43,7 @@ primitive-types = "0.11.1"
|
|||
proptest = { version = "1.0", optional = true }
|
||||
rand = "0.8.4"
|
||||
rayon = "1.5.1"
|
||||
ruint = { version = "1.1.0", path = "../../WV/uint", features = [ "serde", "poseidon-rs", "num-bigint", "ark-ff" ] }
|
||||
ruint = { version = "1.1.0", path = "../../WV/uint", features = [ "serde", "num-bigint", "ark-ff" ] }
|
||||
serde = "1.0"
|
||||
sha2 = "0.10.1"
|
||||
thiserror = "1.0.0"
|
||||
|
|
|
@ -206,7 +206,7 @@ pub const C1: [[U256; 2]; 64] = [
|
|||
0x1574c7ef0c43545f36a8ca08bdbdd8b075d2959e2f322b731675de3e1982b4d0_U256,
|
||||
0x269e4b5b7a2eb21afd567970a717ceec5bd4184571c254fdc06e03a7ff8378f0_U256,
|
||||
],
|
||||
];
|
||||
];
|
||||
|
||||
pub const M: [[U256; 3]; 3] = [
|
||||
[
|
||||
|
|
|
@ -69,6 +69,12 @@ static C: Lazy<[[Fr; 3]; 65]> = Lazy::new(|| {
|
|||
.unwrap()
|
||||
});
|
||||
|
||||
/// Compute the one-value Poseidon hash function.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `input` is not a valid field element.
|
||||
#[must_use]
|
||||
pub fn hash1(value: U256) -> U256 {
|
||||
let value = value.try_into().unwrap();
|
||||
let mut state = [Fr::zero(), value];
|
||||
|
@ -93,6 +99,12 @@ pub fn hash1(value: U256) -> U256 {
|
|||
state[0].into()
|
||||
}
|
||||
|
||||
/// Compute the two-value Poseidon hash function.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `left`, `right` are not a valid field element.
|
||||
#[must_use]
|
||||
pub fn hash2(left: U256, right: U256) -> U256 {
|
||||
let left = left.try_into().unwrap();
|
||||
let right = right.try_into().unwrap();
|
||||
|
@ -139,7 +151,6 @@ mod tests {
|
|||
uint! {
|
||||
assert_eq!(hash2(0_U256, 0_U256), 0x2098f5fb9e239eab3ceac3f27b81e481dc3124d55ffed523a839ee8446b64864_U256);
|
||||
assert_eq!(hash2(31213_U256, 132_U256), 0x303f59cd0831b5633bcda50514521b33776b5d4280eb5868ba1dbbe2e4d76ab5_U256);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue