Skip to content

Commit

Permalink
fix cargo test-all-features
Browse files Browse the repository at this point in the history
  • Loading branch information
jowparks committed Jul 30, 2024
1 parent 9799754 commit 442cb7f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 32 deletions.
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ repository = "https://github.com/iron-fish/ironfish-frost"
blake3 = { version = "1.5.0", optional = true }
chacha20 = "0.9.1"
chacha20poly1305 = "0.10.1"
ed25519-dalek = { version = "2.1.0", features = ["rand_core"] }
ed25519-dalek = { version = "2.1.0", default-features = false, features = ["rand_core", "alloc"] }
rand_chacha = { version = "0.3.1", optional = true }
rand_core = "0.6.4"
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "311baf8865f6e21527d1f20750d8f2cf5c9e531a", features = ["frost", "frost-rerandomized"] }
siphasher = { version = "1.0.0", features =["serde_no_std"] }
x25519-dalek = { version = "2.0.0", features = ["reusable_secrets", "static_secrets"] }
rand_core = { version = "0.6.4", default-features = false, features = ["alloc"] }
reddsa = { path = "../reddsa", default-features = false, features = ["frost", "alloc"]}
frost-core = { git = "https://github.com/ZcashFoundation/frost.git", package = "frost-core", default-features = false, features = ["serialization", "serde", "cheater-detection"] }
siphasher = { version = "1.0.0", default-features = false }
x25519-dalek = { version = "2.0.0", default-features = false, features = ["reusable_secrets", "static_secrets"] }

[dev-dependencies]
hex-literal = "0.4.1"
rand = "0.8.5"

[features]
default = ["signing"]
default = ["dkg"]

std = []
signing = ["dep:blake3", "dep:rand_chacha", "std"]
Expand Down
5 changes: 0 additions & 5 deletions src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,3 @@ impl fmt::Display for ChecksumError {
}
}
}

#[cfg(feature = "std")]
use std::error;
#[cfg(feature = "std")]
impl error::Error for ChecksumError {}
3 changes: 1 addition & 2 deletions src/dkg/round1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::frost::Identifier;
use crate::frost::JubjubScalarField;
use crate::io;
use crate::multienc;
use crate::multienc::read_encrypted_blob;
use crate::participant;
use crate::participant::Identity;
use crate::serde::read_u16;
Expand All @@ -34,8 +35,6 @@ use core::mem;
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::string::ToString;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

type Scalar = <JubjubScalarField as Field>::Scalar;
Expand Down
13 changes: 7 additions & 6 deletions src/dkg/round2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,19 @@ impl CombinedPublicPackage {
Ok(write_variable_length(
writer,
&self.packages,
|writer, pkg| Ok(pkg.serialize_without_sender_into(writer)?),
|writer, pkg| {
pkg.serialize_without_sender_into(writer)
.map_err(|_| io::Error::other("serialize_into failed"))
},
)?)
}

pub fn deserialize_from<R: io::Read>(mut reader: R) -> io::Result<Self> {
pub fn deserialize_from<R: io::Read>(mut reader: R) -> Result<Self, IronfishFrostError> {
let sender_identity = Identity::deserialize_from(&mut reader)?;

let packages = read_variable_length(reader, move |reader| {
Ok(PublicPackage::deserialize_without_sender_from(
reader,
sender_identity.clone(),
)?)
PublicPackage::deserialize_without_sender_from(reader, sender_identity.clone())
.map_err(|_| io::Error::other("deserialization failed"))
})?;

Ok(Self { packages })
Expand Down
1 change: 0 additions & 1 deletion src/dkg/round3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ impl PublicKeyPackage {
bytes
}

#[cfg(feature = "std")]
pub fn serialize_into<W: io::Write>(&self, mut writer: W) -> Result<(), IronfishFrostError> {
let frost_public_key_package = self.frost_public_key_package.serialize()?;
write_variable_length_bytes(&mut writer, &frost_public_key_package)?;
Expand Down
16 changes: 4 additions & 12 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ use reddsa::frost::redjubjub::frost::Error as FrostError;
use reddsa::frost::redjubjub::JubjubBlake2b512;

use crate::checksum::ChecksumError;
use crate::io;

#[derive(Debug)]
pub enum IronfishFrostError {
InvalidInput,
StdError,
IoError(std::io::Error),
IoError(io::Error),
FrostError(FrostError<JubjubBlake2b512>),
SignatureError(ed25519_dalek::SignatureError),
ChecksumError(ChecksumError),
Expand All @@ -23,8 +24,8 @@ impl From<FrostError<JubjubBlake2b512>> for IronfishFrostError {
}
}

impl From<std::io::Error> for IronfishFrostError {
fn from(error: std::io::Error) -> Self {
impl From<io::Error> for IronfishFrostError {
fn from(error: io::Error) -> Self {
IronfishFrostError::IoError(error)
}
}
Expand All @@ -34,12 +35,3 @@ impl From<ed25519_dalek::SignatureError> for IronfishFrostError {
IronfishFrostError::SignatureError(error)
}
}

impl From<IronfishFrostError> for std::io::Error {
fn from(error: IronfishFrostError) -> Self {
match error {
IronfishFrostError::IoError(e) => e,
_ => std::io::Error::new(std::io::ErrorKind::Other, format!("{:?}", error)),
}
}
}

0 comments on commit 442cb7f

Please sign in to comment.