1
+ #[ cfg( target_arch = "wasm32" ) ]
2
+ use solana_zk_sdk:: encryption:: grouped_elgamal:: { GroupedElGamalCiphertext2Handles , GroupedElGamalCiphertext3Handles } ;
3
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
4
+ use solana_zk_sdk:: encryption:: grouped_elgamal:: GroupedElGamal ;
1
5
use {
2
6
crate :: {
3
7
encryption:: { FeeCiphertext , TransferAmountCiphertext } ,
9
13
curve25519_dalek:: scalar:: Scalar ,
10
14
solana_zk_sdk:: {
11
15
encryption:: {
12
- auth_encryption:: { AeCiphertext , AeKey } ,
13
- elgamal:: { ElGamalCiphertext , ElGamalKeypair , ElGamalPubkey } ,
14
- grouped_elgamal:: GroupedElGamal ,
15
- pedersen:: { Pedersen , PedersenCommitment , PedersenOpening } ,
16
+ auth_encryption:: { AeCiphertext , AeKey } , elgamal:: { ElGamalCiphertext , ElGamalKeypair , ElGamalPubkey } , pedersen:: { Pedersen , PedersenCommitment , PedersenOpening }
16
17
} ,
17
18
zk_elgamal_proof_program:: proof_data:: {
18
19
BatchedGroupedCiphertext2HandlesValidityProofData ,
@@ -71,6 +72,16 @@ pub fn transfer_with_fee_split_proof_data(
71
72
destination_elgamal_pubkey,
72
73
auditor_elgamal_pubkey,
73
74
) ;
75
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
76
+ let grouped_ciphertext_lo = transfer_amount_grouped_ciphertext_lo. 0 ;
77
+ #[ cfg( target_arch = "wasm32" ) ]
78
+ let grouped_ciphertext_lo = GroupedElGamalCiphertext3Handles :: encryption_with_u64 (
79
+ source_elgamal_keypair. pubkey ( ) ,
80
+ destination_elgamal_pubkey,
81
+ auditor_elgamal_pubkey,
82
+ transfer_amount_lo,
83
+ & transfer_amount_opening_lo,
84
+ ) ;
74
85
75
86
let ( transfer_amount_grouped_ciphertext_hi, transfer_amount_opening_hi) =
76
87
TransferAmountCiphertext :: new (
@@ -79,6 +90,16 @@ pub fn transfer_with_fee_split_proof_data(
79
90
destination_elgamal_pubkey,
80
91
auditor_elgamal_pubkey,
81
92
) ;
93
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
94
+ let grouped_ciphertext_hi = transfer_amount_grouped_ciphertext_hi. 0 ;
95
+ #[ cfg( target_arch = "wasm32" ) ]
96
+ let grouped_ciphertext_hi = GroupedElGamalCiphertext3Handles :: encryption_with_u64 (
97
+ source_elgamal_keypair. pubkey ( ) ,
98
+ destination_elgamal_pubkey,
99
+ auditor_elgamal_pubkey,
100
+ transfer_amount_hi,
101
+ & transfer_amount_opening_hi,
102
+ ) ;
82
103
83
104
// Decrypt the current available balance at the source
84
105
let current_decrypted_available_balance = current_decryptable_available_balance
@@ -130,8 +151,8 @@ pub fn transfer_with_fee_split_proof_data(
130
151
source_elgamal_keypair. pubkey ( ) ,
131
152
destination_elgamal_pubkey,
132
153
auditor_elgamal_pubkey,
133
- & transfer_amount_grouped_ciphertext_lo . 0 ,
134
- & transfer_amount_grouped_ciphertext_hi . 0 ,
154
+ & grouped_ciphertext_lo ,
155
+ & grouped_ciphertext_hi ,
135
156
transfer_amount_lo,
136
157
transfer_amount_hi,
137
158
& transfer_amount_opening_lo,
@@ -233,6 +254,7 @@ pub fn transfer_with_fee_split_proof_data(
233
254
234
255
// encrypt the fee amount under the destination and withdraw withheld authority
235
256
// ElGamal public key
257
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
236
258
let fee_destination_withdraw_withheld_authority_ciphertext_lo = GroupedElGamal :: encrypt_with (
237
259
[
238
260
destination_elgamal_pubkey,
@@ -241,14 +263,29 @@ pub fn transfer_with_fee_split_proof_data(
241
263
fee_amount_lo,
242
264
& fee_opening_lo,
243
265
) ;
244
- let fee_destination_withdraw_withheld_authority_ciphertext_hi = GroupedElGamal :: encrypt_with (
245
- [
266
+ #[ cfg( target_arch = "wasm32" ) ]
267
+ let fee_destination_withdraw_withheld_authority_ciphertext_lo = GroupedElGamalCiphertext2Handles :: encryption_with_u64 (
268
+ destination_elgamal_pubkey,
269
+ withdraw_withheld_authority_elgamal_pubkey,
270
+ fee_amount_lo,
271
+ & fee_opening_lo
272
+ ) ;
273
+
274
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
275
+ let fee_destination_withdraw_withheld_authority_ciphertext_hi = GroupedElGamal :: encrypt_with ( [
246
276
destination_elgamal_pubkey,
247
277
withdraw_withheld_authority_elgamal_pubkey,
248
278
] ,
249
279
fee_amount_hi,
250
280
& fee_opening_hi,
251
281
) ;
282
+ #[ cfg( target_arch = "wasm32" ) ]
283
+ let fee_destination_withdraw_withheld_authority_ciphertext_hi = GroupedElGamalCiphertext2Handles :: encryption_with_u64 (
284
+ destination_elgamal_pubkey,
285
+ withdraw_withheld_authority_elgamal_pubkey,
286
+ fee_amount_hi,
287
+ & fee_opening_hi,
288
+ ) ;
252
289
253
290
// generate fee ciphertext validity data
254
291
let fee_ciphertext_validity_proof_data =
0 commit comments