sinsemilla: Use lebs2ip_K to match protocol spec naming

This commit is contained in:
Jack Grigg 2021-03-02 01:21:07 +00:00
parent a26e1c7879
commit 22658c3bc4
1 changed files with 3 additions and 2 deletions

View File

@ -12,7 +12,8 @@ const GROUP_HASH_S: &str = "z.cash:SinsemillaS";
const K: usize = 10;
const C: usize = 253;
fn lebs2ip_32(bits: &[bool]) -> u32 {
fn lebs2ip_K(bits: &[bool]) -> u32 {
assert!(bits.len() == K);
bits.iter()
.enumerate()
.fold(0u32, |acc, (i, b)| acc + if *b { 1 << i } else { 0 })
@ -90,7 +91,7 @@ pub(crate) fn hash_to_point(domain_prefix: &str, msg: impl Iterator<Item = bool>
let padded: Vec<_> = Pad::new(msg).collect();
let hasher_S = pallas::Point::hash_to_curve(GROUP_HASH_S);
let S = |chunk: &[bool]| hasher_S(&lebs2ip_32(chunk).to_le_bytes());
let S = |chunk: &[bool]| hasher_S(&lebs2ip_K(chunk).to_le_bytes());
padded
.chunks(K)