spl_token_confidential_transfer_proof_extraction/
encryption.rs

1use {
2    crate::errors::TokenProofExtractionError,
3    solana_zk_sdk::encryption::pod::{
4        elgamal::PodElGamalCiphertext,
5        grouped_elgamal::{
6            PodGroupedElGamalCiphertext2Handles, PodGroupedElGamalCiphertext3Handles,
7        },
8    },
9};
10
11#[derive(Clone, Copy, Debug, Eq, PartialEq)]
12#[repr(C)]
13pub struct PodTransferAmountCiphertext(pub(crate) PodGroupedElGamalCiphertext3Handles);
14
15impl PodTransferAmountCiphertext {
16    pub fn try_extract_ciphertext(
17        &self,
18        index: usize,
19    ) -> Result<PodElGamalCiphertext, TokenProofExtractionError> {
20        self.0
21            .try_extract_ciphertext(index)
22            .map_err(|_| TokenProofExtractionError::CiphertextExtraction)
23    }
24}
25
26#[derive(Clone, Copy, Debug, Eq, PartialEq)]
27#[repr(C)]
28pub struct PodFeeCiphertext(pub(crate) PodGroupedElGamalCiphertext2Handles);
29
30impl PodFeeCiphertext {
31    pub fn try_extract_ciphertext(
32        &self,
33        index: usize,
34    ) -> Result<PodElGamalCiphertext, TokenProofExtractionError> {
35        self.0
36            .try_extract_ciphertext(index)
37            .map_err(|_| TokenProofExtractionError::CiphertextExtraction)
38    }
39}
40
41#[derive(Clone, Copy, Debug, Eq, PartialEq)]
42#[repr(C)]
43pub struct PodBurnAmountCiphertext(pub(crate) PodGroupedElGamalCiphertext3Handles);
44
45impl PodBurnAmountCiphertext {
46    pub fn try_extract_ciphertext(
47        &self,
48        index: usize,
49    ) -> Result<PodElGamalCiphertext, TokenProofExtractionError> {
50        self.0
51            .try_extract_ciphertext(index)
52            .map_err(|_| TokenProofExtractionError::CiphertextExtraction)
53    }
54}
55
56#[derive(Clone, Copy, Debug, Eq, PartialEq)]
57#[repr(C)]
58pub struct PodMintAmountCiphertext(pub(crate) PodGroupedElGamalCiphertext3Handles);
59
60impl PodMintAmountCiphertext {
61    pub fn try_extract_ciphertext(
62        &self,
63        index: usize,
64    ) -> Result<PodElGamalCiphertext, TokenProofExtractionError> {
65        self.0
66            .try_extract_ciphertext(index)
67            .map_err(|_| TokenProofExtractionError::CiphertextExtraction)
68    }
69}