Skip to content

Commit c048a29

Browse files
committed
Rename Complaint to RecoveryProof; move accuser_id to wire types
1 parent 487ebd7 commit c048a29

3 files changed

Lines changed: 50 additions & 36 deletions

File tree

fastcrypto-tbls/src/threshold_schnorr/avss.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::nodes::{Nodes, PartyId};
1414
use crate::polynomial::{Eval, Poly};
1515
use crate::random_oracle::RandomOracle;
1616
use crate::threshold_schnorr::bcs::BCSSerialized;
17-
use crate::threshold_schnorr::complaint::{Complaint, ComplaintResponse};
17+
use crate::threshold_schnorr::complaint::{ComplaintResponse, RecoveryProof};
1818
use crate::threshold_schnorr::Extensions::Encryption;
1919
use crate::threshold_schnorr::{random_oracle_from_sid, EG, G, S};
2020
use crate::types;
@@ -63,6 +63,14 @@ pub enum ProcessedMessage {
6363
Complaint(Complaint),
6464
}
6565

66+
/// A complaint by a receiver who could not decrypt or verify its shares from the dealer's
67+
/// broadcast. Given enough responses, the accuser can recover its shares.
68+
#[derive(Clone, Debug, Serialize, Deserialize)]
69+
pub struct Complaint {
70+
pub accuser_id: PartyId,
71+
pub proof: RecoveryProof,
72+
}
73+
6674
/// The output of a receiver after a single instance of AVSS: The shares for each nonce + commitments for the next round.
6775
#[derive(Debug, Clone, Serialize, Deserialize)]
6876
pub struct PartialOutput {
@@ -284,13 +292,16 @@ impl Receiver {
284292
my_shares,
285293
feldman_commitment: message.feldman_commitment.clone(),
286294
})),
287-
Err(_) => Ok(ProcessedMessage::Complaint(Complaint::create(
288-
self.id,
289-
&message.ciphertext.shared(),
290-
&self.enc_secret_key,
291-
&self.random_oracle(),
292-
&mut rand::thread_rng(),
293-
))),
295+
Err(_) => Ok(ProcessedMessage::Complaint(Complaint {
296+
accuser_id: self.id,
297+
proof: RecoveryProof::create(
298+
self.id,
299+
&message.ciphertext.shared(),
300+
&self.enc_secret_key,
301+
&self.random_oracle(),
302+
&mut rand::thread_rng(),
303+
),
304+
})),
294305
}
295306
}
296307

@@ -301,7 +312,8 @@ impl Receiver {
301312
complaint: &Complaint,
302313
my_output: &PartialOutput,
303314
) -> FastCryptoResult<ComplaintResponse<SharesForNode>> {
304-
complaint.check(
315+
complaint.proof.check(
316+
complaint.accuser_id,
305317
&self.nodes.node_id_to_node(complaint.accuser_id)?.pk,
306318
&message.ciphertext.encs[complaint.accuser_id as usize],
307319
&message.ciphertext.shared(),
@@ -550,11 +562,11 @@ mod tests {
550562
use crate::ecies_v1::{MultiRecipientEncryption, PublicKey};
551563
use crate::nodes::{Node, Nodes, PartyId};
552564
use crate::polynomial::Poly;
565+
use crate::threshold_schnorr::avss::Complaint;
553566
use crate::threshold_schnorr::avss::{Dealer, Message, Receiver};
554567
use crate::threshold_schnorr::avss::{PartialOutput, ProcessedMessage};
555568
use crate::threshold_schnorr::avss::{ReceiverOutput, SharesForNode};
556569
use crate::threshold_schnorr::bcs::BCSSerialized;
557-
use crate::threshold_schnorr::complaint::Complaint;
558570
use crate::threshold_schnorr::tests::restrict;
559571
use crate::threshold_schnorr::Extensions::Encryption;
560572
use crate::threshold_schnorr::{EG, G, S};

fastcrypto-tbls/src/threshold_schnorr/batch_avss.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ pub struct Vote {
209209
/// A complaint by a receiver who could not decrypt or verify its shares.
210210
#[derive(Clone, Debug, Serialize, Deserialize)]
211211
pub struct RevealComplaint {
212-
pub proof: complaint::Complaint,
212+
pub accuser_id: PartyId,
213+
pub proof: complaint::RecoveryProof,
213214
pub ciphertext: Vec<u8>,
214215
pub common_message_hash: Digest,
215216
}
@@ -656,7 +657,8 @@ impl Receiver {
656657
})
657658
.or_else(|_| {
658659
Ok(DecryptionOutcome::Invalid(RevealComplaint {
659-
proof: complaint::Complaint::create(
660+
accuser_id: self.id,
661+
proof: complaint::RecoveryProof::create(
660662
self.id,
661663
shared,
662664
&self.enc_secret_key,
@@ -684,6 +686,7 @@ impl Receiver {
684686
compute_challenge_from_common_message(&self.random_oracle(), common_message);
685687

686688
let RevealComplaint {
689+
accuser_id,
687690
proof,
688691
ciphertext: reveal_ciphertext,
689692
common_message_hash,
@@ -692,11 +695,12 @@ impl Receiver {
692695
if *common_message_hash != common_message.hash() {
693696
return Err(InvalidProof);
694697
}
695-
let recipient_root = common_message.recipient_root(proof.accuser_id)?;
698+
let recipient_root = common_message.recipient_root(*accuser_id)?;
696699
self.check_avid_consistency(reveal_ciphertext, recipient_root)
697700
.map_err(|_| InvalidProof)?;
698-
let accuser = self.nodes.node_id_to_node(proof.accuser_id)?;
701+
let accuser = self.nodes.node_id_to_node(*accuser_id)?;
699702
proof.check(
703+
*accuser_id,
700704
&accuser.pk,
701705
reveal_ciphertext,
702706
&common_message.ciphertext_shared,

fastcrypto-tbls/src/threshold_schnorr/complaint.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ use fastcrypto::traits::AllowedRng;
1414
use serde::{Deserialize, Serialize};
1515
use tracing::debug;
1616

17-
/// A complaint by an accuser that it could not decrypt or verify its shares.
18-
/// Given enough responses to the complaint, the accuser can recover its shares.
17+
/// Cryptographic proof attached to a complaint: an ECIES recovery package that opens the
18+
/// dealer's shared ciphertext with the accuser's private key and produces shares that fail a
19+
/// supplied verifier.
1920
#[derive(Clone, Debug, Serialize, Deserialize)]
20-
pub struct Complaint {
21-
pub(crate) accuser_id: PartyId,
22-
pub(crate) proof: RecoveryPackage<EG>,
23-
}
21+
pub struct RecoveryProof(RecoveryPackage<EG>);
2422

25-
impl Complaint {
26-
/// Try to decrypt the shares for the accuser.
23+
impl RecoveryProof {
24+
/// Verify the proof for the given `accuser_id`: decrypt `ciphertext` via the recovery
25+
/// package and confirm the resulting shares fail `verifier`. The caller supplies
26+
/// `accuser_id` from their protocol context — it is *not* carried inside the proof.
2727
pub fn check<S: BCSSerialized>(
2828
&self,
29+
accuser_id: PartyId,
2930
enc_pk: &ecies_v1::PublicKey<EG>,
3031
ciphertext: &[u8],
3132
shared: &SharedComponents<EG>,
@@ -35,31 +36,31 @@ impl Complaint {
3536
// Check that the recovery package is valid, and if not, return an error since the complaint is invalid.
3637
let buffer = shared.decrypt_with_recovery_package(
3738
ciphertext,
38-
&self.proof,
39-
&random_oracle.extend(&Recovery(self.accuser_id).to_string()),
39+
&self.0,
40+
&random_oracle.extend(&Recovery(accuser_id).to_string()),
4041
&random_oracle.extend(&Encryption.to_string()),
4142
enc_pk,
42-
self.accuser_id as usize,
43+
accuser_id as usize,
4344
)?;
4445

4546
let Ok(shares) = S::from_bytes(&buffer) else {
4647
debug!(
4748
"Complaint by party {} is valid: Failed to deserialize shares",
48-
self.accuser_id
49+
accuser_id
4950
);
5051
return Ok(());
5152
};
5253

5354
if verifier(&shares).is_ok() {
5455
debug!(
5556
"Complaint by party {} is invalid: Shares verify correctly",
56-
self.accuser_id
57+
accuser_id
5758
);
5859
Err(InvalidProof)
5960
} else {
6061
debug!(
6162
"Complaint by party {} is valid: Shares do not verify correctly",
62-
self.accuser_id
63+
accuser_id
6364
);
6465
Ok(())
6566
}
@@ -72,14 +73,11 @@ impl Complaint {
7273
random_oracle: &RandomOracle,
7374
rng: &mut impl AllowedRng,
7475
) -> Self {
75-
Self {
76-
accuser_id,
77-
proof: ciphertext.create_recovery_package(
78-
enc_sk,
79-
&random_oracle.extend(&Recovery(accuser_id).to_string()),
80-
rng,
81-
),
82-
}
76+
Self(ciphertext.create_recovery_package(
77+
enc_sk,
78+
&random_oracle.extend(&Recovery(accuser_id).to_string()),
79+
rng,
80+
))
8381
}
8482
}
8583

0 commit comments

Comments
 (0)