Skip to content

Commit

Permalink
Remove *Box mutation hack
Browse files Browse the repository at this point in the history
  • Loading branch information
fjarri committed Oct 7, 2022
1 parent 6bd3d92 commit 3bbcfdf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/gg20/sign/malicious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub fn delta_inverse_r4(
faulter_bcast: &mut BytesVec,
faulter_p2ps: &mut HoleVecMap<SignShareId, BytesVec>,
) {
let faulter_bcast_deserialized = match deserialize::<r4::Bcast>(
let mut faulter_bcast_deserialized = match deserialize::<r4::Bcast>(
&decode_message::<SignShareId>(faulter_bcast)
.unwrap()
.payload,
Expand All @@ -148,21 +148,21 @@ pub fn delta_inverse_r4(
}
DeltaInvFaultType::beta_ij { victim } => {
let p2p = faulter_p2ps_deserialized.get_mut(*victim).unwrap();
*Box::new(p2p.mta_plaintext.beta_secret.beta).as_mut() -= delta_i_change;
p2p.mta_plaintext.beta_secret.beta -= delta_i_change;
}
DeltaInvFaultType::k_i => {
*Box::new(faulter_bcast_deserialized.1.k_i).as_mut() -=
faulter_bcast_deserialized.1.k_i -=
delta_i_change * faulter_bcast_deserialized.1.gamma_i.invert().unwrap();
}
DeltaInvFaultType::gamma_i => {
*Box::new(faulter_bcast_deserialized.1.gamma_i).as_mut() -=
faulter_bcast_deserialized.1.gamma_i -=
delta_i_change * faulter_bcast_deserialized.1.k_i.invert().unwrap();
}
DeltaInvFaultType::Gamma_i_gamma_i => {
*Box::new(faulter_bcast_deserialized.1.gamma_i).as_mut() -=
faulter_bcast_deserialized.1.gamma_i -=
delta_i_change * faulter_bcast_deserialized.1.k_i.invert().unwrap();
*Box::new(&faulter_bcast_deserialized.0.Gamma_i).as_mut() =
&(ProjectivePoint::GENERATOR * faulter_bcast_deserialized.1.gamma_i)
faulter_bcast_deserialized.0.Gamma_i =
ProjectivePoint::GENERATOR * faulter_bcast_deserialized.1.gamma_i;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/gg20/sign/r6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,11 @@ mod malicious {
recipient: TypedUsize<SignShareId>,
beta_secret: Secret,
) -> Secret {
let mut beta_secret = beta_secret;
if let R3BadBeta { victim } = self.behaviour {
if victim == recipient {
log_confess_info(my_sign_id, &self.behaviour, "step 2/2: beta_secret");
*Box::new(beta_secret.beta).as_mut() += k256::Scalar::ONE;
beta_secret.beta += k256::Scalar::ONE;
}
}
beta_secret
Expand Down

0 comments on commit 3bbcfdf

Please sign in to comment.