Skip to content

Commit

Permalink
support FROST v2 reddsa
Browse files Browse the repository at this point in the history
  • Loading branch information
pacu committed Sep 24, 2024
1 parent 0a37421 commit f73052e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ async-trait = "0.1.77"
eyre = "0.6.12"
frost-core = { version = "2.0.0-rc.0", features = ["serde"] }
frost-ed25519 = { version = "2.0.0-rc.0", features = ["serde"] }
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "81c649c412e5b6ba56d491d2857f91fbd28adbc7", features = ["frost", "serde"] }
reddsa = { git = "https://github.com/ZcashFoundation/reddsa.git", rev = "ed49e9ca0699a6450f6d4a9fe62ff168f5ea1ead", features = ["frost", "serde"] }
hex = { version = "0.4", features = ["serde"] }
thiserror = "1.0"
rand = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion frost-uniffi-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bip0039 = "0.11"
[features]
redpallas = []
regtest = []
#default = ["redpallas"]
default = ["redpallas"]

[build-dependencies]
uniffi = { workspace = true, features = ["build"] }
8 changes: 5 additions & 3 deletions frost-uniffi-sdk/src/randomized/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn aggregate(
.into_randomizer::<E>()
.map_err(|_| CoordinationError::InvalidRandomizer)?;

frost::aggregate(
let signature = frost::aggregate(
&signing_package,
&shares,
&public_key_package,
Expand All @@ -67,8 +67,10 @@ pub fn aggregate(
)
.map_err(|e| CoordinationError::SignatureShareAggregationFailed {
message: e.to_string(),
})
.map(FrostSignature::from_signature)
})?;

FrostSignature::from_signature(signature)
.map_err(|_| CoordinationError::SigningPackageSerializationError)
}

#[uniffi::export]
Expand Down
10 changes: 3 additions & 7 deletions frost-uniffi-sdk/src/randomized/randomizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rand::thread_rng;
use reddsa::frost::redpallas as frost;

use crate::{coordinator::FrostSigningPackage, FrostError, FrostPublicKeyPackage};
use frost::round2::Randomizer;
use crate::randomized::randomizer::frost::Randomizer;
use frost::RandomizedParams;
use frost_core::{Ciphersuite, Error};
use uniffi;
Expand Down Expand Up @@ -77,18 +77,14 @@ pub fn from_hex_string(hex_string: String) -> Result<FrostRandomizer, FrostError
.try_into()
.map_err(|_| FrostError::DeserializationError)?;

let randomizer = frost::round2::Randomizer::deserialize(&buf).map_err(FrostError::map_err)?;
let randomizer = Randomizer::deserialize(&buf).map_err(FrostError::map_err)?;

FrostRandomizer::from_randomizer::<E>(randomizer).map_err(FrostError::map_err)
}

impl FrostRandomizer {
pub fn into_randomizer<C: Ciphersuite>(&self) -> Result<Randomizer, Error<E>> {
let raw_randomizer = &self.data[0..32]
.try_into()
.map_err(|_| Error::DeserializationError)?;

Randomizer::deserialize(raw_randomizer)
Randomizer::deserialize(&self.data)
}

pub fn from_randomizer<C: Ciphersuite>(
Expand Down

0 comments on commit f73052e

Please sign in to comment.