Skip to content

Commit eff31ae

Browse files
committed
fix tests
Signed-off-by: lovesh <lovesh.bond@gmail.com>
1 parent d3409b7 commit eff31ae

File tree

3 files changed

+24
-27
lines changed

3 files changed

+24
-27
lines changed

benches/benches/syra.rs

+4-23
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use syra::{
2323
},
2424
threshold_issuance::{Phase1, Phase1Output, Phase2, UserSecretKeyShare},
2525
};
26+
use test_utils::statistics::statistics;
2627

2728
const BASE_OT_KEY_SIZE: u16 = 128;
2829
const KAPPA: u16 = 256;
@@ -403,26 +404,6 @@ fn pseudonym(c: &mut Criterion) {
403404
// criterion_group!(benches, threshold_issuance_with_known_user_id, pseudonym);
404405
// criterion_main!(benches);
405406

406-
fn timing_info(mut times: Vec<std::time::Duration>) -> String {
407-
times.sort();
408-
let median = {
409-
let mid = times.len() / 2;
410-
if times.len() % 2 == 0 {
411-
(times[mid - 1] + times[mid]) / 2
412-
} else {
413-
times[mid]
414-
}
415-
};
416-
let total = times.iter().sum::<std::time::Duration>();
417-
format!(
418-
"{:.2?} | [{:.2?}, {:.2?}, {:.2?}]",
419-
total,
420-
times[0],
421-
median,
422-
times[times.len() - 1]
423-
)
424-
}
425-
426407
fn main() {
427408
use std::time::Instant;
428409
let mut rng = StdRng::seed_from_u64(0u64);
@@ -518,8 +499,8 @@ fn main() {
518499
usk.verify(user_id, &threshold_ipk, prepared_params.clone())
519500
.unwrap();
520501
}
521-
println!("Phase1 time: {:?}", timing_info(phase1_time));
522-
println!("Phase2 time: {:?}", timing_info(phase2_time));
523-
println!("Aggregation time: {:?}", timing_info(aggr_time));
502+
println!("Phase1 time: {:?}", statistics(phase1_time));
503+
println!("Phase2 time: {:?}", statistics(phase2_time));
504+
println!("Aggregation time: {:?}", statistics(aggr_time));
524505
}
525506
}

equality_across_groups/src/eq_across_groups.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! `ABORT_PARAM` -> `b_f`
1111
//! `NUM_REPS` -> `tau`
1212
//!
13-
//! `RESPONSE_BYTE_SIZE` is the number of bytes need to represent `2^{WITNESS_BIT_SIZE + CHALLENGE_BIT_SIZE + ABORT_PARAM} - 1`
13+
//! `RESPONSE_BYTE_SIZE` is the number of bytes need to represent `z` which lies in `[2^{WITNESS_BIT_SIZE + CHALLENGE_BIT_SIZE}, 2^{WITNESS_BIT_SIZE + CHALLENGE_BIT_SIZE + ABORT_PARAM} - 1]`
1414
//!
1515
//! The groups are assumed to be elliptic curve groups.
1616

equality_across_groups/src/pok_ecdsa_pubkey.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
//! Proof of knowledge of ECDSA public key on short Weierstrass curve. Is a slight variation of the protocol described in section 6 of the paper [ZKAttest Ring and Group Signatures for Existing ECDSA Keys](https://eprint.iacr.org/2021/1183)
1+
//! Proof of knowledge of ECDSA public key committed on a short Weierstrass curve. Is a slight variation of the protocol described in section 6 of the paper [ZKAttest Ring and Group Signatures for Existing ECDSA Keys](https://eprint.iacr.org/2021/1183)
2+
//!
3+
//! To prove the knowledge of the public key, an ECDSA signature on the verifier's chosen message is generated
4+
//! which should be verifiable using the public key but the signature can't be transmitted entirely as the public key
5+
//! can be learnt from the signature.
26
//!
37
//! An ECDSA signature `(r, s)` is transformed to `(R, z=s/r)` as per the paper. The new ECDSA verification equation
48
//! becomes `z*R - g*t*r^-1 = q` where `q` is the public key, `g` is the generator and `t` is the hashed message.
59
//! This is equivalent to `-g*t*r^-1 = q + z*(-R)`
610
//!
711
//! The verifier gets a commitment to the public key `q` and `-z*R` but knows `R, t, g and r` (`r` is the truncated x coordinate of `R`).
12+
//! Note that the verifier should not learn `z` or `s` otherwise it will learn the public key.
813
//!
914
//! Thus using the protocols for scalar multiplication and point addition, the prover proves:
1015
//! - Given commitments to `z` and `-z*R`, the scalar multiplication of `z` and `-R` is indeed `-z*R`
@@ -189,7 +194,6 @@ mod tests {
189194
use super::*;
190195
use crate::{
191196
ec::commitments::from_base_field_to_scalar_field, eq_across_groups::ProofLargeWitness,
192-
util::timing_info,
193197
};
194198
use ark_bls12_381::{Fr as BlsFr, G1Affine as BlsG1Affine};
195199
use ark_secp256r1::Fq;
@@ -201,7 +205,7 @@ mod tests {
201205
use bulletproofs_plus_plus::prelude::SetupParams as BppSetupParams;
202206
use dock_crypto_utils::transcript::new_merlin_transcript;
203207
use rand_core::OsRng;
204-
use std::time::{Duration, Instant};
208+
use std::time::Instant;
205209
use test_utils::statistics::statistics;
206210

207211
#[test]
@@ -245,6 +249,8 @@ mod tests {
245249
let mut prover_transcript = new_merlin_transcript(b"test");
246250
prover_transcript.append(b"comm_key_secp", &comm_key_secp);
247251
prover_transcript.append(b"comm_key_tom", &comm_key_tom);
252+
prover_transcript.append(b"comm_pk", &comm_pk.comm);
253+
prover_transcript.append(b"message", &message);
248254
let proof = ProofOfKnowledgeEcdsaPublicKey::<128>::new(
249255
&mut rng,
250256
transformed_sig,
@@ -264,6 +270,8 @@ mod tests {
264270
let mut verifier_transcript = new_merlin_transcript(b"test");
265271
verifier_transcript.append(b"comm_key_secp", &comm_key_secp);
266272
verifier_transcript.append(b"comm_key_tom", &comm_key_tom);
273+
verifier_transcript.append(b"comm_pk", &comm_pk.comm);
274+
verifier_transcript.append(b"message", &message);
267275
proof
268276
.verify(
269277
message,
@@ -350,6 +358,10 @@ mod tests {
350358
prover_transcript.append(b"comm_key_tom", &comm_key_tom);
351359
prover_transcript.append(b"comm_key_bls", &comm_key_bls);
352360
prover_transcript.append(b"bpp_setup_params", &bpp_setup_params);
361+
prover_transcript.append(b"comm_pk", &comm_pk.comm);
362+
prover_transcript.append(b"bls_comm_pk_x", &bls_comm_pk_x);
363+
prover_transcript.append(b"bls_comm_pk_y", &bls_comm_pk_y);
364+
prover_transcript.append(b"message", &message);
353365
let pok_pubkey = ProofOfKnowledgeEcdsaPublicKey::<128>::new(
354366
&mut rng,
355367
transformed_sig,
@@ -415,6 +427,10 @@ mod tests {
415427
verifier_transcript.append(b"comm_key_tom", &comm_key_tom);
416428
verifier_transcript.append(b"comm_key_bls", &comm_key_bls);
417429
verifier_transcript.append(b"bpp_setup_params", &bpp_setup_params);
430+
verifier_transcript.append(b"comm_pk", &comm_pk.comm);
431+
verifier_transcript.append(b"bls_comm_pk_x", &bls_comm_pk_x);
432+
verifier_transcript.append(b"bls_comm_pk_y", &bls_comm_pk_y);
433+
verifier_transcript.append(b"message", &message);
418434
pok_pubkey
419435
.verify(
420436
message,

0 commit comments

Comments
 (0)