Skip to content

Commit

Permalink
Update protocols/v2/noise-sv2/src/handshake.rs
Browse files Browse the repository at this point in the history
Co-authored-by: RJ Rybarczyk <[email protected]>
  • Loading branch information
Shourya742 and rrybarczyk authored Sep 2, 2024
1 parent 3834c95 commit d51c61c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions protocols/v2/noise-sv2/src/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ pub trait HandshakeOp<Cipher: AeadCipher>: CipherState<Cipher> {
/// Sets the `ck` value to the provided data, updating the chaining key.
fn set_ck(&mut self, data: [u8; 32]);

/// Mixes the provided data into the current hash `h` value.
/// Mixes the data into the handshake hash (`h`).
///
/// The `mix_hash` method is used to update the internal hash state `h` with new data.
/// It concatenates the current hash `h` with the provided data and then rehashes the
/// result using SHA-256. This process is crucial for maintaining a running hash of all the
/// messages exchanged during the handshake, ensuring message integrity and
/// protecting again replay attacks.
/// Updates the current handshake hash by combining it with the provided `data`. The result is
/// a new SHA-256 hash digest that reflects all previous handshake messages, ensuring the
/// integrity of the handshake process. This method is typically called whenever a new piece of
/// data (e.g., a public key or ciphertext) needs to be incorporated into the handshake state.
fn mix_hash(&mut self, data: &[u8]) {
let h = self.get_h();
let mut to_hash = Vec::with_capacity(32 + data.len());
Expand Down

0 comments on commit d51c61c

Please sign in to comment.