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 ce5dae2 commit 0b4c2b0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ ed25519-dalek = { version = "2.1.0", features = ["rand_core"] }
rand_chacha = { version = "0.3.1", optional = true }
rand_core = "0.6.4"
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "b9c3107e6ec5333a89a7fa064f2d10f749a90cce", features = ["frost", "frost-rerandomized"] }
siphasher = { version = "1.0.0", optional = true }
siphasher = { version = "1.0.0" }
x25519-dalek = { version = "2.0.0", features = ["reusable_secrets", "static_secrets"] }

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

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

std = []
signing = ["dep:blake3", "dep:rand_chacha", "dep:siphasher", "std"]
dkg = ["std", "signing"]
signing = ["dep:blake3", "dep:rand_chacha", "std"]
dkg = ["signing"]
5 changes: 1 addition & 4 deletions src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use std::error;
use std::fmt;
use core::fmt;

use siphasher::sip::SipHasher24;

Expand Down Expand Up @@ -32,5 +31,3 @@ impl fmt::Display for ChecksumError {
}
}
}

impl error::Error for ChecksumError {}
13 changes: 7 additions & 6 deletions src/dkg/round2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,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
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)),
}
}
}
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

mod serde;

#[cfg(feature = "signing")]
mod checksum;

pub mod error;
Expand Down

0 comments on commit 0b4c2b0

Please sign in to comment.