Trait zk_pass::conversion::ByteConvertible
source · pub trait ByteConvertible<T> {
// Required methods
fn convert_to(t: &T) -> Vec<u8>;
fn convert_from(bytes: &[u8]) -> Result<T, Box<dyn Error>>
where Self: Sized;
}
Expand description
A trait for converting types to and from byte representations.
This trait provides a common interface for types that can be converted to a byte array and constructed back from a byte array. It is particularly useful for cryptographic operations where serialization and deserialization of objects like points on an elliptic curve or scalars are needed.
Required Methods§
sourcefn convert_to(t: &T) -> Vec<u8>
fn convert_to(t: &T) -> Vec<u8>
Implementations on Foreign Types§
source§impl ByteConvertible<Scalar> for Scalar
impl ByteConvertible<Scalar> for Scalar
Implementation of ByteConvertible
for Scalar
.
This implementation provides methods to convert Scalar
objects to and from
byte arrays. Scalars are fundamental in cryptographic operations and being able to
serialize and deserialize them is crucial.
source§impl ByteConvertible<BigUint> for BigUint
impl ByteConvertible<BigUint> for BigUint
Implementation of ByteConvertible
for BigUint
.
This implementation provides methods to convert BigUint
objects to and from
byte arrays, using big-endian byte order.
source§impl ByteConvertible<Fq> for Scalar
impl ByteConvertible<Fq> for Scalar
source§impl ByteConvertible<Fp> for Scalar
impl ByteConvertible<Fp> for Scalar
source§impl ByteConvertible<Ep> for Point
impl ByteConvertible<Ep> for Point
source§impl ByteConvertible<RistrettoPoint> for RistrettoPoint
impl ByteConvertible<RistrettoPoint> for RistrettoPoint
Implementation of ByteConvertible
for RistrettoPoint
.
This implementation provides methods to convert RistrettoPoint
objects to and from
byte arrays. It uses the compression and decompression features of the Ristretto group
to achieve this.