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

Function signing

bbs_plus/src/threshold/threshold_bbs.rs:218–428  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

216
217 #[test]
218 fn signing() {
219 let mut rng = StdRng::seed_from_u64(0u64);
220 const BASE_OT_KEY_SIZE: u16 = 128;
221 const KAPPA: u16 = 256;
222 const STATISTICAL_SECURITY_PARAMETER: u16 = 80;
223 let ote_params = MultiplicationOTEParams::<KAPPA, STATISTICAL_SECURITY_PARAMETER> {};
224 let gadget_vector = GadgetVector::<Fr, KAPPA, STATISTICAL_SECURITY_PARAMETER>::new::<
225 Blake2b512,
226 >(ote_params, b"test-gadget-vector");
227
228 let protocol_id = b"test".to_vec();
229
230 let sig_batch_size = 3;
231 let threshold_signers = 5;
232 let total_signers = 8;
233 let all_party_set = (1..=total_signers).into_iter().collect::<BTreeSet<_>>();
234 let threshold_party_set = (1..=threshold_signers).into_iter().collect::<BTreeSet<_>>();
235
236 // The signers do a keygen. This is a one time setup.
237 let (sk, sk_shares) =
238 trusted_party_keygen::<_, Fr>(&mut rng, threshold_signers, total_signers);
239
240 // The signers run OT protocol instances. This is also a one time setup.
241 let base_ot_outputs = do_pairwise_base_ot::<BASE_OT_KEY_SIZE>(
242 &mut rng,
243 ote_params.num_base_ot(),
244 total_signers,
245 all_party_set.clone(),
246 );
247
248 let message_count = 5;
249 let params = SignatureParams23G1::<Bls12_381>::generate_using_rng(&mut rng, message_count);
250 let public_key =
251 PublicKeyG2::generate_using_secret_key_and_bbs23_params(&SecretKey(sk), &params);
252
253 println!(
254 "For a batch size of {} BBS signatures and {} signers",
255 sig_batch_size, threshold_signers
256 );
257
258 // Following have to happen for each new batch of signatures. Batch size can be 1 when creating one signature at a time
259
260 let mut round1s = vec![];
261 let mut commitments = vec![];
262 let mut commitments_zero_share = vec![];
263 let mut round1outs = vec![];
264
265 // Signers initiate round-1 and each signer sends commitments to others
266 let start = Instant::now();
267 for i in 1..=threshold_signers {
268 let mut others = threshold_party_set.clone();
269 others.remove(&i);
270 let (round1, comm, comm_zero) = Phase1::<Fr, 256>::init_for_bbs::<_, Blake2b512>(
271 &mut rng,
272 sig_batch_size,
273 i,
274 others,
275 protocol_id.clone(),

Callers

nothing calls this directly

Calls 14

randFunction · 0.85
num_base_otMethod · 0.80
cloneMethod · 0.80
getMethod · 0.80
mapMethod · 0.80
SecretKeyClass · 0.50
into_iterMethod · 0.45
removeMethod · 0.45
receive_commitmentMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected