Trait reef::traits::Transaction

source ·
pub trait Transaction: Clone + Debug + Serialize + DeserializeOwned + Send + Sync {
    type NullifierSet: NullifierSet;
    type Hash: Clone + Debug + Eq + Hash + Send + Sync + Serialize + DeserializeOwned + CanonicalSerialize + CanonicalDeserialize;
    type Kind: TransactionKind;

    // Required methods
    fn cap(
        note: TransactionNote,
        proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof>
    ) -> Self;
    fn open_viewing_memo(
        &self,
        viewable_assets: &HashMap<AssetCode, AssetDefinition>,
        viewing_keys: &HashMap<ViewerPubKey, ViewerKeyPair>
    ) -> Result<ViewingMemoOpening, ViewingError>;
    fn proven_nullifiers(
        &self
    ) -> Vec<(Nullifier, <Self::NullifierSet as NullifierSet>::Proof)>;
    fn output_commitments(&self) -> Vec<RecordCommitment>;
    fn hash(&self) -> Self::Hash;
    fn kind(&self) -> Self::Kind;
    fn set_proofs(
        &mut self,
        proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof>
    );

    // Provided methods
    fn output_openings(&self) -> Option<Vec<RecordOpening>> { ... }
    fn output_len(&self) -> usize { ... }
    fn input_nullifiers(&self) -> Vec<Nullifier> { ... }
}
Expand description

A CAP transaction.

A CAP transaction is an operation on the CAP ledger – it consumes a set of records, adding their nullifiers to the nullifier set, and produces a list of new records, adding their commitments to the record set. It may also contain viewing information encrypted under the viewing key of the transaction’s asset type.

The transaction may also contain information specific to a particular instantiation of CAP, such as a proof that the transaction is valid, bookkeeping related to fees and rewards, or optional plaintext record openings for the transaction outputs, in the case of a non-private type of transaction.

Regardless of the exact structure of the transaction, this interface captures the transaction’s effects on the ledger when it is executed – the exact nullifiers and record commitments which will be added to the ledger, regardless of how they are encoded in the transaction.

Required Associated Types§

source

type NullifierSet: NullifierSet

Nullifier set to be updated when a transaction is added to the ledger.

source

type Hash: Clone + Debug + Eq + Hash + Send + Sync + Serialize + DeserializeOwned + CanonicalSerialize + CanonicalDeserialize

Transaction digest.

This should be a determinstic, injective, committing function of the transaction.

source

type Kind: TransactionKind

Supported transaction types.

Required Methods§

source

fn cap( note: TransactionNote, proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof> ) -> Self

Wrap a raw CAP transaction in this network’s transaction type.

source

fn open_viewing_memo( &self, viewable_assets: &HashMap<AssetCode, AssetDefinition>, viewing_keys: &HashMap<ViewerPubKey, ViewerKeyPair> ) -> Result<ViewingMemoOpening, ViewingError>

Attempt to decrypt the attached viewing memo.

Given a collection of asset types for which the caller holds the viewing key, attempt to open the viewing memos attached to this transaction.

viewable_assets should be the set of asset types which the caller can view, indexed by asset code. This determines which asset types can be viewed by this method. viewing_keys is the caller’s collection of viewing key pairs, indexed by public key. viewing_keys must contain every public key which is listed as a viewer in the policy of one of the viewable_assets.

source

fn proven_nullifiers( &self ) -> Vec<(Nullifier, <Self::NullifierSet as NullifierSet>::Proof)>

Nullifiers for the records that this transaction will consume when executed.

The results should contain authentication that the nullifiers were unspent at the time the transaction was constructed.

source

fn output_commitments(&self) -> Vec<RecordCommitment>

Commitments to the records that this transaction will create when executed.

source

fn hash(&self) -> Self::Hash

A committing hash of this transaction.

source

fn kind(&self) -> Self::Kind

The type of this transaction.

source

fn set_proofs( &mut self, proofs: Vec<<Self::NullifierSet as NullifierSet>::Proof> )

Update the proofs that this transaction’s nullifiers are unspent.

Provided Methods§

source

fn output_openings(&self) -> Option<Vec<RecordOpening>>

If this is not a private transaction, get the openings of its output records.

The implementation must ensure that if self.output_openings().is_some(), then self.output_commitments() is a list of the commitments of each [RecordOpening] in self.output_openings().unwrap().

source

fn output_len(&self) -> usize

The number of outputs.

This is equivalent to self.output_commitments().len(), but may be more efficient in some implementations.

source

fn input_nullifiers(&self) -> Vec<Nullifier>

This transaction’s inputs, without authentication.

Implementations on Foreign Types§

source§

impl Transaction for TransactionNote

§

type NullifierSet = HashSet<ArbitraryNullifier, RandomState>

§

type Hash = Commitment<TransactionNote>

§

type Kind = TransactionKind

source§

fn cap(note: TransactionNote, _proofs: Vec<()>) -> Self

source§

fn open_viewing_memo( &self, assets: &HashMap<AssetCode, AssetDefinition>, keys: &HashMap<ViewerPubKey, ViewerKeyPair> ) -> Result<ViewingMemoOpening, ViewingError>

source§

fn proven_nullifiers(&self) -> Vec<(Nullifier, ())>

source§

fn output_commitments(&self) -> Vec<RecordCommitment>

source§

fn hash(&self) -> Self::Hash

source§

fn kind(&self) -> Self::Kind

source§

fn set_proofs(&mut self, _proofs: Vec<()>)

Implementors§