Skip to main content

encode_v0

Function encode_v0 

Source
pub fn encode_v0(client_key: &[u8; 32], psk: &[u8; 32]) -> String
Expand description

Encodes a version-0 pairing token: client_key || pairing_psk as base32.

client_key is the raw 32-byte Curve25519 public key whose base64url form is the client’s client_id; psk is the client’s pairing PSK. The two must be the pair the client actually uses, because a server selects and verifies the client’s Noise identity from them.

§Example

use syncspin_core::pairing::token::encode_v0;

// The spec's reference vector: client_key 0x00..=0x1f, pairing_psk 0xe0..=0xff.
let client_key = std::array::from_fn(|index| index as u8);
let psk = std::array::from_fn(|index| 0xe0 + index as u8);
assert_eq!(
    encode_v0(&client_key, &psk),
    "SP:0AAAQEAYEAUDAOCAJBIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYP6BYPC4PSOLZXH5DU6V97M5XXO74HR6LZ7J5PW674PT6X37T6757Y"
);