taproot_assets_core/
lib.rs1#![no_std]
2
3extern crate alloc;
4
5use taproot_assets_types::asset::SerializedKey;
6use thiserror::Error;
7
8#[derive(Error, Debug, Clone, Copy, PartialEq, Eq)]
10pub enum OpsError {
11 #[error("invalid group key reveal raw key")]
13 InvalidRawGroupKey,
14 #[error("invalid group key reveal internal key")]
16 InvalidInternalKey,
17 #[error("asset id tweak out of range")]
19 AssetIdTweakOutOfRange,
20 #[error("invalid group key tweak")]
22 InvalidGroupKeyTweak,
23 #[error("invalid taproot output key")]
25 InvalidTaprootOutputKey,
26}
27
28pub trait TaprootOps {
30 type PubKey;
32
33 fn parse_group_key(&self, key: &SerializedKey) -> Result<Self::PubKey, OpsError>;
35
36 fn parse_internal_key(&self, key: &SerializedKey) -> Result<Self::PubKey, OpsError>;
38
39 fn add_tweak(&self, pubkey: &Self::PubKey, tweak: [u8; 32]) -> Result<Self::PubKey, OpsError>;
41
42 fn taproot_output_key(
44 &self,
45 internal_key: &Self::PubKey,
46 tapscript_root: Option<[u8; 32]>,
47 ) -> Result<SerializedKey, OpsError>;
48}
49
50pub mod verify;