Skip to content

Commit

Permalink
add SignBitcoinPayload to InitCeremony
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayanring committed Jul 19, 2024
1 parent ad50d91 commit b94879e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub enum CeremonyErrorReason {

#[derive(Debug, PartialEq, Eq, Clone)]
pub enum CeremonyCommand {
InitCeremony([u8; 32], SignersWithKeys, bool),
InitCeremony([u8; 32], SignersWithKeys, SignBitcoinPayload, bool),
SaveNonce(SignerId, PubNonce),
SavePartialSignature(SignerId, PartialSignature),
KillCeremony,
Expand Down Expand Up @@ -117,6 +117,7 @@ pub struct MuSig2CeremonyData<AK: AccessKey<KeyType = SchnorrPair>> {
signers: SignersWithKeys,
signing_key_access: Arc<AK>,
agg_key: PublicKey,
// indicates whether it's check run - signature verification result is returned instead of signature
check_run: bool,
}

Expand Down
8 changes: 5 additions & 3 deletions bitacross-worker/bitacross/core/bc-task-processor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ fn handle_ceremony_command<SKR, SIGNINGAK, EKR, BKR, S, H, O, RRL, ERL, SRL, Res
.map(|(c, _)| c.read().unwrap().is_first_round())
};
match (is_first_round, &command) {
(None, CeremonyCommand::InitCeremony(_, _, _))
(None, CeremonyCommand::InitCeremony(_, _, _, _))
| (Some(true), CeremonyCommand::SaveNonce(_, _))
| (Some(false), CeremonyCommand::SavePartialSignature(_, _))
| (_, CeremonyCommand::KillCeremony) => {},
Expand Down Expand Up @@ -407,13 +407,13 @@ where
Responder: SendRpcResponse<Hash = H256> + Send + Sync + 'static,
{
match command {
CeremonyCommand::InitCeremony(aes_key, signers, check_run) => {
CeremonyCommand::InitCeremony(aes_key, signers, payload, check_run) => {
// InitCeremony should create ceremony first
let result = MuSig2Ceremony::new(
context.signing_key_pub,
aes_key,
signers,
ceremony_id.clone(),
payload,
context.bitcoin_key_repository.clone(),
check_run,
);
Expand Down Expand Up @@ -576,6 +576,7 @@ where
let hash = blake2_256(&payload.encode());
let command = sign_bitcoin::handle(
signer,
payload.clone(),
aes_key,
context.relayer_registry_lookup.deref(),
context.signer_registry_lookup.clone(),
Expand All @@ -595,6 +596,7 @@ where
let hash = blake2_256(&payload.encode());
let command = sign_bitcoin::handle(
signer,
payload.clone(),
aes_key,
context.relayer_registry_lookup.deref(),
context.signer_registry_lookup.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Litentry. If not, see <https://www.gnu.org/licenses/>.

use bc_enclave_registry::EnclaveRegistryLookup;
use bc_musig2_ceremony::{CeremonyCommand, PublicKey, SignersWithKeys};
use bc_musig2_ceremony::{CeremonyCommand, PublicKey, SignBitcoinPayload, SignersWithKeys};
use bc_relayer_registry::RelayerRegistryLookup;
use bc_signer_registry::SignerRegistryLookup;
use codec::Encode;
Expand All @@ -31,6 +31,7 @@ pub enum SignBitcoinError {
#[allow(clippy::too_many_arguments)]
pub fn handle<RRL: RelayerRegistryLookup, SR: SignerRegistryLookup, ER: EnclaveRegistryLookup>(
signer: Identity,
payload: SignBitcoinPayload,
aes_key: [u8; 32],
relayer_registry: &RRL,
signer_registry: Arc<SR>,
Expand All @@ -52,7 +53,7 @@ pub fn handle<RRL: RelayerRegistryLookup, SR: SignerRegistryLookup, ER: EnclaveR
})
.collect();

Ok(CeremonyCommand::InitCeremony(aes_key, signers?, check_run))
Ok(CeremonyCommand::InitCeremony(aes_key, signers?, payload, check_run))
} else {
Err(SignBitcoinError::InvalidSigner)
}
Expand All @@ -63,6 +64,7 @@ pub mod test {
use crate::handler::sign_bitcoin::{handle, SignBitcoinError};
use alloc::sync::Arc;
use bc_enclave_registry::{EnclaveRegistry, EnclaveRegistryUpdater};
use bc_musig2_ceremony::SignBitcoinPayload;
use bc_relayer_registry::{RelayerRegistry, RelayerRegistryUpdater};
use bc_signer_registry::{PubKey, SignerRegistryLookup};
use itp_sgx_crypto::{key_repository::AccessKey, schnorr::Pair as SchnorrPair, Error};
Expand Down Expand Up @@ -126,6 +128,7 @@ pub mod test {
// when
let result = handle(
relayer_account,
SignBitcoinPayload::Derived(vec![]),
[0u8; 32],
&relayer_registry,
signers_registry,
Expand All @@ -150,6 +153,7 @@ pub mod test {
// when
let result = handle(
enclave_account,
SignBitcoinPayload::Derived(vec![]),
[0u8; 32],
&relayer_registry,
signers_registry,
Expand All @@ -174,6 +178,7 @@ pub mod test {
//when
let result = handle(
non_relayer_account,
SignBitcoinPayload::Derived(vec![]),
[0u8; 32],
&relayer_registry,
signers_registry,
Expand Down

0 comments on commit b94879e

Please sign in to comment.