From 883e531a9d136c4ca4413759c1dce74629884b82 Mon Sep 17 00:00:00 2001 From: Jun Luo <4catcode@gmail.com> Date: Fri, 6 Sep 2024 11:11:11 +0800 Subject: [PATCH] WIP, no alloc --- src/convert.rs | 48 ++++++++++----- src/ed25519.rs | 155 +++++++++++++++++++++++++++++++++++++++---------- src/strkey.rs | 121 +++++++++++++++++++++++++++++++++----- src/typ.rs | 24 ++++++++ tests/tests.rs | 5 +- 5 files changed, 288 insertions(+), 65 deletions(-) diff --git a/src/convert.rs b/src/convert.rs index 94b7fbc..a2195cd 100644 --- a/src/convert.rs +++ b/src/convert.rs @@ -1,16 +1,7 @@ // TODO: Could encode and decode, and the functions upstream that call them, be // const fn's? -use crate::{crc::checksum, error::DecodeError}; - -// PublicKeyEd25519 32-bytes -// PrivateKeyEd25519 32-bytes -// PreAuthTx 32-bytes -// HashX 32-bytes -// MuxedAccountEd25519 40-bytes -// SignedPayloadEd25519 32 + 4 + 4 = 40-bytes min, 32 + 4 + 64 = 100-bytes max -// Contract 32-bytes -const MAX_PAYLOAD_LEN: usize = 32 + 4 + 64; +use crate::{crc::checksum, error::DecodeError, typ}; /// Get the length of the strkey encoded data. /// @@ -18,7 +9,7 @@ const MAX_PAYLOAD_LEN: usize = 32 + 4 + 64; /// /// * `input_len` - The length of the raw data. pub fn encode_len(input_len: usize) -> usize { - let len = 1 + input_len + 2; + let len = 1 + input_len + 2; // ver + payload + crc data_encoding::BASE32_NOPAD.encode_len(len) } @@ -43,7 +34,7 @@ pub fn encode_len(input_len: usize) -> usize { /// // encode(0, &input, &mut output[..output_len]); /// ``` pub fn encode(ver: u8, input: &[u8], output: &mut [u8]) { - let mut d = [0u8; 1 + MAX_PAYLOAD_LEN + 2]; + let mut d = [0u8; 1 + typ::MAX_PAYLOAD_LEN + 2]; d[0] = ver; d[1..=input.len()].copy_from_slice(input); let crc = checksum(&d[..=input.len()]); @@ -66,16 +57,43 @@ pub fn decode_len(input_len: usize) -> Result { let len = data_encoding::BASE32_NOPAD .decode_len(input_len) .map_err(|_| DecodeError::Invalid)?; - if len < 3 || len > 1 + MAX_PAYLOAD_LEN + 2 { + if len < 3 || len > 1 + typ::MAX_PAYLOAD_LEN + 2 { return Err(DecodeError::Invalid); } - Ok(len - 3) // remove version byte and crc length + Ok(len - 1 - 2) // len - ver - crc } +/// Decode the strkey to raw data. +/// +/// # Arguments +/// +/// * `input` - The encoded strkey. +/// * `output` - The raw data. We assume it is the correct size, and you can get the correct size by calling [decode_len]. +/// +/// # Returns +/// +/// The version byte. +/// +/// # Errors +/// +/// This function will return an error if the strkey is invalid. +/// +/// # Panics +/// +/// This function will panic if the output buffer is not the correct size. +/// +/// # Examples +/// +/// ```rust +/// let mut output = [0u8; 100]; +/// let input = "GA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQHES5".as_bytes(); +/// // let output_len = decode_len(input.len()).unwrap(); +/// // let v = decode(input, &mut output[..output_len]).unwrap(); +/// ``` pub fn decode(input: &[u8], output: &mut [u8]) -> Result { let len = decode_len(input.len())? + 3; assert_eq!(output.len(), len - 3); - let mut decoded = [0u8; 1 + MAX_PAYLOAD_LEN + 2]; + let mut decoded = [0u8; 1 + typ::MAX_PAYLOAD_LEN + 2]; let _ = data_encoding::BASE32_NOPAD .decode_mut(input, &mut decoded[..len]) .map_err(|_| DecodeError::Invalid)?; diff --git a/src/ed25519.rs b/src/ed25519.rs index 4dab617..2b8810a 100644 --- a/src/ed25519.rs +++ b/src/ed25519.rs @@ -1,7 +1,7 @@ use crate::{ convert::{decode, encode}, error::DecodeError, - version, + typ, version, }; use crate::convert::encode_len; @@ -13,7 +13,7 @@ use alloc::string::String; use core::fmt::Display; #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct PrivateKey(pub [u8; 32]); +pub struct PrivateKey(pub [u8; typ::RAW_PRIVATE_KEY_LEN]); impl Debug for PrivateKey { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -29,25 +29,38 @@ impl Debug for PrivateKey { impl PrivateKey { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 56]; + let mut output = [0; typ::ENCODED_PRIVATE_KEY_LEN]; self.to_encoded(&mut output); String::from_utf8(output.to_vec()).unwrap() } + /// Returns the length of the encoded [PrivateKey]. + /// + /// # Note + /// + /// The encoded [PrivateKey] length is always [`typ::ENCODED_PRIVATE_KEY_LEN`] bytes. pub fn encoded_len(&self) -> usize { - 56 + typ::ENCODED_PRIVATE_KEY_LEN } - /// Encodes the private key into the provided buffer. + /// Encodes the [PrivateKey] into the provided buffer. /// - /// ### Panics + /// # Panics /// - /// If the buffer's length is not equal to the encoded private key length, - /// which is 56 bytes. + /// If the output buffer's length is not equal to the encoded [PrivateKey] length. pub fn to_encoded(&self, output: &mut [u8]) { encode(version::PRIVATE_KEY_ED25519, &self.0, output); } + /// Creates a [PrivateKey] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [PrivateKey]. pub fn from_payload(payload: &[u8]) -> Result { match payload.try_into() { Ok(ed25519) => Ok(Self(ed25519)), @@ -55,8 +68,17 @@ impl PrivateKey { } } + /// Creates a [PrivateKey] from the strkey encoded [PrivateKey]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [PrivateKey]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [PrivateKey]. pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 32]; + let mut payload = [0u8; typ::RAW_PRIVATE_KEY_LEN]; let ver = decode(s.as_bytes(), &mut payload)?; match ver { version::PRIVATE_KEY_ED25519 => Self::from_payload(&payload), @@ -81,7 +103,7 @@ impl FromStr for PrivateKey { } #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct PublicKey(pub [u8; 32]); +pub struct PublicKey(pub [u8; typ::RAW_PUBLIC_KEY_LEN]); impl Debug for PublicKey { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -97,25 +119,38 @@ impl Debug for PublicKey { impl PublicKey { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 56]; + let mut output = [0; typ::ENCODED_PUBLIC_KEY_LEN]; self.to_encoded(&mut output); String::from_utf8(output.to_vec()).unwrap() } + /// Returns the length of the encoded [PublicKey]. + /// + /// # Note + /// + /// The encoded [PublicKey] length is always [`typ::PUBLIC_KEY_ED25519`] bytes. pub fn encoded_len(&self) -> usize { - 56 + typ::ENCODED_PUBLIC_KEY_LEN } - /// Encodes the public key into the provided buffer. + /// Encodes the [PublicKey] into the provided buffer. /// - /// ### Panics + /// # Panics /// - /// If the buffer's length is not equal to the encoded public key length, - /// which is 56 bytes. + /// If the output buffer's length is not equal to the encoded private key length. pub fn to_encoded(&self, output: &mut [u8]) { encode(version::PUBLIC_KEY_ED25519, &self.0, output); } + /// Creates a [PublicKey] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [PublicKey]. pub fn from_payload(payload: &[u8]) -> Result { match payload.try_into() { Ok(ed25519) => Ok(Self(ed25519)), @@ -123,8 +158,17 @@ impl PublicKey { } } + /// Creates a [PublicKey] from the strkey encoded [PublicKey]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [PublicKey]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [PublicKey]. pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 32]; + let mut payload = [0u8; typ::RAW_PUBLIC_KEY_LEN]; let ver = decode(s.as_bytes(), &mut payload)?; match ver { @@ -151,7 +195,7 @@ impl FromStr for PublicKey { #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct MuxedAccount { - pub ed25519: [u8; 32], + pub ed25519: [u8; typ::RAW_PUBLIC_KEY_LEN], pub id: u64, } @@ -177,29 +221,42 @@ impl Debug for MuxedAccount { impl MuxedAccount { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 69]; + let mut output = [0; typ::ENCODED_MUXED_ACCOUNT_LEN]; self.to_encoded(&mut output); String::from_utf8(output.to_vec()).unwrap() } + /// Returns the length of the encoded [MuxedAccount]. + /// + /// # Note + /// + /// The encoded [MuxedAccount] length is always [`typ::ENCODED_MUXED_ACCOUNT_LEN`] bytes. pub fn encoded_len(&self) -> usize { - 69 + typ::ENCODED_MUXED_ACCOUNT_LEN } - /// Encodes the muxed account into the provided buffer. + /// Encodes the [MuxedAccount] into the provided buffer. /// - /// ### Panics + /// # Panics /// - /// If the buffer's length is not equal to the encoded muxed account length, - /// which is 69 bytes. + /// If the output buffer's length is not equal to the encoded [MuxedAccount] length. pub fn to_encoded(&self, output: &mut [u8]) { - let mut payload: [u8; 40] = [0; 40]; + let mut payload = [0u8; typ::RAW_MUXED_ACCOUNT_LEN]; let (ed25519, id) = payload.split_at_mut(32); ed25519.copy_from_slice(&self.ed25519); id.copy_from_slice(&self.id.to_be_bytes()); encode(version::MUXED_ACCOUNT_ED25519, &payload, output); } + /// Creates a [MuxedAccount] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [MuxedAccount]. pub fn from_payload(payload: &[u8]) -> Result { if payload.len() < 40 { return Err(DecodeError::Invalid); @@ -211,8 +268,17 @@ impl MuxedAccount { }) } + /// Creates a [MuxedAccount] from the strkey encoded [MuxedAccount]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [MuxedAccount]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [MuxedAccount]. pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 40]; + let mut payload = [0u8; typ::RAW_MUXED_ACCOUNT_LEN]; let ver = decode(s.as_bytes(), &mut payload)?; match ver { version::MUXED_ACCOUNT_ED25519 => Self::from_payload(&payload), @@ -241,7 +307,7 @@ impl FromStr for MuxedAccount { /// The payload must not have a size larger than u32::MAX. #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct SignedPayload { - pub ed25519: [u8; 32], + pub ed25519: [u8; typ::RAW_PUBLIC_KEY_LEN], pub payload: [u8; 64], pub payload_len: usize, } @@ -267,23 +333,30 @@ impl SignedPayload { /// Returns the strkey string for the signed payload signer. #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 165]; + let mut output = [0; typ::ENCODED_SIGNED_PAYLOAD_MAX_LEN]; let encoded_len = self.encoded_len(); self.to_encoded(&mut output[..encoded_len]); String::from_utf8(output[..encoded_len].to_vec()).unwrap() } + /// Returns the length of the encoded [SignedPayload]. + /// + /// # Note + /// + /// The encoded [SignedPayload] length is between [`typ::ENCODED_SIGNED_PAYLOAD_MIN_LEN`] + /// and [`typ::ENCODED_SIGNED_PAYLOAD_MAX_LEN`] bytes. pub fn encoded_len(&self) -> usize { let inner_payload_len = self.payload_len + (4 - self.payload_len % 4) % 4; encode_len(32 + 4 + inner_payload_len) } - /// Encodes the signed payload into the provided buffer. + /// Encodes the [SignedPayload] into the provided buffer. + /// + /// # Panics /// - /// ### Panics - /// TODO + /// If the output buffer's length is not equal to the encoded [SignedPayload] length. pub fn to_encoded(&self, output: &mut [u8]) { - let mut payload = [0u8; 32 + 4 + 64]; + let mut payload = [0u8; typ::RAW_SIGNED_PAYLOAD_MAX_LEN]; let inner_payload_len = self.payload_len + (4 - self.payload_len % 4) % 4; payload[..32].copy_from_slice(&self.ed25519); payload[32..32 + 4].copy_from_slice(&(self.payload_len as u32).to_be_bytes()); @@ -295,6 +368,15 @@ impl SignedPayload { ); } + /// Creates a [SignedPayload] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [SignedPayload]. pub fn from_payload(payload: &[u8]) -> Result { // 32-byte for the signer, 4-byte for the payload size, then either 4-byte for the // min or 64-byte for the max payload @@ -367,6 +449,15 @@ impl SignedPayload { }) } + /// Creates a [SignedPayload] from the strkey encoded [SignedPayload]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [SignedPayload]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [SignedPayload]. pub fn from_string(s: &str) -> Result { let mut payload = [0u8; 100]; let ver = decode(s.as_bytes(), &mut payload)?; diff --git a/src/strkey.rs b/src/strkey.rs index 59edefb..b9f0dee 100644 --- a/src/strkey.rs +++ b/src/strkey.rs @@ -10,7 +10,7 @@ use crate::{ convert::{decode, encode}, ed25519, error::DecodeError, - version, + typ, version, }; #[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)] @@ -24,6 +24,15 @@ pub enum Strkey { Contract(Contract), } +// TODO: add a trait? +// pub trait StrkeyTrait: Sized + Debug { +// #[cfg(feature = "alloc")] +// fn to_string(&self) -> String; +// fn to_encoded(&self, output: &mut [u8]); +// fn encoded_len(&self) -> usize; +// fn from_string(s: &str) -> Result; +// } + impl Strkey { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { @@ -63,7 +72,7 @@ impl Strkey { } pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 100]; + let mut payload = [0u8; typ::MAX_PAYLOAD_LEN]; let len = decode_len(s.len())?; let mut payload = &mut payload[..len]; let ver = decode(s.as_bytes(), &mut payload)?; @@ -105,7 +114,7 @@ impl FromStr for Strkey { } #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct PreAuthTx(pub [u8; 32]); +pub struct PreAuthTx(pub [u8; typ::RAW_PRE_AUTH_TX_LEN]); impl Debug for PreAuthTx { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -122,25 +131,53 @@ impl Debug for PreAuthTx { impl PreAuthTx { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 56]; + let mut output = [0; typ::ENCODED_PRE_AUTH_TX_LEN]; self.to_encoded(&mut output); String::from_utf8(output.to_vec()).unwrap() } + /// Returns the length of the encoded [PreAuthTx]. + /// + /// # Note + /// + /// The encoded [PreAuthTx] length is always [`typ::ENCODED_PRE_AUTH_TX_LEN`] bytes. pub fn encoded_len(&self) -> usize { - 56 + typ::ENCODED_PRE_AUTH_TX_LEN } + /// Encodes the [PreAuthTx] into the provided buffer. + /// + /// # Panics + /// + /// If the output buffer's length is not equal to the encoded [PreAuthTx] length. pub fn to_encoded(&self, output: &mut [u8]) { encode(version::PRE_AUTH_TX, &self.0, output); } + /// Creates a [PreAuthTx] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [PreAuthTx]. fn from_payload(payload: &[u8]) -> Result { Ok(Self(payload.try_into().map_err(|_| DecodeError::Invalid)?)) } + /// Creates a [PreAuthTx] from the strkey encoded [PreAuthTx]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [PreAuthTx]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [PreAuthTx]. pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 32]; + let mut payload = [0u8; typ::RAW_PRE_AUTH_TX_LEN]; let ver = decode(s.as_bytes(), &mut payload)?; match ver { version::PRE_AUTH_TX => Self::from_payload(&payload), @@ -165,7 +202,7 @@ impl FromStr for PreAuthTx { } #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct HashX(pub [u8; 32]); +pub struct HashX(pub [u8; typ::RAW_HASH_X_LEN]); impl Debug for HashX { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -182,25 +219,53 @@ impl Debug for HashX { impl HashX { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 56]; + let mut output = [0; typ::ENCODED_HASH_X_LEN]; self.to_encoded(&mut output); String::from_utf8(output.to_vec()).unwrap() } + /// Returns the length of the encoded [HashX]. + /// + /// # Note + /// + /// The encoded [HashX] length is always [`typ::ENCODED_HASH_X_LEN`] bytes. pub fn encoded_len(&self) -> usize { - 56 + typ::ENCODED_HASH_X_LEN } + /// Encodes the [HashX] into the provided buffer. + /// + /// # Panics + /// + /// If the output buffer's length is not equal to the encoded [HashX] length. pub fn to_encoded(&self, output: &mut [u8]) { encode(version::HASH_X, &self.0, output); } + /// Creates a [HashX] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [HashX]. fn from_payload(payload: &[u8]) -> Result { Ok(Self(payload.try_into().map_err(|_| DecodeError::Invalid)?)) } + /// Creates a [HashX] from the strkey encoded [HashX]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [HashX]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [HashX]. pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 32]; + let mut payload = [0u8; typ::RAW_HASH_X_LEN]; let ver = decode(s.as_bytes(), &mut payload)?; match ver { version::HASH_X => Self::from_payload(&payload), @@ -225,7 +290,7 @@ impl FromStr for HashX { } #[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct Contract(pub [u8; 32]); +pub struct Contract(pub [u8; typ::RAW_CONTRACT_LEN]); impl Debug for Contract { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { @@ -241,25 +306,53 @@ impl Debug for Contract { impl Contract { #[cfg(feature = "alloc")] pub fn to_string(&self) -> String { - let mut output = [0; 56]; + let mut output = [0; typ::ENCODED_CONTRACT_LEN]; self.to_encoded(&mut output); String::from_utf8(output.to_vec()).unwrap() } + /// Returns the length of the encoded [Contract]. + /// + /// # Note + /// + /// The encoded [Contract] length is always [`typ::ENCODED_CONTRACT_LEN`] bytes. pub fn encoded_len(&self) -> usize { - 56 + typ::ENCODED_CONTRACT_LEN } + /// Encodes the [Contract] into the provided buffer. + /// + /// # Panics + /// + /// If the output buffer's length is not equal to the encoded [Contract] length. pub fn to_encoded(&self, output: &mut [u8]) { encode(version::CONTRACT, &self.0, output); } + /// Creates a [Contract] from the raw payload. + /// + /// # Arguments + /// + /// * `payload` - The raw payload. + /// + /// # Errors + /// + /// Returns an error if the payload is not a valid [Contract]. fn from_payload(payload: &[u8]) -> Result { Ok(Self(payload.try_into().map_err(|_| DecodeError::Invalid)?)) } + /// Creates a [Contract] from the strkey encoded [Contract]. + /// + /// # Arguments + /// + /// * `s` - The strkey encoded [Contract]. + /// + /// # Errors + /// + /// Returns an error if the strkey is not a valid [Contract]. pub fn from_string(s: &str) -> Result { - let mut payload = [0u8; 32]; + let mut payload = [0u8; typ::RAW_CONTRACT_LEN]; let ver = decode(s.as_bytes(), &mut payload)?; match ver { version::CONTRACT => Self::from_payload(&payload), diff --git a/src/typ.rs b/src/typ.rs index 3013900..7e814e5 100644 --- a/src/typ.rs +++ b/src/typ.rs @@ -9,3 +9,27 @@ pub const CONTRACT: u8 = 2 << 3; pub mod public_key_alg { pub const ED25519: u8 = 0; } + +pub const ENCODED_PUBLIC_KEY_LEN: usize = 56; +pub const ENCODED_PRIVATE_KEY_LEN: usize = 56; +pub const ENCODED_MUXED_ACCOUNT_LEN: usize = 69; +pub const ENCODED_PRE_AUTH_TX_LEN: usize = 56; +pub const ENCODED_HASH_X_LEN: usize = 56; +#[allow(dead_code)] +pub const ENCODED_SIGNED_PAYLOAD_MIN_LEN: usize = 69; +#[allow(dead_code)] +pub const ENCODED_SIGNED_PAYLOAD_MAX_LEN: usize = 165; +pub const ENCODED_CONTRACT_LEN: usize = 56; + +pub const RAW_PUBLIC_KEY_LEN: usize = 32; +pub const RAW_PRIVATE_KEY_LEN: usize = 32; +pub const RAW_MUXED_ACCOUNT_LEN: usize = 40; // MuxedAccountEd25519 +pub const RAW_PRE_AUTH_TX_LEN: usize = 32; +pub const RAW_HASH_X_LEN: usize = 32; +#[allow(dead_code)] +pub const RAW_SIGNED_PAYLOAD_MIN_LEN: usize = 40; // 32 + 4 + 4 = 40-bytes +pub const RAW_SIGNED_PAYLOAD_MAX_LEN: usize = 100; // 32 + 4 + 64 = 100-bytes +pub const RAW_CONTRACT_LEN: usize = 32; + +// TODO: is OK to put this here? +pub(crate) const MAX_PAYLOAD_LEN: usize = RAW_SIGNED_PAYLOAD_MAX_LEN; diff --git a/tests/tests.rs b/tests/tests.rs index 8f5bc49..48dba32 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -7,10 +7,7 @@ use proptest::proptest; use stellar_strkey::*; #[cfg(feature = "alloc")] -use alloc::{ - format, - string::String, -}; +use alloc::{format, string::String}; #[test] fn test_valid_public_keys() {