Skip to content

Commit 692755d

Browse files
lanternolovesh
authored andcommitted
feat: Update threshold signature protocol to use explicit hash functions
This update aligns with API changes in the underlying crypto library (version 0.25) that now requires explicit specification of hash functions for improved type safety and flexibility.
1 parent 8147946 commit 692755d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/threshold_sig/base_ot.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use oblivious_transfer_protocols::{
1616
use secret_sharing_and_dkg::common::PublicKeyBase;
1717
use wasm_bindgen::prelude::*;
1818
use zeroize::Zeroize;
19+
use sha3::Shake256;
1920

2021
fn parse_pk_base(pk_base: Uint8Array) -> Result<G1Affine, JsValue> {
2122
let pk_base = obj_from_uint8array!(PublicKeyBase<G1Affine>, pk_base, false);
@@ -68,7 +69,7 @@ pub fn base_ot_phase_process_sender_pubkey(
6869
let mut base_ot = obj_from_uint8array!(Participant<G1Affine>, base_ot_phase, true);
6970
let pub_key_proof = obj_from_uint8array!(SenderPubKeyAndProof<G1Affine>, pub_key_proof, false);
7071
let recv_pk = base_ot
71-
.receive_sender_pubkey::<_, Blake2b512, BASE_OT_KEY_SIZE>(
72+
.receive_sender_pubkey::<_, Blake2b512, Shake256, BASE_OT_KEY_SIZE>(
7273
&mut rng,
7374
sender_id,
7475
pub_key_proof,
@@ -98,7 +99,7 @@ pub fn base_ot_phase_process_receiver_pubkey(
9899
let mut base_ot = obj_from_uint8array!(Participant<G1Affine>, base_ot_phase, true);
99100
let pk = obj_from_uint8array!(ReceiverPubKeys<G1Affine>, public_key, false);
100101
let challenges = base_ot
101-
.receive_receiver_pubkey::<BASE_OT_KEY_SIZE>(receiver_id, pk)
102+
.receive_receiver_pubkey::<Blake2b512, Shake256, BASE_OT_KEY_SIZE>(receiver_id, pk)
102103
.map_err(|e| {
103104
JsValue::from(&format!(
104105
"Processing Base OT sender's public key returned error: {:?}",
@@ -123,7 +124,7 @@ pub fn base_ot_phase_process_receiver_challenges(
123124
let mut base_ot = obj_from_uint8array!(Participant<G1Affine>, base_ot_phase, true);
124125
let challenges = obj_from_uint8array!(Challenges, challenges, false);
125126
let resp = base_ot
126-
.receive_challenges(sender_id, challenges)
127+
.receive_challenges::<Blake2b512>(sender_id, challenges)
127128
.map_err(|e| {
128129
JsValue::from(&format!(
129130
"Processing Base OT sender's challenges returned error: {:?}",
@@ -172,7 +173,7 @@ pub fn base_ot_phase_process_hashed_keys(
172173
set_panic_hook();
173174
let mut base_ot = obj_from_uint8array!(Participant<G1Affine>, base_ot_phase, true);
174175
let hk = obj_from_uint8array!(Vec<(HashedKey, HashedKey)>, hashed_keys, false);
175-
base_ot.receive_hashed_keys(sender_id, hk).map_err(|e| {
176+
base_ot.receive_hashed_keys::<Blake2b512>(sender_id, hk).map_err(|e| {
176177
JsValue::from(&format!(
177178
"Processing Base OT receiver's responses returned error: {:?}",
178179
e

src/threshold_sig/signing.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ use crate::{
88
},
99
Fr,
1010
};
11+
use blake2::Blake2b512;
12+
use sha3::Shake256;
1113
use ark_bls12_381::Bls12_381;
1214
use bbs_plus::threshold::{
1315
multiplication_phase::{Phase2, Phase2Output},
1416
randomness_generation_phase::Phase1,
1517
threshold_bbs::{BBSSignatureShare, Phase1Output as BbsPhase1Output},
1618
threshold_bbs_plus::{BBSPlusSignatureShare, Phase1Output as BbsPlusPhase1Output},
1719
};
18-
use blake2::Blake2b512;
1920
use js_sys::{Array, Map, Set, Uint8Array};
2021
use oblivious_transfer_protocols::{
2122
cointoss::Commitments,
@@ -35,7 +36,7 @@ macro_rules! start_phase1 {
3536
set_panic_hook();
3637
let mut rng = get_seeded_rng();
3738
let others = js_set_to_btree_set(&$others);
38-
let (phase1, comm, comm_zero) = Phase1::<Fr, SALT_SIZE>::$fn_name(
39+
let (phase1, comm, comm_zero) = Phase1::<Fr, SALT_SIZE>::$fn_name::<_, Blake2b512>(
3940
&mut rng,
4041
$sig_batch_size,
4142
$participant_id,
@@ -81,7 +82,7 @@ macro_rules! start_phase2 {
8182
let gadget_vector = obj_from_uint8array!(GadgetVector<Fr, KAPPA, STATISTICAL_SECURITY_PARAMETER>, $gadget_vector, false, "GadgetVector");
8283
let ote_params = MultiplicationOTEParams::<KAPPA, STATISTICAL_SECURITY_PARAMETER> {};
8384

84-
let (phase2, msgs) = Phase2::init(
85+
let (phase2, msgs) = Phase2::init::<_, Shake256>(
8586
&mut rng,
8687
$participant_id,
8788
phase1_output.masked_signing_key_shares,
@@ -488,7 +489,7 @@ fn process_shares(
488489
let shares = obj_from_uint8array!(Vec<(Fr, [u8; SALT_SIZE])>, shares, false);
489490
let zero_shares = obj_from_uint8array!(Vec<(Fr, [u8; SALT_SIZE])>, zero_shares, false);
490491
phase1
491-
.receive_shares(sender_id, shares, zero_shares)
492+
.receive_shares::<Blake2b512>(sender_id, shares, zero_shares)
492493
.map_err(|e| {
493494
JsValue::from(&format!(
494495
"Processing shares in Phase1 returned error: {:?}",
@@ -511,7 +512,7 @@ fn receive_message_1(
511512
let message = obj_from_uint8array!(Message1<Fr>, message, false, "Phase2 Message1");
512513
let gadget_vector = obj_from_uint8array!(GadgetVector<Fr, KAPPA, STATISTICAL_SECURITY_PARAMETER>, gadget_vector, false);
513514
let m2 = phase2
514-
.receive_message1::<Blake2b512>(sender_id, message, &gadget_vector)
515+
.receive_message1::<Blake2b512, Shake256>(sender_id, message, &gadget_vector)
515516
.map_err(|e| {
516517
JsValue::from(&format!(
517518
"Receiving Message1 in Phase2 returned error: {:?}",

0 commit comments

Comments
 (0)