Skip to main content

taproot_assets_core/verify/
mod.rs

1//! Verification routines for Taproot Assets proofs.
2
3/// Group key reveal verification helpers.
4pub mod group_key_reveal;
5/// Proof verification helpers.
6pub mod proof;
7/// Taproot proof verification helpers.
8pub mod taproot_proof;
9/// Anchor transaction verification helpers.
10pub mod tx;
11
12/// Result type for verification helpers.
13pub type Result<T> = core::result::Result<T, Error>;
14
15/// Errors returned by verification helpers.
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum Error {
18    /// Group key reveal verification failed.
19    GroupKeyReveal(group_key_reveal::Error),
20    /// Proof verification failed.
21    Proof(proof::Error),
22    /// Taproot proof verification failed.
23    TaprootProof(taproot_proof::Error),
24    /// Anchor transaction verification failed.
25    Tx(tx::Error),
26}
27
28impl From<group_key_reveal::Error> for Error {
29    /// Converts a group key reveal error into a verification error.
30    fn from(err: group_key_reveal::Error) -> Self {
31        Self::GroupKeyReveal(err)
32    }
33}
34
35impl From<proof::Error> for Error {
36    /// Converts a proof error into a verification error.
37    fn from(err: proof::Error) -> Self {
38        Self::Proof(err)
39    }
40}
41
42impl From<taproot_proof::Error> for Error {
43    /// Converts a taproot proof error into a verification error.
44    fn from(err: taproot_proof::Error) -> Self {
45        Self::TaprootProof(err)
46    }
47}
48
49impl From<tx::Error> for Error {
50    /// Converts a transaction error into a verification error.
51    fn from(err: tx::Error) -> Self {
52        Self::Tx(err)
53    }
54}
55
56impl core::fmt::Display for Error {
57    /// Formats the error for display.
58    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
59        match self {
60            Error::GroupKeyReveal(err) => core::fmt::Display::fmt(err, f),
61            Error::Proof(err) => core::fmt::Display::fmt(err, f),
62            Error::TaprootProof(err) => core::fmt::Display::fmt(err, f),
63            Error::Tx(err) => core::fmt::Display::fmt(err, f),
64        }
65    }
66}