Skip to content

Commit

Permalink
Check verification keys of the other signers
Browse files Browse the repository at this point in the history
  • Loading branch information
neacsu committed Nov 9, 2022
1 parent 51e407b commit 0452ab9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/nymcoconut/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ serde_derive = "1.0"
bs58 = "0.4.0"
sha2 = "0.9"

dkg = { path = "../crypto/dkg" }
pemstore = { path = "../pemstore" }

[dependencies.ff]
Expand All @@ -30,7 +31,6 @@ default-features = false
[dev-dependencies]
criterion = { version="0.3", features=["html_reports"] }
doc-comment = "0.3"
dkg = { path = "../crypto/dkg" }
rand_chacha = "0.3"

[dev-dependencies.bincode]
Expand Down
33 changes: 33 additions & 0 deletions common/nymcoconut/src/scheme/verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,39 @@ pub fn check_bilinear_pairing(p: &G1Affine, q: &G2Prepared, r: &G1Affine, s: &G2
multi_miller.final_exponentiation().is_identity().into()
}

pub fn check_vk_pairing(
params: &Parameters,
dkg_alpha: G2Projective,
dkg_beta: &[G2Projective],
vk: &VerificationKey,
) -> bool {
if dkg_beta.len() != vk.beta_g1.len() || dkg_beta.len() != vk.beta_g2.len() {
return false;
}
if vk.alpha != dkg_alpha {
return false;
}
if dkg_beta
.iter()
.zip(vk.beta_g2.iter())
.any(|(dkg_beta, vk_beta)| dkg_beta != vk_beta)
{
return false;
}
if vk.beta_g1.iter().zip(vk.beta_g2.iter()).any(|(g1, g2)| {
!check_bilinear_pairing(
&params.gen1(),
&G2Prepared::from(g2.to_affine()),
&g1.to_affine(),
params.prepared_miller_g2(),
)
}) {
return false;
}

true
}

pub fn verify_credential(
params: &Parameters,
verification_key: &VerificationKey,
Expand Down

0 comments on commit 0452ab9

Please sign in to comment.