Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
Include security_param into hasher's input
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Burundukov <[email protected]>
  • Loading branch information
Oleg Burundukov committed Mar 18, 2021
1 parent cdf1345 commit c2b5b43
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/algorithms/dlog_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::borrow::Borrow;
pub const DIGEST_BIT_LENGTH: u32 = HSha512Trunc256::DIGEST_BIT_LENGTH as u32;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DlogProof {
security_param: u32,
y: BigInt,
c: BigInt,
}
Expand All @@ -33,18 +32,14 @@ impl DlogProof {
let c = HSha512Trunc256::create_hash(&[&BigInt::from(security_param), N, g, V, &x]);

let y = r - c.borrow() * s;
Self {
security_param,
y,
c,
}
Self { y, c }
}

pub fn verify(&self, N: &BigInt, g: &BigInt, V: &BigInt, security_param: u32) -> bool {
let x = g.powm_sec(&self.y, N) * V.powm_sec(&self.c, N) % N;
let c = HSha512Trunc256::create_hash(&[&BigInt::from(security_param), N, g, V, &x]);

c == self.c && self.security_param == security_param
c == self.c
}
}

Expand Down Expand Up @@ -74,7 +69,6 @@ mod tests {
<= (max_secret_length + security_param + DIGEST_BIT_LENGTH) as usize
);
assert!(proof.c.bit_length() <= DIGEST_BIT_LENGTH as usize);
assert_eq!(proof.security_param, security_param);
}
#[test]
fn validate() {
Expand Down

0 comments on commit c2b5b43

Please sign in to comment.