Skip to main content

Payment

Struct Payment 

Source
pub struct Payment {
Show 13 fields pub kappa: G2Projective, pub kappa_e: G2Projective, pub sig: Signature, pub sig_exp: Signature, pub kappa_k: Vec<G2Projective>, pub omega: Vec<Signature>, pub ss: Vec<G1Projective>, pub tt: Vec<G1Projective>, pub aa: Vec<G1Projective>, pub spend_value: u64, pub cc: G1Projective, pub t_type: u8, pub zk_proof: SpendProof,
}

Fields§

§kappa: G2Projective§kappa_e: G2Projective§sig: Signature§sig_exp: Signature§kappa_k: Vec<G2Projective>§omega: Vec<Signature>§ss: Vec<G1Projective>§tt: Vec<G1Projective>§aa: Vec<G1Projective>§spend_value: u64§cc: G1Projective§t_type: u8§zk_proof: SpendProof

Implementations§

Source§

impl Payment

Source

pub fn check_signature_validity( &self, verification_key: &VerificationKeyAuth, ) -> Result<(), CompactEcashError>

Checks the validity of the payment signature.

This function performs two checks to ensure the payment signature is valid:

  • Verifies that the element h of the payment signature does not equal the identity.
  • Performs a bilinear pairing check involving the elements of the signature and the payment (h, kappa, and s).
§Arguments
  • params - A reference to the system parameters required for the checks.
§Returns

A Result indicating success if the signature is valid or an error if any check fails.

§Errors

An error is returned if:

  • The element h of the payment signature equals the identity.
  • The bilinear pairing check for kappa fails.
Source

pub fn check_exp_signature_validity( &self, verification_key: &VerificationKeyAuth, spend_date: Scalar, ) -> Result<(), CompactEcashError>

Checks the validity of the expiration signature encoded in the payment given a spending date. If the spending date is within the allowed range before the expiration date, the check is successful.

This function performs two checks to ensure the payment expiration signature is valid:

  • Verifies that the element h of the expiration signature does not equal the identity.
  • Performs a bilinear pairing check involving the elements of the expiration signature and the payment (h, kappa_e, and s).
§Arguments
  • verification_key - The global verification key of the signing authorities.
  • spend_date - The date associated with the payment.
§Returns

A Result indicating success if the expiration signature is valid or an error if any check fails.

§Errors

An error is returned if:

  • The element h of the payment expiration signature equals the identity.
  • The bilinear pairing check for kappa_e fails.
Source

pub fn no_duplicate_serial_numbers(&self) -> Result<(), CompactEcashError>

Checks that all serial numbers in the payment are unique.

This function verifies that each serial number in the payment’s serial number array (ss) is unique.

§Returns

A Result indicating success if all serial numbers are unique or an error if any serial number is duplicated.

§Errors

An error is returned if not all serial numbers in the payment are unique.

Source

pub fn batch_check_coin_index_signatures( &self, verification_key: &VerificationKeyAuth, ) -> Result<(), CompactEcashError>

Checks the validity of all coin index signatures available.

Source

pub fn verify_spend_proof( &self, verification_key: &VerificationKeyAuth, pay_info: &PayInfo, ) -> Result<(), CompactEcashError>

Checks the validity of the attached zk proof of spending.

Source

pub fn spend_verify( &self, verification_key: &VerificationKeyAuth, pay_info: &PayInfo, spend_date: u32, ) -> Result<(), CompactEcashError>

Verifies the validity of a spend transaction, including signature checks, expiration date signature checks, serial number uniqueness, coin index signature checks, and zero-knowledge proof verification.

§Arguments
  • params - The cryptographic parameters.
  • verification_key - The verification key used for validation.
  • pay_info - The pay information associated with the transaction.
  • spend_date - The date at which the spending transaction occurs.
§Returns

Returns Ok(true) if the spend transaction is valid; otherwise, returns an error.

Source

pub fn encoded_serial_number(&self) -> Vec<u8>

Source

pub fn serial_number_bs58(&self) -> String

Source§

impl Payment

Source

pub fn to_bytes(&self) -> Vec<u8>

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Payment, CompactEcashError>

Trait Implementations§

Source§

impl Base58 for Payment

Source§

fn try_from_bs58<S>(x: S) -> Result<Self, CompactEcashError>
where S: AsRef<str>,

Source§

fn to_bs58(&self) -> String

Source§

impl Bytable for Payment

Source§

impl Clone for Payment

Source§

fn clone(&self) -> Payment

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Payment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Payment

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Payment, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Payment

Source§

fn eq(&self, other: &Payment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Payment

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&[u8]> for Payment

Source§

type Error = CompactEcashError

The type returned in the event of a conversion error.
Source§

fn try_from(bytes: &[u8]) -> Result<Payment, CompactEcashError>

Performs the conversion.
Source§

impl StructuralPartialEq for Payment

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,