Skip to content

Commit

Permalink
Style
Browse files Browse the repository at this point in the history
  • Loading branch information
skaunov committed Oct 27, 2023
1 parent ef93f16 commit daa7c04
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions rust-k256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub struct PlumeSignatureV1Fields<'a> {
pub hashed_to_curve_r: &'a ProjectivePoint,
}
impl PlumeSignature<'_> {
/// WARNING: panics when `self.c` isn't an `Output::<Sha256>`.
/// WARNING: panics when `self.c` isn't an `Output::<Sha256>`.
/// So catch it if it's a possible case for you.
// Verifier check in SNARK:
// g^[r + sk * c] / (g^sk)^c = g^r
Expand All @@ -117,6 +117,14 @@ impl PlumeSignature<'_> {
let hashed_to_curve = hash_to_curve(self.message, self.pk);
let hashed_to_curve_r = &hashed_to_curve * self.s - self.nullifier * &c_scalar;

let result = |components: Vec<&ProjectivePoint>| -> bool {
if &c_sha256_vec_signal(components) == c {
true
} else {
false
}
};

if let Some(PlumeSignatureV1Fields {
r_point: sig_r_point,
hashed_to_curve_r: sig_hashed_to_curve_r,
Expand All @@ -133,25 +141,18 @@ impl PlumeSignature<'_> {
}

// Check if the given hash matches
if &c_sha256_vec_signal(vec![
result(vec![
&ProjectivePoint::GENERATOR,
self.pk,
&hashed_to_curve,
self.nullifier,
&r_point,
&hashed_to_curve_r,
]) != c
{
return false;
}
])
} else {
// Check if the given hash matches
if &c_sha256_vec_signal(vec![self.nullifier, &r_point, &hashed_to_curve_r]) != c {
return false;
}
result(vec![self.nullifier, &r_point, &hashed_to_curve_r])
}

true
}
}

Expand Down

0 comments on commit daa7c04

Please sign in to comment.