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

Update Synedrion usage to v0.0.12 #535

Merged
merged 2 commits into from
Nov 28, 2023
Merged
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
50 changes: 12 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crypto/kvdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ zeroize ={ version="1.4", features=["zeroize_derive"], default-features=
rpassword ={ version="5.0", default-features=false }
scrypt ={ version="0.11.0", default-features=false, features=["std"] }
chacha20poly1305={ version="0.9", features=["alloc"], default-features=false }
synedrion ={ git="ssh://[email protected]/entropyxyz/synedrion.git", branch="fix-32bit" }
synedrion ={ git="ssh://[email protected]/entropyxyz/synedrion.git", tag="release/v0.0.12" }

# Async
tokio ={ version="1.16", features=["macros", "sync", "fs", "rt-multi-thread", "io-util"] }
Expand Down
2 changes: 1 addition & 1 deletion crypto/protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition ='2021'
[dependencies]
async-trait="0.1.73"
entropy-shared={ path="../shared", default-features=false }
synedrion={ git="ssh://[email protected]/entropyxyz/synedrion.git", branch="fix-32bit" }
synedrion={ git="ssh://[email protected]/entropyxyz/synedrion.git", tag="release/v0.0.12" }
serde={ version="1.0", features=["derive"], default-features=false }
subxt={ package="subxt", git="https://github.com/paritytech/subxt.git", tag="v0.32.1", default-features=false }
sp-core={ version="21.0.0", default-features=false, features=["full_crypto", "serde"] }
Expand Down
76 changes: 72 additions & 4 deletions crypto/protocol/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,84 @@
use synedrion::{
sessions, InteractiveSigningResult, KeyRefreshResult, KeygenAndAuxResult, ProtocolResult,
};
use thiserror::Error;

use crate::{
protocol_message::ProtocolMessage, protocol_transport::errors::EncryptedConnectionErr,
KeyParams, PartyId,
};

#[derive(Debug, Error)]
pub enum GenericProtocolError<Res: ProtocolResult> {
#[error("Synedrion session error {0}")]
Joined(Box<sessions::Error<Res, PartyId>>),
#[error("Incoming message stream error: {0}")]
IncomingStream(String),
#[error("Broadcast error: {0}")]
Broadcast(#[from] Box<tokio::sync::broadcast::error::SendError<ProtocolMessage>>),
}

impl<Res: ProtocolResult> From<sessions::LocalError> for GenericProtocolError<Res> {
fn from(err: sessions::LocalError) -> Self {
Self::Joined(Box::new(sessions::Error::Local(err)))
}
}

impl<Res: ProtocolResult> From<sessions::RemoteError<PartyId>> for GenericProtocolError<Res> {
fn from(err: sessions::RemoteError<PartyId>) -> Self {
Self::Joined(Box::new(sessions::Error::Remote(err)))
}
}

impl<Res: ProtocolResult> From<sessions::Error<Res, PartyId>> for GenericProtocolError<Res> {
fn from(err: sessions::Error<Res, PartyId>) -> Self {
Self::Joined(Box::new(err))
}
}

impl From<GenericProtocolError<InteractiveSigningResult<KeyParams>>> for ProtocolExecutionErr {
fn from(err: GenericProtocolError<InteractiveSigningResult<KeyParams>>) -> Self {
match err {
GenericProtocolError::Joined(err) => ProtocolExecutionErr::SigningProtocolError(err),
GenericProtocolError::IncomingStream(err) => ProtocolExecutionErr::IncomingStream(err),
GenericProtocolError::Broadcast(err) => ProtocolExecutionErr::Broadcast(err),
}
}
}

impl From<GenericProtocolError<KeygenAndAuxResult<KeyParams>>> for ProtocolExecutionErr {
fn from(err: GenericProtocolError<KeygenAndAuxResult<KeyParams>>) -> Self {
match err {
GenericProtocolError::Joined(err) => ProtocolExecutionErr::KeyGenProtocolError(err),
GenericProtocolError::IncomingStream(err) => ProtocolExecutionErr::IncomingStream(err),
GenericProtocolError::Broadcast(err) => ProtocolExecutionErr::Broadcast(err),
}
}
}

impl From<GenericProtocolError<KeyRefreshResult<KeyParams>>> for ProtocolExecutionErr {
fn from(err: GenericProtocolError<KeyRefreshResult<KeyParams>>) -> Self {
match err {
GenericProtocolError::Joined(err) => ProtocolExecutionErr::KeyRefreshProtocolError(err),
GenericProtocolError::IncomingStream(err) => ProtocolExecutionErr::IncomingStream(err),
GenericProtocolError::Broadcast(err) => ProtocolExecutionErr::Broadcast(err),
}
}
}

/// An error during or while setting up a protocol session
#[derive(Debug, Error)]
pub enum ProtocolExecutionErr {
#[error("Session Creation Error: {0}")]
SessionCreationError(synedrion::InitError),
#[error("Incoming message stream error: {0}")]
IncomingStream(String),
#[error("Synedrion session error {0}")]
SynedrionSession(synedrion::sessions::Error),
#[error("Synedrion session creation error: {0}")]
SessionCreation(sessions::LocalError),
#[error("Synedrion signing session error {0}")]
SigningProtocolError(Box<sessions::Error<InteractiveSigningResult<KeyParams>, PartyId>>),
#[error("Synedrion keygen session error {0}")]
KeyGenProtocolError(Box<sessions::Error<KeygenAndAuxResult<KeyParams>, PartyId>>),
#[error("Synedrion key refresh session error {0}")]
KeyRefreshProtocolError(Box<sessions::Error<KeyRefreshResult<KeyParams>, PartyId>>),
#[error("Broadcast error: {0}")]
Broadcast(#[from] Box<tokio::sync::broadcast::error::SendError<ProtocolMessage>>),
#[error("Bad keyshare error {0}")]
Expand All @@ -25,6 +91,8 @@ pub enum UserRunningProtocolErr {
#[error("Encrypted Connection Error: {0}")]
EncryptedConnection(#[from] EncryptedConnectionErr),
#[error("Protocol Execution Error {0}")]
SigningProtocolExecution(#[from] GenericProtocolError<InteractiveSigningResult<KeyParams>>),
#[error("Protocol Execution Error {0}")]
ProtocolExecution(#[from] ProtocolExecutionErr),
#[error("Serialization Error: {0:?}")]
Serialization(#[from] bincode::Error),
Expand Down
Loading