Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add field aux to SignWithSchnorrArgument #573

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/ic-cdk/src/api/management_canister/schnorr/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use candid::CandidType;
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;

use super::super::main::CanisterId;

Expand Down Expand Up @@ -27,6 +28,31 @@ pub struct SchnorrPublicKeyResponse {
pub chain_code: Vec<u8>,
}

/// SignWithBip341 auxiliary parameter
#[derive(
CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default,
)]
pub struct SignWithBip341Aux {
/// The merkle_root_hash must be generated in accordance with BIP341's specification for taproot_output_script.
///
/// Specifically it should be either an empty bytestring (for the script == None case)
/// or else 32 bytes generated using the procedure documented as taproot_tree_helper.
pub merkle_root_hash: ByteBuf,
}

/// The auxiliary parameter type SignWithSchnorrAux is an enumeration.
#[derive(
CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone,
)]
pub enum SignWithSchnorrAux {
/// The only currently supported variant is bip341 which allows passing a Merkle tree root hash,
/// which is required to implement Taproot signatures as defined in BIP341.
///
/// The bip341 variant is only allowed for bip340secp256k1 signatures.
#[serde(rename = "bip341")]
Bip341(SignWithBip341Aux),
}

/// Argument Type of [sign_with_schnorr](super::sign_with_schnorr).
#[derive(
CandidType, Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Default,
Expand All @@ -38,6 +64,12 @@ pub struct SignWithSchnorrArgument {
pub derivation_path: Vec<Vec<u8>>,
/// See [SchnorrKeyId].
pub key_id: SchnorrKeyId,
/// An optional auxiliary parameter.
///
/// If no auxiliary parameter is provided, then bip340secp256k1 signatures are generated in accordance with BIP340.
///
/// Check [sign_with_schnorr](https://internetcomputer.org/docs/references/ic-interface-spec#ic-sign_with_schnorr) for more details.
pub aux: Option<SignWithSchnorrAux>,
}

/// Response Type of [sign_with_schnorr](super::sign_with_schnorr).
Expand Down
Loading