1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
pub mod close_account;
pub mod transfer;
pub mod transfer_with_fee;
pub mod withdraw;
pub mod withdraw_withheld;
#[cfg(not(target_arch = "bpf"))]
use {
crate::{
encryption::{
elgamal::ElGamalCiphertext,
pedersen::{PedersenCommitment, PedersenOpening},
},
errors::ProofError,
},
curve25519_dalek::scalar::Scalar,
};
pub use {
close_account::CloseAccountData, transfer::TransferData,
transfer_with_fee::TransferWithFeeData, withdraw::WithdrawData,
withdraw_withheld::WithdrawWithheldTokensData,
};
#[cfg(not(target_arch = "bpf"))]
const TWO_32: u64 = 4294967296;
#[cfg(not(target_arch = "bpf"))]
pub trait Verifiable {
fn verify(&self) -> Result<(), ProofError>;
}
#[cfg(not(target_arch = "bpf"))]
#[derive(Debug, Copy, Clone)]
pub enum Role {
Source,
Dest,
Auditor,
}
#[cfg(not(target_arch = "bpf"))]
pub fn split_u64_into_u32(amount: u64) -> (u32, u32) {
let lo = amount as u32;
let hi = (amount >> 32) as u32;
(lo, hi)
}
#[cfg(not(target_arch = "bpf"))]
fn combine_u32_ciphertexts(
ciphertext_lo: &ElGamalCiphertext,
ciphertext_hi: &ElGamalCiphertext,
) -> ElGamalCiphertext {
ciphertext_lo + &(ciphertext_hi * &Scalar::from(TWO_32))
}
#[cfg(not(target_arch = "bpf"))]
pub fn combine_u32_commitments(
comm_lo: &PedersenCommitment,
comm_hi: &PedersenCommitment,
) -> PedersenCommitment {
comm_lo + comm_hi * &Scalar::from(TWO_32)
}
#[cfg(not(target_arch = "bpf"))]
pub fn combine_u32_openings(
opening_lo: &PedersenOpening,
opening_hi: &PedersenOpening,
) -> PedersenOpening {
opening_lo + opening_hi * &Scalar::from(TWO_32)
}