Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure evidence and correctness proofs #129

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion synedrion/src/cggmp21/protocols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ pub(crate) mod aux_gen;
pub(crate) mod interactive_signing;
pub(crate) mod key_gen;
pub(crate) mod key_init;
pub(crate) mod key_init_errors;
pub(crate) mod key_init_malicious;
pub(crate) mod key_refresh;
pub(crate) mod presigning;
pub(crate) mod signing;
Expand All @@ -11,7 +13,8 @@ pub use interactive_signing::{
InteractiveSigningError, InteractiveSigningProof, InteractiveSigningResult,
};
pub use key_gen::{KeyGenError, KeyGenProof, KeyGenResult};
pub use key_init::{KeyInitError, KeyInitResult};
pub use key_init::KeyInitResult;
pub use key_init_errors::KeyInitError;
pub use key_refresh::KeyRefreshResult;
pub use presigning::{PresigningError, PresigningProof, PresigningResult};
pub use signing::{SigningProof, SigningResult};
41 changes: 20 additions & 21 deletions synedrion/src/cggmp21/protocols/aux_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,19 @@ use crate::paillier::{
SecretKeyPaillier, SecretKeyPaillierPrecomputed,
};
use crate::rounds::{
no_broadcast_messages, no_direct_messages, FinalizableToNextRound, FinalizableToResult,
FinalizeError, FirstRound, InitError, ProtocolResult, Round, ToNextRound, ToResult,
no_broadcast_messages, no_direct_messages, EvidenceRequiresMessages, FinalizableToNextRound,
FinalizableToResult, FinalizeError, FirstRound, InitError, PartyId, ProtocolResult, Round,
ToNextRound, ToResult,
};
use crate::tools::bitvec::BitVec;
use crate::tools::hashing::{Chain, FofHasher, HashOutput};
use crate::uint::UintLike;

/// Possible results of the AuxGen protocol.
#[derive(Debug, Clone, Copy)]
pub struct AuxGenResult<P: SchemeParams, I: Debug>(PhantomData<P>, PhantomData<I>);
pub struct AuxGenResult<P: SchemeParams, I: PartyId>(PhantomData<P>, PhantomData<I>);

impl<P: SchemeParams, I: Debug + Ord> ProtocolResult for AuxGenResult<P, I> {
impl<P: SchemeParams, I: PartyId> ProtocolResult<I> for AuxGenResult<P, I> {
type Success = AuxInfo<P, I>;
type ProvableError = AuxGenError;
type CorrectnessProof = ();
Expand All @@ -42,6 +43,8 @@ impl<P: SchemeParams, I: Debug + Ord> ProtocolResult for AuxGenResult<P, I> {
#[derive(Debug, Clone)]
pub struct AuxGenError(#[allow(dead_code)] AuxGenErrorEnum);

impl<I> EvidenceRequiresMessages<I> for AuxGenError {}

#[derive(Debug, Clone)]
enum AuxGenErrorEnum {
// TODO (#43): this can be removed when error verification is added
Expand Down Expand Up @@ -96,7 +99,7 @@ pub struct Round1<P: SchemeParams, I> {
context: Context<P, I>,
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> FirstRound<I> for Round1<P, I> {
impl<P: SchemeParams, I: PartyId> FirstRound<I> for Round1<P, I> {
type Inputs = ();
fn new(
rng: &mut impl CryptoRngCore,
Expand Down Expand Up @@ -176,7 +179,7 @@ pub struct Round1Payload {
cap_v: HashOutput,
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round1<P, I> {
impl<P: SchemeParams, I: PartyId> Round<I> for Round1<P, I> {
type Type = ToNextRound;
type Result = AuxGenResult<P, I>;
const ROUND_NUM: u8 = 1;
Expand Down Expand Up @@ -217,23 +220,21 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round1<P,
_from: &I,
broadcast_msg: Self::BroadcastMessage,
_direct_msg: Self::DirectMessage,
) -> Result<Self::Payload, <Self::Result as ProtocolResult>::ProvableError> {
) -> Result<Self::Payload, <Self::Result as ProtocolResult<I>>::ProvableError> {
Ok(Round1Payload {
cap_v: broadcast_msg.cap_v,
})
}
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> FinalizableToNextRound<I>
for Round1<P, I>
{
impl<P: SchemeParams, I: PartyId> FinalizableToNextRound<I> for Round1<P, I> {
type NextRound = Round2<P, I>;
fn finalize_to_next_round(
self,
_rng: &mut impl CryptoRngCore,
payloads: BTreeMap<I, <Self as Round<I>>::Payload>,
_artifacts: BTreeMap<I, <Self as Round<I>>::Artifact>,
) -> Result<Self::NextRound, FinalizeError<Self::Result>> {
) -> Result<Self::NextRound, FinalizeError<I, Self::Result>> {
Ok(Round2 {
context: self.context,
others_cap_v: payloads
Expand All @@ -260,7 +261,7 @@ pub struct Round2Payload<P: SchemeParams> {
data: PublicData1Precomp<P>,
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round2<P, I> {
impl<P: SchemeParams, I: PartyId> Round<I> for Round2<P, I> {
type Type = ToNextRound;
type Result = AuxGenResult<P, I>;
const ROUND_NUM: u8 = 2;
Expand Down Expand Up @@ -296,7 +297,7 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round2<P,
from: &I,
broadcast_msg: Self::BroadcastMessage,
_direct_msg: Self::DirectMessage,
) -> Result<Self::Payload, <Self::Result as ProtocolResult>::ProvableError> {
) -> Result<Self::Payload, <Self::Result as ProtocolResult<I>>::ProvableError> {
if &broadcast_msg.data.hash(&self.context.sid_hash, from)
!= self.others_cap_v.get(from).unwrap()
{
Expand Down Expand Up @@ -330,16 +331,14 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round2<P,
}
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> FinalizableToNextRound<I>
for Round2<P, I>
{
impl<P: SchemeParams, I: PartyId> FinalizableToNextRound<I> for Round2<P, I> {
type NextRound = Round3<P, I>;
fn finalize_to_next_round(
self,
rng: &mut impl CryptoRngCore,
payloads: BTreeMap<I, <Self as Round<I>>::Payload>,
_artifacts: BTreeMap<I, <Self as Round<I>>::Artifact>,
) -> Result<Self::NextRound, FinalizeError<Self::Result>> {
) -> Result<Self::NextRound, FinalizeError<I, Self::Result>> {
let others_data = payloads
.into_iter()
.map(|(id, payload)| (id, payload.data))
Expand Down Expand Up @@ -411,7 +410,7 @@ pub struct Round3Message<P: SchemeParams> {
data2: PublicData2<P>,
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round3<P, I> {
impl<P: SchemeParams, I: PartyId> Round<I> for Round3<P, I> {
type Type = ToResult;
type Result = AuxGenResult<P, I>;
const ROUND_NUM: u8 = 3;
Expand Down Expand Up @@ -461,7 +460,7 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round3<P,
from: &I,
_broadcast_msg: Self::BroadcastMessage,
direct_msg: Self::DirectMessage,
) -> Result<Self::Payload, <Self::Result as ProtocolResult>::ProvableError> {
) -> Result<Self::Payload, <Self::Result as ProtocolResult<I>>::ProvableError> {
let sender_data = &self.others_data.get(from).unwrap();

let aux = (&self.context.sid_hash, &from, &self.rho);
Expand Down Expand Up @@ -500,13 +499,13 @@ impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> Round<I> for Round3<P,
}
}

impl<P: SchemeParams, I: Debug + Clone + Ord + Serialize> FinalizableToResult<I> for Round3<P, I> {
impl<P: SchemeParams, I: PartyId> FinalizableToResult<I> for Round3<P, I> {
fn finalize_to_result(
self,
_rng: &mut impl CryptoRngCore,
_payloads: BTreeMap<I, <Self as Round<I>>::Payload>,
_artifacts: BTreeMap<I, <Self as Round<I>>::Artifact>,
) -> Result<<Self::Result as ProtocolResult>::Success, FinalizeError<Self::Result>> {
) -> Result<<Self::Result as ProtocolResult<I>>::Success, FinalizeError<I, Self::Result>> {
let my_id = self.my_id().clone();
let mut all_data = self.others_data;
all_data.insert(my_id.clone(), self.context.data_precomp);
Expand Down
Loading
Loading