Skip to content

Commit

Permalink
renamed protocol functions
Browse files Browse the repository at this point in the history
  • Loading branch information
10d9e committed Nov 2, 2023
1 parent cb26d4a commit bdb9b7e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/chaum_pedersen/curve25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ChaumPedersen for EllipticCurveChaumPedersen {
///
/// # Returns
/// A tuple containing the commitment parameters and the commitment random value.
fn calculate_commitment(
fn commitment(
params: &Self::GroupParameters, x: &Self::Secret,
) -> (Self::CommitParameters, Self::CommitmentRandom)
where
Expand Down Expand Up @@ -86,7 +86,7 @@ impl ChaumPedersen for EllipticCurveChaumPedersen {
///
/// # Returns
/// The response for the Chaum-Pedersen protocol.
fn calculate_response(
fn challenge_response(
_: &Self::GroupParameters, k: &Self::CommitmentRandom, c: &Self::Challenge,
x: &Self::Secret,
) -> Self::Response
Expand Down Expand Up @@ -165,7 +165,7 @@ mod test {
};

// Calculating the commitment.
let (cp, _) = EllipticCurveChaumPedersen::calculate_commitment(&params, &x);
let (cp, _) = EllipticCurveChaumPedersen::commitment(&params, &x);
let (y1, y2, _, _) = cp;

// Verifying the correctness of the commitment.
Expand Down
8 changes: 4 additions & 4 deletions src/chaum_pedersen/discretelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ChaumPedersen for DiscreteLogChaumPedersen {
/// * A tuple of commitments (`y1`, `y2`, `r1`, `r2`), where `y1` and `y2` are the actual commitments
/// and `r1` and `r2` are the random commitments.
/// * The random value `k` used in the commitment calculations.
fn calculate_commitment(
fn commitment(
params: &Self::GroupParameters, x: &Self::Secret,
) -> (Self::CommitParameters, Self::CommitmentRandom)
where
Expand Down Expand Up @@ -76,7 +76,7 @@ impl ChaumPedersen for DiscreteLogChaumPedersen {
///
/// # Returns
/// A `BigUint` representing the challenge value.
fn calculate_response(
fn challenge_response(
params: &Self::GroupParameters, k: &Self::CommitmentRandom, c: &Self::Challenge,
x: &Self::Secret,
) -> Self::Response
Expand Down Expand Up @@ -140,7 +140,7 @@ mod tests {
q: q.clone(),
};

let (cp, _k) = DiscreteLogChaumPedersen::calculate_commitment(&params, &x);
let (cp, _k) = DiscreteLogChaumPedersen::commitment(&params, &x);
let (y1, y2, r1, r2) = cp;

assert_eq!(y1, params.g.modpow(&x, &params.p));
Expand Down Expand Up @@ -215,7 +215,7 @@ mod tests {
let x = BigUint::from(10u32);
let k = BigUint::from(17u32);
let c = BigUint::from(0u32);
let s = DiscreteLogChaumPedersen::calculate_response(&params, &k, &c, &x);
let s = DiscreteLogChaumPedersen::challenge_response(&params, &k, &c, &x);
println!("Response: {:?}", s);

// server verifies
Expand Down
6 changes: 3 additions & 3 deletions src/chaum_pedersen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait ChaumPedersen {
///
/// # Returns
/// A tuple containing the commitment parameters and the commitment randomness.
fn calculate_commitment(
fn commitment(
params: &Self::GroupParameters, x: &Self::Secret,
) -> (Self::CommitParameters, Self::CommitmentRandom)
where
Expand All @@ -69,7 +69,7 @@ pub trait ChaumPedersen {
where
Self: Sized;

/// Calculates the response in the Chaum-Pedersen protocol.
/// Calculates the challenge response in the Chaum-Pedersen protocol.
///
/// # Arguments
/// * `params` - Group parameters used in the protocol.
Expand All @@ -79,7 +79,7 @@ pub trait ChaumPedersen {
///
/// # Returns
/// The response value in the protocol.
fn calculate_response(
fn challenge_response(
params: &Self::GroupParameters, k: &Self::CommitmentRandom, c: &Self::Challenge,
x: &Self::Secret,
) -> Self::Response
Expand Down
4 changes: 2 additions & 2 deletions src/chaum_pedersen/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ where
T: ChaumPedersen,
{
// The client calculates the commitment using their secret and the group parameters.
let (cp, k) = T::calculate_commitment(params, x);
let (cp, k) = T::commitment(params, x);

// The server (simulated here) sends a challenge to the client.
let c = T::challenge(params);

// The client calculates the response based on the commitment random, challenge,
// and their secret.
let s = T::calculate_response(params, &k, &c, &x);
let s = T::challenge_response(params, &k, &c, &x);

// The server (simulated here) verifies the response against the challenge and
// commitment parameters.
Expand Down
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
S: ByteConvertible<S>,
{
// Client calculates the commitment.
let ((y1, y2, r1, r2), k) = T::calculate_commitment(params, x);
let ((y1, y2, r1, r2), k) = T::commitment(params, x);

// Registers the commitment with the server.
client
Expand All @@ -148,7 +148,7 @@ where
let challenge = S::from_bytes(&c)?;

// Calculates the response to the challenge.
let s = T::calculate_response(&params, &k, &challenge, &x);
let s = T::challenge_response(&params, &k, &challenge, &x);

// Sends the response to the server and receives a session ID.
let session_id = client
Expand Down

0 comments on commit bdb9b7e

Please sign in to comment.