MCPcopy Create free account
hub / github.com/docknetwork/crypto / check

Function check

kvac/src/bbs_sharp/proof.rs:848–1035  ·  view source on GitHub ↗
(message_count: u32, num_tokens: usize, nonces: Option<Vec<&[u8]>>)

Source from the content-addressed store, hash-verified

846 let num_tokens = 10;
847
848 fn check(message_count: u32, num_tokens: usize, nonces: Option<Vec<&[u8]>>) {
849 let mut rng = StdRng::seed_from_u64(0u64);
850 let messages = (0..message_count)
851 .map(|_| Fr::rand(&mut rng))
852 .collect::<Vec<_>>();
853 let params = MACParams::<Affine>::new::<Sha256>(b"test", message_count);
854 let signer_sk = SecretKey::new(&mut rng);
855 let signer_pk = SignerPublicKey::new_from_params(&signer_sk, &params);
856
857 let user_sk = SecretKey::new(&mut rng);
858 let user_pk = UserPublicKey::new_from_params(&user_sk, &params);
859
860 let mac = MAC::new(&mut rng, &messages, &user_pk, &signer_sk, &params).unwrap();
861 let proof = ProofOfValidityOfMAC::new::<_, Sha256>(
862 &mut rng, &mac, &signer_sk, &signer_pk, &params, None,
863 );
864
865 mac.verify(&messages, &user_pk, &signer_sk, &params)
866 .unwrap();
867 proof
868 .verify::<Sha256>(&mac, &messages, &user_pk, &signer_pk, params.clone())
869 .unwrap();
870
871 // User generates several requests of keyed-proofs and sends them to the signer and gets their proof of validity.
872 // These will be used later to create proof of knowledge of MAC
873 let mut signer_time = Duration::default();
874 let mut user_time = Duration::default();
875
876 // User proves knowledge of secret key to signer using a Schnorr signature (called pi_U in paper)
877 let signer_challenge = b"signer's challenge";
878 let start = Instant::now();
879 let schnorr_signature = SchnorrSignature::new::<_, Sha256>(
880 &mut rng,
881 signer_challenge,
882 &user_sk.0,
883 &params.g,
884 );
885 user_time += start.elapsed();
886
887 let start = Instant::now();
888 assert!(schnorr_signature.verify::<Sha256>(signer_challenge, &user_pk.0, &params.g));
889 signer_time += start.elapsed();
890
891 let start = Instant::now();
892 let mut user_protocol =
893 HOLUserProtocol::init(&mut rng, num_tokens, &mac, &messages, &user_pk, &params)
894 .unwrap();
895 user_time += start.elapsed();
896
897 let start = Instant::now();
898 let (signer_protocol, pre_challenge) =
899 HOLSignerProtocol::init(&mut rng, num_tokens, &mac.A, &params);
900 signer_time += start.elapsed();
901
902 let start = Instant::now();
903 let blinded_challenges =
904 user_protocol.compute_challenge::<Sha256>(pre_challenge, &params, nonces.clone());
905 user_time += start.elapsed();

Calls 10

randFunction · 0.85
mapMethod · 0.80
cloneMethod · 0.80
compute_responseMethod · 0.80
process_responseMethod · 0.80
transform_schnorr_sigMethod · 0.80
verifyMethod · 0.45
iterMethod · 0.45
gen_proofMethod · 0.45