mirror of
https://github.com/zerotier/identity.git
synced 2026-05-22 16:29:03 -07:00
improved prefixes
This commit is contained in:
+2
-2
@@ -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)]
|
||||
|
||||
@@ -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
@@ -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);
|
||||
|
||||
@@ -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] {
|
||||
|
||||
Reference in New Issue
Block a user