pub struct Id { /* private fields */ }
Expand description
A keyset ID is an identifier for a specific keyset. It can be derived by anyone who knows the set of public keys of a mint. The keyset ID CAN be stored in a Cashu token such that the token can be used to identify which mint or keyset it was generated from.
Implementations§
Source§impl Id
impl Id
Sourcepub fn get_version(&self) -> KeySetVersion
pub fn get_version(&self) -> KeySetVersion
Get the version of the keyset
Sourcepub fn v2_from_data(map: &Keys, unit: &CurrencyUnit, expiry: Option<u64>) -> Id
pub fn v2_from_data(map: &Keys, unit: &CurrencyUnit, expiry: Option<u64>) -> Id
*** V2 KEYSET ***
create Id
v2 from keys, unit and (optionally) expiry
1 - sort public keys by their amount in ascending order
2 - concatenate all public keys to one byte array
3 - concatenate the lowercase unit string to the byte array (e.g. “unit:sat”)
4 - If a final expiration is specified, convert it into a radix-10 string and concatenate it (e.g “final_expiry:1896187313”)
5 - HASH_SHA256 the concatenated byte array and take the first 31 bytes
6 - prefix it with a keyset ID version byte
Sourcepub fn v1_from_keys(map: &Keys) -> Id
pub fn v1_from_keys(map: &Keys) -> Id
*** V1 VERSION *** As per NUT-02:
- sort public keys by their amount in ascending order
- concatenate all public keys to one string
- HASH_SHA256 the concatenated public keys
- take the first 14 characters of the hex-encoded hash
- prefix it with a keyset ID version byte
Sourcepub fn from_short_keyset_id(
short_id: &ShortKeysetId,
keysets_info: &[KeySetInfo],
) -> Result<Id, Error>
pub fn from_short_keyset_id( short_id: &ShortKeysetId, keysets_info: &[KeySetInfo], ) -> Result<Id, Error>
Selects the correct IDv2 from a list of keysets and the given short-id or returns the short-id in the case of v1.