xand_ledger/model/sends.rs
1use crate::{
2 transactions::PublicInputSet, Encrypted, IdentityTag, KeyImage, Proof, TransactionOutput,
3 TransactionResult, VerifiableEncryptionOfSignerKey,
4};
5use alloc::vec::Vec;
6use curve25519_dalek::ristretto::RistrettoPoint;
7use serde::{Deserialize, Serialize};
8use zkplmt::bulletproofs::BulletRangeProof;
9
10/// The CoreTransaction contains all the details of a Transaction except the signature and proof. A
11/// serialized version of the CoreTransaction is then signed as part of the main proof. A
12/// Transaction contains a CoreTransaction and a proof cum signature.
13#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
14#[allow(non_snake_case)]
15pub struct CoreSendClaimsTransaction {
16 /// A list of lists of transaction outputs where only one of the lists of outputs is the real
17 /// one being used.
18 pub input: Vec<PublicInputSet>,
19
20 /// The set of output UTxOs. All of them are real. The sum of all the TransactionOutput(s) is
21 /// the value Of the transaction.
22 pub output: Vec<SendClaimsOutput>,
23
24 /// A new identity output key that can be used by the same member who issued this transaction
25 /// for subsequent transactions.
26 pub output_identity: IdentityTag,
27
28 /// key-images are nullifiers or the TransactionOutput(s). There is only a unique key-image for
29 /// every TransactionOutput, but the key-image cannot be efficiently matched with the
30 /// corresponding TransactionOutput by any polynomial time probabilistic algorithm with a
31 /// non-negligible probability without using the private key. If a Transaction contains a
32 /// key-image that has already been used, then the corresponding TransactionOutput has been
33 /// spent already, which means that the transaction is invalid.
34 pub key_images: Vec<KeyImage>,
35
36 /// `Z` is used to store the randomness required to obfuscate which of the input sums equals the
37 /// output sum. Without this randomness, all anonymity will be lost.
38 pub Z: RistrettoPoint,
39
40 /// A proof that Z is a Pedersen commitment to zero. It also implies that pZ is also a
41 /// commitment to zero where p is any scalar. Also proves that the all the banned member points
42 /// `Qs` share randomness with `Z`.
43 pub alpha: Proof,
44
45 /// Proof that all the output TransactionOutput(s) contain commitments to values represented by
46 /// a maximum number of bits. This is to stop the sum from rolling over to create money out of
47 /// nothing.
48 pub range_proof: BulletRangeProof,
49
50 /// The encryption of the signer's permanent public key that can be decrypted by
51 /// each receiver.
52 pub encrypted_sender: VerifiableEncryptionOfSignerKey,
53
54 /// Banned members with randomness. Order must be kept to rebuild the alpha proof.
55 pub Qs: Vec<RistrettoPoint>,
56}
57
58/// Transfer TxO and associated data
59#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
60pub struct SendClaimsOutput {
61 pub txo: TransactionOutput,
62 /// Currently contains commitment inputs encrypted by the issuer for the recipient
63 pub encrypted_metadata: Encrypted,
64}
65
66/// A send claims transaction representing the transfer of value from one registered member to another
67#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
68pub struct SendClaimsTransaction {
69 /// Contains all the details of a Transaction other than the proof with signature.
70 pub core_transaction: CoreSendClaimsTransaction,
71
72 ///pi is the proof with signature
73 pub pi: Proof,
74}
75
76/// Implementors are capable of processing send claims transactions
77pub trait SendClaimsHandler {
78 /// Process and validate an incoming send claims transaction
79 fn send_claims(&self, transaction: SendClaimsTransaction) -> TransactionResult;
80}