Skip to content

Commit eb562f0

Browse files
committed
rust/hash: name struct field for clarity
1 parent 9e4b45d commit eb562f0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/rust/bitbox02-rust/src/hash.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ use alloc::vec::Vec;
2121
/// This implementation accumulates the data to be hashed in heap, it does **not** hash in a
2222
/// streaming fashion, even when using `update()`.
2323
#[derive(Default, Clone)]
24-
pub struct Sha512(Vec<u8>);
24+
pub struct Sha512 {
25+
message: Vec<u8>,
26+
}
2527

2628
impl digest::HashMarker for Sha512 {}
2729

@@ -32,20 +34,20 @@ impl digest::OutputSizeUser for Sha512 {
3234
impl digest::FixedOutput for Sha512 {
3335
fn finalize_into(self, out: &mut digest::Output<Self>) {
3436
// use digest::Digest;
35-
// out.copy_from_slice(&sha2::Sha512::digest(&self.0));
36-
out.copy_from_slice(&bitbox02::sha512(&self.0));
37+
// out.copy_from_slice(&sha2::Sha512::digest(&self.message));
38+
out.copy_from_slice(&bitbox02::sha512(&self.message));
3739
}
3840
}
3941

4042
impl digest::Update for Sha512 {
4143
fn update(&mut self, data: &[u8]) {
42-
self.0.extend(data);
44+
self.message.extend(data);
4345
}
4446
}
4547

4648
impl digest::Reset for Sha512 {
4749
fn reset(&mut self) {
48-
self.0 = vec![];
50+
self.message = vec![];
4951
}
5052
}
5153

0 commit comments

Comments
 (0)