Skip to main content

blueprint_crypto/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3use thiserror::Error;
4
5pub use blueprint_crypto_core::*;
6
7#[cfg(feature = "k256")]
8pub use blueprint_crypto_k256 as k256;
9
10#[cfg(feature = "sr25519-schnorrkel")]
11pub use blueprint_crypto_sr25519 as sr25519;
12
13#[cfg(feature = "ed25519")]
14pub use blueprint_crypto_ed25519 as ed25519;
15
16#[cfg(feature = "bls")]
17pub use blueprint_crypto_bls as bls;
18
19#[cfg(feature = "bn254")]
20pub use blueprint_crypto_bn254 as bn254;
21
22#[cfg(feature = "hashing")]
23pub use blueprint_crypto_hashing as hashing;
24
25#[derive(Debug, Error)]
26pub enum CryptoCoreError {
27    #[cfg(feature = "k256")]
28    #[error(transparent)]
29    K256(#[from] blueprint_crypto_k256::error::K256Error),
30    #[cfg(feature = "sr25519-schnorrkel")]
31    #[error(transparent)]
32    Sr25519(#[from] blueprint_crypto_sr25519::error::Sr25519Error),
33    #[cfg(feature = "ed25519")]
34    #[error(transparent)]
35    Ed25519(#[from] blueprint_crypto_ed25519::error::Ed25519Error),
36    #[cfg(feature = "bls")]
37    #[error(transparent)]
38    Bls(#[from] blueprint_crypto_bls::error::BlsError),
39    #[cfg(feature = "bn254")]
40    #[error(transparent)]
41    Bn254(#[from] blueprint_crypto_bn254::error::Bn254Error),
42}
43
44pub trait IntoCryptoError {
45    fn into_crypto_error(self) -> CryptoCoreError;
46}
47
48#[cfg(feature = "k256")]
49impl IntoCryptoError for blueprint_crypto_k256::error::K256Error {
50    fn into_crypto_error(self) -> CryptoCoreError {
51        CryptoCoreError::K256(self)
52    }
53}
54
55#[cfg(feature = "sr25519-schnorrkel")]
56impl IntoCryptoError for blueprint_crypto_sr25519::error::Sr25519Error {
57    fn into_crypto_error(self) -> CryptoCoreError {
58        CryptoCoreError::Sr25519(self)
59    }
60}
61
62#[cfg(feature = "ed25519")]
63impl IntoCryptoError for blueprint_crypto_ed25519::error::Ed25519Error {
64    fn into_crypto_error(self) -> CryptoCoreError {
65        CryptoCoreError::Ed25519(self)
66    }
67}
68
69#[cfg(feature = "bls")]
70impl IntoCryptoError for blueprint_crypto_bls::error::BlsError {
71    fn into_crypto_error(self) -> CryptoCoreError {
72        CryptoCoreError::Bls(self)
73    }
74}
75
76#[cfg(feature = "bn254")]
77impl IntoCryptoError for blueprint_crypto_bn254::error::Bn254Error {
78    fn into_crypto_error(self) -> CryptoCoreError {
79        CryptoCoreError::Bn254(self)
80    }
81}