Skip to content

Commit ce5dae2

Browse files
committed
upgrades reddsa to newer commit to use frost 2.0.0-rc
1 parent 1a3e331 commit ce5dae2

File tree

12 files changed

+194
-209
lines changed

12 files changed

+194
-209
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ chacha20poly1305 = "0.10.1"
1515
ed25519-dalek = { version = "2.1.0", features = ["rand_core"] }
1616
rand_chacha = { version = "0.3.1", optional = true }
1717
rand_core = "0.6.4"
18-
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "311baf8865f6e21527d1f20750d8f2cf5c9e531a", features = ["frost", "frost-rerandomized"] }
18+
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "b9c3107e6ec5333a89a7fa064f2d10f749a90cce", features = ["frost", "frost-rerandomized"] }
1919
siphasher = { version = "1.0.0", optional = true }
2020
x25519-dalek = { version = "2.0.0", features = ["reusable_secrets", "static_secrets"] }
2121

@@ -24,7 +24,7 @@ hex-literal = "0.4.1"
2424
rand = "0.8.5"
2525

2626
[features]
27-
default = ["std", "signing"]
27+
default = ["std", "signing", "dkg"]
2828

2929
std = []
3030
signing = ["dep:blake3", "dep:rand_chacha", "dep:siphasher", "std"]

src/dkg/error.rs

Lines changed: 0 additions & 46 deletions
This file was deleted.

src/dkg/group_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl GroupSecretKeyShard {
7979
}
8080

8181
pub fn import(secret: &Secret, exported: &[u8]) -> io::Result<Self> {
82-
let bytes = multienc::decrypt(secret, &exported).map_err(io::Error::other)?;
82+
let bytes = multienc::decrypt(secret, exported).map_err(io::Error::other)?;
8383

8484
if bytes.len() != GROUP_SECRET_KEY_LEN {
8585
return Err(io::Error::other(

src/dkg/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
44

5-
pub mod error;
65
pub mod group_key;
76
pub mod round1;
87
pub mod round2;

src/dkg/round1.rs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use crate::checksum::Checksum;
66
use crate::checksum::ChecksumHasher;
77
use crate::checksum::CHECKSUM_LEN;
8-
use crate::dkg::error::Error;
98
use crate::dkg::group_key::GroupSecretKeyShard;
9+
use crate::error::IronfishFrostError;
1010
use crate::frost;
1111
use crate::frost::keys::dkg::round1::Package;
1212
use crate::frost::keys::dkg::round1::SecretPackage;
@@ -80,23 +80,24 @@ impl<'a> From<&'a SerializableSecretPackage> for &'a SecretPackage {
8080
}
8181

8282
impl SerializableSecretPackage {
83-
fn serialize_into<W: io::Write>(&self, mut writer: W) -> io::Result<()> {
83+
fn serialize_into<W: io::Write>(&self, mut writer: W) -> Result<(), IronfishFrostError> {
8484
writer.write_all(&self.identifier.serialize())?;
8585
write_variable_length(&mut writer, &self.coefficients, |writer, scalar| {
8686
writer.write_all(&scalar.to_bytes())
8787
})?;
88-
write_variable_length(&mut writer, self.commitment.serialize(), |writer, array| {
88+
let serialized = self.commitment.serialize()?;
89+
write_variable_length(&mut writer, serialized, |writer, array| {
8990
writer.write_all(&array)
9091
})?;
9192
write_u16(&mut writer, self.min_signers)?;
9293
write_u16(&mut writer, self.max_signers)?;
9394
Ok(())
9495
}
9596

96-
fn deserialize_from<R: io::Read>(mut reader: R) -> io::Result<Self> {
97+
fn deserialize_from<R: io::Read>(mut reader: R) -> Result<Self, IronfishFrostError> {
9798
let mut identifier = [0u8; 32];
9899
reader.read_exact(&mut identifier)?;
99-
let identifier = Identifier::deserialize(&identifier).map_err(io::Error::other)?;
100+
let identifier = Identifier::deserialize(&identifier)?;
100101

101102
let coefficients = read_variable_length(&mut reader, |reader| {
102103
let mut scalar = [0u8; 32];
@@ -112,8 +113,7 @@ impl SerializableSecretPackage {
112113
reader.read_exact(&mut array)?;
113114
Ok(array)
114115
},
115-
)?)
116-
.map_err(io::Error::other)?;
116+
)?)?;
117117

118118
let min_signers = read_u16(&mut reader)?;
119119
let max_signers = read_u16(&mut reader)?;
@@ -153,8 +153,8 @@ pub fn export_secret_package<R: RngCore + CryptoRng>(
153153
pub fn import_secret_package(
154154
exported: &[u8],
155155
secret: &participant::Secret,
156-
) -> io::Result<SecretPackage> {
157-
let serialized = multienc::decrypt(secret, &exported).map_err(io::Error::other)?;
156+
) -> Result<SecretPackage, IronfishFrostError> {
157+
let serialized = multienc::decrypt(secret, exported).map_err(io::Error::other)?;
158158
SerializableSecretPackage::deserialize_from(&serialized[..]).map(|pkg| pkg.into())
159159
}
160160

@@ -247,20 +247,20 @@ impl PublicPackage {
247247
buf
248248
}
249249

250-
pub fn serialize_into<W: io::Write>(&self, mut writer: W) -> io::Result<()> {
250+
pub fn serialize_into<W: io::Write>(&self, mut writer: W) -> Result<(), IronfishFrostError> {
251251
self.identity.serialize_into(&mut writer)?;
252-
let frost_package = self.frost_package.serialize().map_err(io::Error::other)?;
252+
let frost_package = self.frost_package.serialize()?;
253253
write_variable_length_bytes(&mut writer, &frost_package)?;
254254
writer.write_all(&self.group_secret_key_shard_encrypted[..])?;
255255
writer.write_all(&self.checksum.to_le_bytes())?;
256256
Ok(())
257257
}
258258

259-
pub fn deserialize_from<R: io::Read>(mut reader: R) -> io::Result<Self> {
259+
pub fn deserialize_from<R: io::Read>(mut reader: R) -> Result<Self, IronfishFrostError> {
260260
let identity = Identity::deserialize_from(&mut reader).expect("reading identity failed");
261261

262262
let frost_package = read_variable_length_bytes(&mut reader)?;
263-
let frost_package = Package::deserialize(&frost_package).map_err(io::Error::other)?;
263+
let frost_package = Package::deserialize(&frost_package)?;
264264

265265
let group_secret_key_shard_encrypted = read_encrypted_blob(&mut reader)?;
266266

@@ -282,7 +282,7 @@ pub fn round1<'a, I, R>(
282282
min_signers: u16,
283283
participants: I,
284284
mut csrng: R,
285-
) -> Result<(Vec<u8>, PublicPackage), Error>
285+
) -> Result<(Vec<u8>, PublicPackage), IronfishFrostError>
286286
where
287287
I: IntoIterator<Item = &'a Identity>,
288288
R: RngCore + CryptoRng,
@@ -294,25 +294,21 @@ where
294294
let participants = participants;
295295

296296
if !participants.contains(&self_identity) {
297-
return Err(Error::InvalidInput(
298-
"participants must include self_identity".to_string(),
299-
));
297+
return Err(IronfishFrostError::InvalidInput);
300298
}
301299

302-
let max_signers = u16::try_from(participants.len())
303-
.map_err(|_| Error::InvalidInput("too many participants".to_string()))?;
300+
let max_signers =
301+
u16::try_from(participants.len()).map_err(|_| IronfishFrostError::InvalidInput)?;
304302

305303
let (secret_package, public_package) = frost::keys::dkg::part1(
306304
self_identity.to_frost_identifier(),
307305
max_signers,
308306
min_signers,
309307
&mut csrng,
310-
)
311-
.map_err(Error::FrostError)?;
308+
)?;
312309

313310
let encrypted_secret_package =
314-
export_secret_package(&secret_package, self_identity, &mut csrng)
315-
.map_err(Error::EncryptionError)?;
311+
export_secret_package(&secret_package, self_identity, &mut csrng)?;
316312

317313
let group_secret_key_shard = GroupSecretKeyShard::random(&mut csrng);
318314

0 commit comments

Comments
 (0)