improved prefixes

This commit is contained in:
Monica Moniot
2024-02-28 13:50:19 -05:00
parent d905b65c50
commit daebb48841
4 changed files with 7 additions and 7 deletions
+2 -2
View File
@@ -29,9 +29,9 @@ impl Address {
pub const REQUIRED_PREFIX: u8 = 0xfc;
pub const SIZE: usize = 48;
/// Length of a full address in string format.
pub const STRING_SIZE: usize = 81;
pub const STRING_SIZE_NO_PREFIX: usize = 76;
/// Length of a full address in string format.
pub const STRING_SIZE: usize = Self::STRING_SIZE_NO_PREFIX + PREFIX_ADDRESS.len();
/// Get this address as a raw byte array.
#[inline(always)]
+1 -1
View File
@@ -30,8 +30,8 @@ pub struct Identity {
impl Identity {
pub const SIZE: usize = P384_IDENTITY_SIZE;
pub const STRING_SIZE: usize = 548;
pub const STRING_SIZE_NO_PREFIX: usize = 543;
pub const STRING_SIZE: usize = Self::STRING_SIZE_NO_PREFIX + PREFIX_IDENTITY.len();
pub fn prefix(&self) -> &ShortAddress {
self.address.prefix()
+3 -3
View File
@@ -40,9 +40,9 @@ const IDENTITY_VARIANT_P384: u8 = 1;
const DOMAIN_MASTER_SIG: &[u8] = b"ZTID1_MASTERSIG";
const DOMAIN_SUBKEY_SIG: &[u8] = b"ZTID1_SUBKEYSIG";
const PREFIX_IDENTITY: &str = "zt:i:";
const PREFIX_ADDRESS: &str = "zt:a:";
const PREFIX_SHORT: &str = "zt:s:";
const PREFIX_IDENTITY: &str = "zt:id:";
const PREFIX_ADDRESS: &str = "zt:addr:";
const PREFIX_SHORT: &str = "zt:addr:";
fn first_128_to_string(b: &[u8], s: &mut String) {
base24::encode_4to7(&b[0..4], s);
+1 -1
View File
@@ -18,8 +18,8 @@ pub struct ShortAddress(pub(crate) [u64; 2]); // treated as [u8; 16]
impl ShortAddress {
pub const SIZE: usize = 16;
pub const STRING_SIZE: usize = 36;
pub const STRING_SIZE_NO_PREFIX: usize = 31;
pub const STRING_SIZE: usize = Self::STRING_SIZE_NO_PREFIX + PREFIX_SHORT.len();
#[inline(always)]
pub fn as_bytes(&self) -> &[u8; Self::SIZE] {