Trait iota_types::crypto::ToFromBytes
pub trait ToFromBytes: Sized + AsRef<[u8]> + Debug {
// Required method
fn from_bytes(bytes: &[u8]) -> Result<Self, FastCryptoError>;
// Provided method
fn as_bytes(&self) -> &[u8] ⓘ { ... }
}
Expand description
Trait impl’d by concrete types that represent digital cryptographic material (keys).
Key types must (as mandated by the AsRef<[u8]>
bound) be a thin
wrapper around the “bag-of-bytes” serialized form of a key which can
be directly parsed from or written to the “wire”.
The ToFromBytes
trait aims to provide similar simplicity by minimizing
the number of steps involved to obtain a serializable key and
ideally ensuring there is one signature type for any given signature system
shared by all “provider” crates.
For signature systems which require a more advanced internal representation
(e.g. involving decoded scalars or decompressed elliptic curve points) it’s
recommended that “provider” libraries maintain their own internal signature
type and use From
bounds to provide automatic conversions.
Required Methods§
fn from_bytes(bytes: &[u8]) -> Result<Self, FastCryptoError>
fn from_bytes(bytes: &[u8]) -> Result<Self, FastCryptoError>
Parse an object from its byte representation
Provided Methods§
Object Safety§
Implementors§
impl ToFromBytes for GenericSignature
GenericSignature encodes a single signature [enum Signature] as is flag || signature || pubkey
. It encodes [struct MultiSigLegacy] as the MultiSig
flag (0x03) concat with the bcs serializedbytes of [struct MultiSigLegacy]
i.e. flag || bcs_bytes(MultiSigLegacy)
. [struct Multisig] is encodede as
the MultiSig flag (0x03) concat with the bcs serializedbytes of [struct
Multisig] i.e. flag || bcs_bytes(Multisig)
.
impl ToFromBytes for Signature
impl ToFromBytes for MultiSig
impl ToFromBytes for PasskeyAuthenticator
impl ToFromBytes for ZkLoginAuthenticator
impl ToFromBytes for AuthorityPublicKeyBytes
impl ToFromBytes for Ed25519IotaSignature
impl ToFromBytes for Secp256k1IotaSignature
impl ToFromBytes for Secp256r1IotaSignature
impl ToFromBytes for BLS12381AggregateSignature
impl ToFromBytes for BLS12381AggregateSignature
impl ToFromBytes for BLS12381KeyPair
impl ToFromBytes for BLS12381KeyPair
impl ToFromBytes for BLS12381PrivateKey
impl ToFromBytes for BLS12381PrivateKey
impl ToFromBytes for BLS12381PublicKey
impl ToFromBytes for BLS12381PublicKey
impl ToFromBytes for BLS12381Signature
impl ToFromBytes for BLS12381Signature
impl ToFromBytes for Ed25519AggregateSignature
impl ToFromBytes for Ed25519KeyPair
The bytes form of the keypair always only contain the private key bytes
impl ToFromBytes for Ed25519PrivateKey
impl ToFromBytes for Ed25519PublicKey
impl ToFromBytes for Ed25519Signature
impl ToFromBytes for Secp256k1KeyPair
The bytes form of the keypair always only contain the private key bytes
impl ToFromBytes for Secp256k1PrivateKey
impl ToFromBytes for Secp256k1PublicKey
impl ToFromBytes for Secp256k1RecoverableSignature
impl ToFromBytes for Secp256k1Signature
impl ToFromBytes for Secp256r1KeyPair
The bytes form of the keypair always only contain the private key bytes