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,
input_fee_ppk: u64,
expiry: Option<u64>,
) -> Id
pub fn v2_from_data( map: &Keys, unit: &CurrencyUnit, input_fee_ppk: u64, 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
§Panics
This function will not panic under normal circumstances as the hash output is always valid hex and the correct length.
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
§Panics
This function will not panic under normal circumstances as the hash output is always valid hex and the correct length.
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Id
impl<'de> Deserialize<'de> for Id
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Id, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Id, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<Id> for ShortKeysetId
impl From<Id> for ShortKeysetId
Source§fn from(id: Id) -> ShortKeysetId
fn from(id: Id) -> ShortKeysetId
Source§impl From<MintKeySet> for Id
Available on crate feature mint only.
impl From<MintKeySet> for Id
mint only.Source§fn from(keyset: MintKeySet) -> Id
fn from(keyset: MintKeySet) -> Id
Source§impl Ord for Id
impl Ord for Id
Source§impl PartialOrd for Id
impl PartialOrd for Id
Source§impl Serialize for Id
impl Serialize for Id
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Id
impl Eq for Id
impl StructuralPartialEq for Id
Auto Trait Implementations§
impl Freeze for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnsafeUnpin for Id
impl UnwindSafe for Id
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.