Skip to content

Commit be6e974

Browse files
committed
fix cargo test-all-features
1 parent 9799754 commit be6e974

File tree

7 files changed

+26
-38
lines changed

7 files changed

+26
-38
lines changed

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@ repository = "https://github.com/iron-fish/ironfish-frost"
1212
blake3 = { version = "1.5.0", optional = true }
1313
chacha20 = "0.9.1"
1414
chacha20poly1305 = "0.10.1"
15-
ed25519-dalek = { version = "2.1.0", features = ["rand_core"] }
16-
rand_chacha = { version = "0.3.1", optional = true }
17-
rand_core = "0.6.4"
18-
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "311baf8865f6e21527d1f20750d8f2cf5c9e531a", features = ["frost", "frost-rerandomized"] }
19-
siphasher = { version = "1.0.0", features =["serde_no_std"] }
20-
x25519-dalek = { version = "2.0.0", features = ["reusable_secrets", "static_secrets"] }
15+
ed25519-dalek = { version = "2.1.0", features = ["rand_core", "alloc"], default-features = false }
16+
rand_chacha = { version = "0.3.1", optional = true, default-features = false }
17+
rand_core = { version = "0.6.4", features = ["alloc"], default-features = false }
18+
reddsa = { path = "../reddsa", features = ["frost", "alloc"], default-features = false }
19+
frost-core = { git = "https://github.com/ZcashFoundation/frost.git", rev = "c6c3f2f", package = "frost-core", features = ["serialization", "serde", "cheater-detection"], default-features = false }
20+
frost-rerandomized = { git = "https://github.com/ZcashFoundation/frost.git", rev = "c6c3f2f", package = "frost-rerandomized", features = ["serialization", "cheater-detection"], default-features = false }
21+
siphasher = { version = "1.0.0", default-features = false }
22+
x25519-dalek = { version = "2.0.0", features = ["reusable_secrets", "static_secrets"], default-features = false }
2123

2224
[dev-dependencies]
2325
hex-literal = "0.4.1"
2426
rand = "0.8.5"
2527

2628
[features]
27-
default = ["signing"]
29+
default = ["dkg"]
2830

2931
std = []
3032
signing = ["dep:blake3", "dep:rand_chacha", "std"]

src/checksum.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,3 @@ impl fmt::Display for ChecksumError {
3030
}
3131
}
3232
}
33-
34-
#[cfg(feature = "std")]
35-
use std::error;
36-
#[cfg(feature = "std")]
37-
impl error::Error for ChecksumError {}

src/dkg/round1.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::frost::Identifier;
1616
use crate::frost::JubjubScalarField;
1717
use crate::io;
1818
use crate::multienc;
19+
use crate::multienc::read_encrypted_blob;
1920
use crate::participant;
2021
use crate::participant::Identity;
2122
use crate::serde::read_u16;
@@ -34,8 +35,6 @@ use core::mem;
3435
#[cfg(not(feature = "std"))]
3536
extern crate alloc;
3637
#[cfg(not(feature = "std"))]
37-
use alloc::string::ToString;
38-
#[cfg(not(feature = "std"))]
3938
use alloc::vec::Vec;
4039

4140
type Scalar = <JubjubScalarField as Field>::Scalar;
@@ -143,7 +142,7 @@ pub(super) fn get_secret_package_signers(pkg: &SecretPackage) -> (u16, u16) {
143142
pub fn export_secret_package<R: RngCore + CryptoRng>(
144143
pkg: &SecretPackage,
145144
identity: &Identity,
146-
csrng: R,
145+
mut csrng: R,
147146
) -> io::Result<Vec<u8>> {
148147
let serializable = <&SerializableSecretPackage>::from(pkg);
149148
if serializable.identifier != identity.to_frost_identifier() {
@@ -154,7 +153,7 @@ pub fn export_secret_package<R: RngCore + CryptoRng>(
154153
serializable
155154
.serialize_into(&mut serialized)
156155
.expect("serialization failed");
157-
Ok(multienc::encrypt(&serialized, [identity], csrng))
156+
Ok(multienc::encrypt(&serialized, [identity], &mut csrng))
158157
}
159158

160159
pub fn import_secret_package(

src/dkg/round2.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,19 @@ impl CombinedPublicPackage {
329329
Ok(write_variable_length(
330330
writer,
331331
&self.packages,
332-
|writer, pkg| Ok(pkg.serialize_without_sender_into(writer)?),
332+
|writer, pkg| {
333+
pkg.serialize_without_sender_into(writer)
334+
.map_err(|_| io::Error::other("serialize_into failed"))
335+
},
333336
)?)
334337
}
335338

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

339342
let packages = read_variable_length(reader, move |reader| {
340-
Ok(PublicPackage::deserialize_without_sender_from(
341-
reader,
342-
sender_identity.clone(),
343-
)?)
343+
PublicPackage::deserialize_without_sender_from(reader, sender_identity.clone())
344+
.map_err(|_| io::Error::other("deserialization failed"))
344345
})?;
345346

346347
Ok(Self { packages })

src/dkg/round3.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ impl PublicKeyPackage {
8383
bytes
8484
}
8585

86-
#[cfg(feature = "std")]
8786
pub fn serialize_into<W: io::Write>(&self, mut writer: W) -> Result<(), IronfishFrostError> {
8887
let frost_public_key_package = self.frost_public_key_package.serialize()?;
8988
write_variable_length_bytes(&mut writer, &frost_public_key_package)?;

src/error.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ use reddsa::frost::redjubjub::frost::Error as FrostError;
66
use reddsa::frost::redjubjub::JubjubBlake2b512;
77

88
use crate::checksum::ChecksumError;
9+
use crate::io;
910

1011
#[derive(Debug)]
1112
pub enum IronfishFrostError {
1213
InvalidInput,
1314
StdError,
14-
IoError(std::io::Error),
15+
IoError(io::Error),
1516
FrostError(FrostError<JubjubBlake2b512>),
1617
SignatureError(ed25519_dalek::SignatureError),
1718
ChecksumError(ChecksumError),
@@ -23,8 +24,8 @@ impl From<FrostError<JubjubBlake2b512>> for IronfishFrostError {
2324
}
2425
}
2526

26-
impl From<std::io::Error> for IronfishFrostError {
27-
fn from(error: std::io::Error) -> Self {
27+
impl From<io::Error> for IronfishFrostError {
28+
fn from(error: io::Error) -> Self {
2829
IronfishFrostError::IoError(error)
2930
}
3031
}
@@ -34,12 +35,3 @@ impl From<ed25519_dalek::SignatureError> for IronfishFrostError {
3435
IronfishFrostError::SignatureError(error)
3536
}
3637
}
37-
38-
impl From<IronfishFrostError> for std::io::Error {
39-
fn from(error: IronfishFrostError) -> Self {
40-
match error {
41-
IronfishFrostError::IoError(e) => e,
42-
_ => std::io::Error::new(std::io::ErrorKind::Other, format!("{:?}", error)),
43-
}
44-
}
45-
}

src/multienc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ where
6060
}
6161

6262
#[must_use]
63-
pub fn encrypt<'a, I, R>(data: &[u8], recipients: I, csrng: R) -> Vec<u8>
63+
pub fn encrypt<'a, I, R>(data: &[u8], recipients: I, mut csrng: R) -> Vec<u8>
6464
where
6565
I: IntoIterator<Item = &'a Identity>,
6666
I::IntoIter: ExactSizeIterator,
@@ -72,7 +72,7 @@ where
7272

7373
let (metadata, ciphertext) = result.split_at_mut(metadata_len);
7474
ciphertext.copy_from_slice(data);
75-
encrypt_in_place(ciphertext, metadata, recipients, csrng).expect("failed to encrypt data");
75+
encrypt_in_place(ciphertext, metadata, recipients, &mut csrng).expect("failed to encrypt data");
7676

7777
result
7878
}
@@ -118,7 +118,7 @@ where
118118
// We write the number of recipients and the length of the ciphertext in the metadata for
119119
// convenience, to make decryption easier for the caller. Both numbers are unauthenticated,
120120
// again for the reason outline above: we rely on the ChaCha20Poly1305 tag for integrity.
121-
let agreement_secret = ReusableSecret::random_from_rng(csrng);
121+
let agreement_secret = ReusableSecret::random_from_rng(&mut csrng);
122122
let agreement_key = PublicKey::from(&agreement_secret);
123123

124124
let header = Header {

0 commit comments

Comments
 (0)