Skip to content

Commit

Permalink
signature_share and signing_commitment replaced (#4768)
Browse files Browse the repository at this point in the history
we now use the structs from ironfish-frost repo
  • Loading branch information
patnir authored Feb 23, 2024
1 parent 397d57c commit c3962a8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 162 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 13 additions & 16 deletions ironfish-rust-nodejs/src/frost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use crate::{
};
use ironfish::{
frost::{keys::KeyPackage, round1::SigningCommitments, round2, Randomizer},
frost_utils::{
signature_share::SignatureShare, signing_commitment::SigningCommitment,
signing_package::SigningPackage, split_spender_key::split_spender_key,
},
frost_utils::{signing_package::SigningPackage, split_spender_key::split_spender_key},
participant::{Identity, Secret},
serializing::{bytes_to_hex, fr::FrSerializable, hex_to_bytes, hex_to_vec_bytes},
SaplingKey,
};
use ironfish_frost::nonces::deterministic_signing_nonces;
use ironfish_frost::{
nonces::deterministic_signing_nonces, signature_share::SignatureShare,
signing_commitment::SigningCommitment,
};
use napi::{bindgen_prelude::*, JsBuffer};
use napi_derive::napi;
use rand::thread_rng;
Expand Down Expand Up @@ -60,13 +60,12 @@ pub fn create_signing_commitment(
deterministic_signing_nonces(key_package.signing_share(), &transaction_hash, &signers);
let commitments = SigningCommitments::from(&nonces);

let signing_commitment = SigningCommitment {
identity,
hiding: *commitments.hiding(),
binding: *commitments.binding(),
};
let signing_commitment =
SigningCommitment::from_frost(identity, *commitments.hiding(), *commitments.binding());

let bytes = signing_commitment.serialize()?;

Ok(bytes_to_hex(&signing_commitment.serialize()))
Ok(bytes_to_hex(&bytes[..]))
}

#[napi]
Expand Down Expand Up @@ -113,12 +112,10 @@ pub fn create_signature_share(
)
.map_err(to_napi_err)?;

let signature_share = SignatureShare {
identity,
signature_share,
};
let signature_share = SignatureShare::from_frost(signature_share, identity);
let bytes = signature_share.serialize()?;

Ok(bytes_to_hex(&signature_share.serialize()))
Ok(bytes_to_hex(&bytes[..]))
}

#[napi]
Expand Down
28 changes: 18 additions & 10 deletions ironfish-rust-nodejs/src/structs/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ use ironfish::assets::asset_identifier::AssetIdentifier;
use ironfish::frost::round1::SigningCommitments;
use ironfish::frost::round2::SignatureShare as FrostSignatureShare;
use ironfish::frost::Identifier;
use ironfish::frost_utils::signature_share::SignatureShare;
use ironfish::frost_utils::signing_commitment::SigningCommitment;
use ironfish::frost_utils::signing_package::SigningPackage;
use ironfish::serializing::bytes_to_hex;
use ironfish::serializing::fr::FrSerializable;
use ironfish::serializing::hex_to_vec_bytes;
use ironfish::serializing::{bytes_to_hex, hex_to_bytes};
use ironfish::transaction::unsigned::UnsignedTransaction;
use ironfish::transaction::{
batch_verify_transactions, TransactionVersion, TRANSACTION_EXPIRATION_SIZE,
Expand All @@ -27,6 +25,8 @@ use ironfish::{
ViewKey,
};
use ironfish_frost::keys::PublicKeyPackage;
use ironfish_frost::signature_share::SignatureShare;
use ironfish_frost::signing_commitment::SigningCommitment;
use napi::{
bindgen_prelude::{i64n, BigInt, Buffer, Env, Object, Result, Undefined},
JsBuffer,
Expand Down Expand Up @@ -437,12 +437,15 @@ impl NativeUnsignedTransaction {

for identifier_commitment in native_identifer_commitments {
let bytes = hex_to_vec_bytes(&identifier_commitment).map_err(to_napi_err)?;
let signing_commitment = SigningCommitment::read(&bytes[..]).map_err(to_napi_err)?;
let signing_commitment =
SigningCommitment::deserialize_from(&bytes[..]).map_err(to_napi_err)?;

let commitment =
SigningCommitments::new(signing_commitment.hiding, signing_commitment.binding);
let commitment = SigningCommitments::new(
*signing_commitment.hiding(),
*signing_commitment.binding(),
);

commitments.push((signing_commitment.identity, commitment));
commitments.push((signing_commitment.identity().clone(), commitment));
}

let signing_package = self
Expand Down Expand Up @@ -487,9 +490,14 @@ pub fn aggregate_signature_shares(

let mut signature_shares = BTreeMap::<Identifier, FrostSignatureShare>::new();
for signature_share in signature_shares_arr.iter() {
let iss = SignatureShare::deserialize(&hex_to_bytes(signature_share).map_err(to_napi_err)?)
.map_err(to_napi_err)?;
signature_shares.insert(iss.identity.to_frost_identifier(), iss.signature_share);
let iss = SignatureShare::deserialize_from(
&hex_to_vec_bytes(signature_share).map_err(to_napi_err)?[..],
)
.map_err(to_napi_err)?;
signature_shares.insert(
iss.identity().to_frost_identifier(),
*iss.frost_signature_share(),
);
}

let signed_transaction = unsigned_transaction
Expand Down
2 changes: 0 additions & 2 deletions ironfish-rust/src/frost_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* 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/. */

pub mod signature_share;
pub mod signing_commitment;
pub mod signing_package;
pub mod split_secret;
pub mod split_spender_key;
49 changes: 0 additions & 49 deletions ironfish-rust/src/frost_utils/signature_share.rs

This file was deleted.

84 changes: 0 additions & 84 deletions ironfish-rust/src/frost_utils/signing_commitment.rs

This file was deleted.

0 comments on commit c3962a8

Please sign in to comment.