pub struct WalletSignatures { /* private fields */ }Expand description
The struct represents a wallet with essential components for a payment transaction.
A Wallet includes a Pointcheval-Sanders signature (sig),
a scalar value (v) representing the wallet’s secret, an optional
an expiration date (expiration_date)
and an u64 (‘l’) indicating the total number of spent coins.
Implementations§
Source§impl WalletSignatures
impl WalletSignatures
pub fn with_tickets_spent(self, tickets_spent: u64) -> Wallet
pub fn new_wallet(self) -> Wallet
pub fn encoded_expiration_date(&self) -> Scalar
Source§impl WalletSignatures
impl WalletSignatures
pub const SERIALISED_SIZE: usize = 133
pub fn signature(&self) -> &Signature
Sourcepub fn to_bytes(&self) -> [u8; 133]
pub fn to_bytes(&self) -> [u8; 133]
Converts the WalletSignatures to a fixed-size byte array.
The resulting byte array has a length of 168 bytes and contains serialized
representations of the Signature (sig), scalar value (v), and
expiration date (expiration_date) fields of the WalletSignatures struct.
§Returns
A fixed-size byte array ([u8; 136]) representing the serialized form of the Wallet.
pub fn from_bytes(bytes: &[u8]) -> Result<WalletSignatures, CompactEcashError>
Sourcepub fn spend<BI, BE>(
&self,
params: &Parameters,
verification_key: &VerificationKeyAuth,
sk_user: &SecretKeyUser,
pay_info: &PayInfo,
current_tickets_spent: u64,
spend_value: u64,
valid_dates_signatures: &[BE],
coin_indices_signatures: &[BI],
spend_date_timestamp: u32,
) -> Result<Payment, CompactEcashError>
pub fn spend<BI, BE>( &self, params: &Parameters, verification_key: &VerificationKeyAuth, sk_user: &SecretKeyUser, pay_info: &PayInfo, current_tickets_spent: u64, spend_value: u64, valid_dates_signatures: &[BE], coin_indices_signatures: &[BI], spend_date_timestamp: u32, ) -> Result<Payment, CompactEcashError>
Performs a spending operation with the given parameters, updating the wallet and generating a payment.
§Arguments
verification_key- The global verification key.sk_user- The secret key of the user who wants to spend from their wallet.pay_info- Unique information related to the payment.current_tickets_spent- The total number of tickets already spent in the associated wallet.spend_value- The amount to spend from the wallet.valid_dates_signatures- A list of SORTED signatures on valid dates during which we can spend from the wallet.coin_indices_signatures- A list of SORTED signatures on coin indices.spend_date- The date on which the spending occurs, expressed as unix timestamp.
§Returns
A tuple containing the generated payment and a reference to the updated wallet, or an error.
Trait Implementations§
Source§impl Base58 for WalletSignatures
impl Base58 for WalletSignatures
Source§impl Bytable for WalletSignatures
impl Bytable for WalletSignatures
fn to_byte_vec(&self) -> Vec<u8> ⓘ
fn try_from_byte_slice( slice: &[u8], ) -> Result<WalletSignatures, CompactEcashError>
Source§impl Clone for WalletSignatures
impl Clone for WalletSignatures
Source§fn clone(&self) -> WalletSignatures
fn clone(&self) -> WalletSignatures
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WalletSignatures
impl Debug for WalletSignatures
Source§impl<'de> Deserialize<'de> for WalletSignatures
impl<'de> Deserialize<'de> for WalletSignatures
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<WalletSignatures, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<WalletSignatures, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Drop for WalletSignatures
impl Drop for WalletSignatures
Source§impl From<Wallet> for WalletSignatures
impl From<Wallet> for WalletSignatures
Source§fn from(value: Wallet) -> WalletSignatures
fn from(value: Wallet) -> WalletSignatures
Source§impl PartialEq for WalletSignatures
impl PartialEq for WalletSignatures
Source§impl Serialize for WalletSignatures
impl Serialize for WalletSignatures
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,
Source§impl TryFrom<&[u8]> for WalletSignatures
impl TryFrom<&[u8]> for WalletSignatures
Source§type Error = CompactEcashError
type Error = CompactEcashError
Source§fn try_from(bytes: &[u8]) -> Result<WalletSignatures, CompactEcashError>
fn try_from(bytes: &[u8]) -> Result<WalletSignatures, CompactEcashError>
Source§impl Zeroize for WalletSignatures
impl Zeroize for WalletSignatures
impl StructuralPartialEq for WalletSignatures
Auto Trait Implementations§
impl Freeze for WalletSignatures
impl RefUnwindSafe for WalletSignatures
impl Send for WalletSignatures
impl Sync for WalletSignatures
impl Unpin for WalletSignatures
impl UnsafeUnpin for WalletSignatures
impl UnwindSafe for WalletSignatures
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<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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more