Skip to content

Commit 1a51471

Browse files
committed
add some more doc
1 parent 3b8f45f commit 1a51471

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

crates/components/hmac-sha256/src/prf/function/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//! Provides [`PrfFunction`], for computing the TLS 1.2 PRF.
2+
//!
3+
//! If the feature flag `local-inner-hash` is set, provides an implementation which computes
4+
//! some hashes locally.
5+
16
use crate::{sha256::Sha256, PrfError};
27
use mpz_circuits::circuits::xor;
38
use mpz_vm_core::{
@@ -19,14 +24,22 @@ mod local;
1924
#[cfg(feature = "local-inner-hash")]
2025
pub(crate) use local::PrfFunction;
2126

27+
/// Depending on the provided `mask` computes and returns `outer_partial` or `inner_partial` for
28+
/// HMAC-SHA256.
29+
///
30+
/// # Arguments
31+
///
32+
/// * `vm` - Virtual machine.
33+
/// * `key` - Key to pad and xor.
34+
/// * `mask`- Mask used for padding.
2235
fn compute_partial(
2336
vm: &mut dyn Vm<Binary>,
24-
data: Vector<U8>,
37+
key: Vector<U8>,
2538
mask: [u8; 64],
2639
) -> Result<Array<U32, 8>, PrfError> {
2740
let xor = Arc::new(xor(8 * 64));
2841

29-
let additional_len = 64 - data.len();
42+
let additional_len = 64 - key.len();
3043
let padding = vec![0_u8; additional_len];
3144

3245
let padding_ref: Vector<U8> = vm.alloc_vec(additional_len).map_err(PrfError::vm)?;
@@ -40,7 +53,7 @@ fn compute_partial(
4053
vm.commit(mask_ref).map_err(PrfError::vm)?;
4154

4255
let xor = Call::builder(xor)
43-
.arg(data)
56+
.arg(key)
4457
.arg(padding_ref)
4558
.arg(mask_ref)
4659
.build()

crates/components/hmac-sha256/src/prf/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use state::State;
1717
mod function;
1818
use function::PrfFunction;
1919

20-
/// MPC PRF for computing TLS HMAC-SHA256 PRF.
20+
/// MPC PRF for computing TLS 1.2 HMAC-SHA256 PRF.
2121
#[derive(Debug)]
2222
pub struct MpcPrf {
2323
state: State,
@@ -209,6 +209,7 @@ impl MpcPrf {
209209
}
210210
}
211211

212+
/// Contains the respective [`PrfFunction`]s.
212213
#[derive(Debug)]
213214
struct Circuits {
214215
pub(crate) master_secret: PrfFunction,

0 commit comments

Comments
 (0)