solana_zk_token_sdk/instruction/
mod.rs

1//! The instruction data types for the [`ZK Token proof`] instruction.
2//!
3//! [`ZK Token proof`]: https://docs.solanalabs.com/runtime/zk-token-proof
4
5pub mod batched_grouped_ciphertext_validity;
6pub mod batched_range_proof;
7pub mod ciphertext_ciphertext_equality;
8pub mod ciphertext_commitment_equality;
9pub mod errors;
10pub mod fee_sigma;
11pub mod grouped_ciphertext_validity;
12pub mod pubkey_validity;
13pub mod range_proof;
14pub mod transfer;
15pub mod withdraw;
16pub mod zero_balance;
17
18#[cfg(not(target_os = "solana"))]
19use crate::errors::ProofVerificationError;
20use num_derive::{FromPrimitive, ToPrimitive};
21pub use {
22    batched_grouped_ciphertext_validity::{
23        BatchedGroupedCiphertext2HandlesValidityProofContext,
24        BatchedGroupedCiphertext2HandlesValidityProofData,
25        BatchedGroupedCiphertext3HandlesValidityProofContext,
26        BatchedGroupedCiphertext3HandlesValidityProofData,
27    },
28    batched_range_proof::{
29        batched_range_proof_u128::BatchedRangeProofU128Data,
30        batched_range_proof_u256::BatchedRangeProofU256Data,
31        batched_range_proof_u64::BatchedRangeProofU64Data, BatchedRangeProofContext,
32    },
33    bytemuck::Pod,
34    ciphertext_ciphertext_equality::{
35        CiphertextCiphertextEqualityProofContext, CiphertextCiphertextEqualityProofData,
36    },
37    ciphertext_commitment_equality::{
38        CiphertextCommitmentEqualityProofContext, CiphertextCommitmentEqualityProofData,
39    },
40    fee_sigma::{FeeSigmaProofContext, FeeSigmaProofData},
41    grouped_ciphertext_validity::{
42        GroupedCiphertext2HandlesValidityProofContext, GroupedCiphertext2HandlesValidityProofData,
43        GroupedCiphertext3HandlesValidityProofContext, GroupedCiphertext3HandlesValidityProofData,
44    },
45    pubkey_validity::{PubkeyValidityData, PubkeyValidityProofContext},
46    range_proof::{RangeProofContext, RangeProofU64Data},
47    transfer::{
48        FeeParameters, TransferData, TransferProofContext, TransferWithFeeData,
49        TransferWithFeeProofContext,
50    },
51    withdraw::{WithdrawData, WithdrawProofContext},
52    zero_balance::{ZeroBalanceProofContext, ZeroBalanceProofData},
53};
54
55#[derive(Clone, Copy, Debug, FromPrimitive, ToPrimitive, PartialEq, Eq)]
56#[repr(u8)]
57pub enum ProofType {
58    /// Empty proof type used to distinguish if a proof context account is initialized
59    Uninitialized,
60    ZeroBalance,
61    Withdraw,
62    CiphertextCiphertextEquality,
63    Transfer,
64    TransferWithFee,
65    PubkeyValidity,
66    RangeProofU64,
67    BatchedRangeProofU64,
68    BatchedRangeProofU128,
69    BatchedRangeProofU256,
70    CiphertextCommitmentEquality,
71    GroupedCiphertext2HandlesValidity,
72    BatchedGroupedCiphertext2HandlesValidity,
73    FeeSigma,
74    GroupedCiphertext3HandlesValidity,
75    BatchedGroupedCiphertext3HandlesValidity,
76}
77
78pub trait ZkProofData<T: Pod> {
79    const PROOF_TYPE: ProofType;
80
81    fn context_data(&self) -> &T;
82
83    #[cfg(not(target_os = "solana"))]
84    fn verify_proof(&self) -> Result<(), ProofVerificationError>;
85}