Correctly interpret BLAKE2s inputs and outputs as little endian.
This commit is contained in:
parent
87c62e2248
commit
f491e02b56
|
@ -343,7 +343,7 @@ mod test {
|
||||||
|
|
||||||
let mut out = out.into_iter();
|
let mut out = out.into_iter();
|
||||||
for b in expected.into_iter() {
|
for b in expected.into_iter() {
|
||||||
for i in (0..8).rev() {
|
for i in 0..8 {
|
||||||
let c = out.next().unwrap().get_value().unwrap();
|
let c = out.next().unwrap().get_value().unwrap();
|
||||||
|
|
||||||
assert_eq!(c, (b >> i) & 1u8 == 1u8);
|
assert_eq!(c, (b >> i) & 1u8 == 1u8);
|
||||||
|
@ -405,7 +405,7 @@ mod test {
|
||||||
let mut input_bits = vec![];
|
let mut input_bits = vec![];
|
||||||
|
|
||||||
for (byte_i, input_byte) in data.into_iter().enumerate() {
|
for (byte_i, input_byte) in data.into_iter().enumerate() {
|
||||||
for bit_i in (0..8).rev() {
|
for bit_i in 0..8 {
|
||||||
let cs = cs.namespace(|| format!("input bit {} {}", byte_i, bit_i));
|
let cs = cs.namespace(|| format!("input bit {} {}", byte_i, bit_i));
|
||||||
|
|
||||||
input_bits.push(AllocatedBit::alloc(cs, Some((input_byte >> bit_i) & 1u8 == 1u8)).unwrap().into());
|
input_bits.push(AllocatedBit::alloc(cs, Some((input_byte >> bit_i) & 1u8 == 1u8)).unwrap().into());
|
||||||
|
@ -417,7 +417,7 @@ mod test {
|
||||||
assert!(cs.is_satisfied());
|
assert!(cs.is_satisfied());
|
||||||
|
|
||||||
let mut s = hash_result.as_ref().iter()
|
let mut s = hash_result.as_ref().iter()
|
||||||
.flat_map(|&byte| (0..8).rev().map(move |i| (byte >> i) & 1u8 == 1u8));
|
.flat_map(|&byte| (0..8).map(move |i| (byte >> i) & 1u8 == 1u8));
|
||||||
|
|
||||||
for b in r {
|
for b in r {
|
||||||
match b {
|
match b {
|
||||||
|
|
|
@ -114,10 +114,7 @@ impl UInt32 {
|
||||||
|
|
||||||
/// Turns this `UInt32` into its little-endian byte order representation.
|
/// Turns this `UInt32` into its little-endian byte order representation.
|
||||||
pub fn into_bits(&self) -> Vec<Boolean> {
|
pub fn into_bits(&self) -> Vec<Boolean> {
|
||||||
self.bits.chunks(8)
|
self.bits.clone()
|
||||||
.flat_map(|v| v.iter().rev())
|
|
||||||
.cloned()
|
|
||||||
.collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a little-endian byte order representation of bits into a
|
/// Converts a little-endian byte order representation of bits into a
|
||||||
|
@ -126,10 +123,7 @@ impl UInt32 {
|
||||||
{
|
{
|
||||||
assert_eq!(bits.len(), 32);
|
assert_eq!(bits.len(), 32);
|
||||||
|
|
||||||
let new_bits = bits.chunks(8)
|
let new_bits = bits.to_vec();
|
||||||
.flat_map(|v| v.iter().rev())
|
|
||||||
.cloned()
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let mut value = Some(0u32);
|
let mut value = Some(0u32);
|
||||||
for b in new_bits.iter().rev() {
|
for b in new_bits.iter().rev() {
|
||||||
|
|
Loading…
Reference in New Issue