7 releases (breaking)

Uses new Rust 2024

new 0.6.0 Apr 9, 2026
0.5.0 Apr 3, 2026
0.4.0 Mar 24, 2026
0.3.1 Mar 20, 2026
0.1.0 Jan 21, 2026

#942 in Magic Beans

Download history 3/week @ 2026-02-25 34/week @ 2026-03-04 40/week @ 2026-03-11 41/week @ 2026-03-18 36/week @ 2026-03-25 91/week @ 2026-04-01

209 downloads per month
Used in 20 crates (10 directly)

BSD-3-Clause

77KB
1.5K SLoC

ootle_byte_type

Crates.io Documentation

Lightweight conversion traits between rich types and their flat fixed byte-array representations. Useful for serialisation boundaries where allocating or expensive Edwards point decompression operations are undesirable.

Traits

Trait Direction Method
ToByteType T → Bytes to_byte_type(&self) -> Self::ByteType
ConvertFromByteType<B> Bytes → T convert_from_byte_type(bytes: &B) -> Result<Self, _>
FromByteType<T> Bytes → T (blanket) try_from_byte_type(&self) -> Result<T, _>

FromByteType is automatically implemented for any B where T: ConvertFromByteType<B>, so you only need to implement ConvertFromByteType.

Example

use ootle_byte_type::{ToByteType, FromByteType};
use tari_crypto::{keys::PublicKey, ristretto::RistrettoPublicKey};
use tari_template_lib_types::crypto::RistrettoPublicKeyBytes;

// Rich type → bytes
let (_, pk) = RistrettoPublicKey::random_keypair( & mut rand::thread_rng());
let bytes: RistrettoPublicKeyBytes = pk.to_byte_type();

// Bytes → rich type
let pk2: RistrettoPublicKey = bytes.try_from_byte_type().unwrap();
assert_eq!(pk, pk2);

With the crypto feature (enabled by default) implementations are provided for RistrettoPublicKey, PedersenCommitment, SchnorrSignature, CommitmentSignature, and Option<T>.

License

BSD-3-Clause. Copyright 2026 The Tari Project.

Dependencies

~0–2.5MB
~47K SLoC