Skip to content

Commit

Permalink
adds round_two napi binding for frost signing (#4559)
Browse files Browse the repository at this point in the history
  • Loading branch information
jowparks authored Jan 18, 2024
1 parent 44422d2 commit 79c62d4
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions ironfish-rust-nodejs/src/frost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use ironfish::{
frost::keys::KeyPackage,
frost_utils::round_one::round_one as round_one_rust,
serializing::{bytes_to_hex, hex_to_vec_bytes},
frost::{
keys::KeyPackage,
round2::{Randomizer, SignatureShare},
SigningPackage,
},
frost_utils::{round_one::round_one as round_one_rust, round_two::round_two as round_two_rust},
serializing::{bytes_to_hex, hex_to_bytes, hex_to_vec_bytes},
};
use napi::bindgen_prelude::*;
use napi_derive::napi;
Expand Down Expand Up @@ -33,3 +37,21 @@ pub fn round_one(key_package: String, seed: u32) -> Result<RoundOneSigningData>
commitment_binding: bytes_to_hex(&commitment.binding().serialize()),
})
}

pub fn round_two(
signing_package: String,
key_package: String,
public_key_randomness: String,
seed: u64,
) -> Result<SignatureShare> {
let key_package =
KeyPackage::deserialize(&hex_to_vec_bytes(&key_package).map_err(to_napi_err)?[..])
.map_err(to_napi_err)?;
let signing_package =
SigningPackage::deserialize(&hex_to_vec_bytes(&signing_package).map_err(to_napi_err)?[..])
.map_err(to_napi_err)?;
let randomizer =
Randomizer::deserialize(&hex_to_bytes(&public_key_randomness).map_err(to_napi_err)?)
.map_err(to_napi_err)?;
round_two_rust(signing_package, key_package, randomizer, seed).map_err(to_napi_err)
}

0 comments on commit 79c62d4

Please sign in to comment.