From 8583028644347e864980ddbbe55f9c2d3f42c8b6 Mon Sep 17 00:00:00 2001 From: jowparks Date: Thu, 18 Jan 2024 16:49:32 -0800 Subject: [PATCH] creates method for taking commitments from participants and creating a signing package (#4562) --- .../src/structs/transaction.rs | 2 +- ironfish-rust/src/transaction/unsigned.rs | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ironfish-rust-nodejs/src/structs/transaction.rs b/ironfish-rust-nodejs/src/structs/transaction.rs index 9c86b4396a..223655aeb0 100644 --- a/ironfish-rust-nodejs/src/structs/transaction.rs +++ b/ironfish-rust-nodejs/src/structs/transaction.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::cell::RefCell; + use std::convert::TryInto; use ironfish::assets::asset_identifier::AssetIdentifier; @@ -174,7 +175,6 @@ impl NativeTransaction { pub fn new(version: u8) -> Result { let tx_version = version.try_into().map_err(to_napi_err)?; let transaction = ProposedTransaction::new(tx_version); - Ok(NativeTransaction { transaction }) } diff --git a/ironfish-rust/src/transaction/unsigned.rs b/ironfish-rust/src/transaction/unsigned.rs index fc2a74005d..0644fe873f 100644 --- a/ironfish-rust/src/transaction/unsigned.rs +++ b/ironfish-rust/src/transaction/unsigned.rs @@ -4,8 +4,13 @@ use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt}; use group::GroupEncoding; +use ironfish_frost::frost::{round1::SigningCommitments, Identifier, SigningPackage}; + use ironfish_zkp::redjubjub::{self, Signature}; -use std::io::{self, Write}; +use std::{ + collections::BTreeMap, + io::{self, Write}, +}; use crate::{ errors::IronfishError, serializing::read_scalar, transaction::Blake2b, OutputDescription, @@ -209,4 +214,15 @@ impl UnsignedTransaction { randomized_public_key: self.randomized_public_key.clone(), }) } + + // Creates frost signing package for use in round two of FROST multisig protocol + // only applicable for multisig transactions + pub fn signing_package( + &self, + commitments: BTreeMap, + ) -> Result { + // Create the transaction signature hash + let data_to_sign = self.transaction_signature_hash()?; + Ok(SigningPackage::new(commitments, &data_to_sign)) + } }