@@ -2083,19 +2083,26 @@ where
2083
2083
WithdrawAccountInfo :: new ( confidential_transfer_account)
2084
2084
} ;
2085
2085
2086
- let WithdrawProofData {
2087
- equality_proof_data,
2088
- range_proof_data,
2089
- } = account_info
2090
- . generate_proof_data ( withdraw_amount, elgamal_keypair, aes_key)
2091
- . map_err ( |_| TokenError :: ProofGeneration ) ?;
2092
-
2093
- // if proof accounts are none, then proof data must be included as instruction
2094
- // data
2095
- let equality_proof_data = equality_proof_account
2096
- . is_none ( )
2097
- . then_some ( equality_proof_data) ;
2098
- let range_proof_data = range_proof_account. is_none ( ) . then_some ( range_proof_data) ;
2086
+ let ( equality_proof_data, range_proof_data) =
2087
+ if equality_proof_account. is_some ( ) && range_proof_account. is_some ( ) {
2088
+ ( None , None )
2089
+ } else {
2090
+ let WithdrawProofData {
2091
+ equality_proof_data,
2092
+ range_proof_data,
2093
+ } = account_info
2094
+ . generate_proof_data ( withdraw_amount, elgamal_keypair, aes_key)
2095
+ . map_err ( |_| TokenError :: ProofGeneration ) ?;
2096
+
2097
+ // if proof accounts are none, then proof data must be included as instruction
2098
+ // data
2099
+ let equality_proof_data = equality_proof_account
2100
+ . is_none ( )
2101
+ . then_some ( equality_proof_data) ;
2102
+ let range_proof_data = range_proof_account. is_none ( ) . then_some ( range_proof_data) ;
2103
+
2104
+ ( equality_proof_data, range_proof_data)
2105
+ } ;
2099
2106
2100
2107
// cannot panic as long as either `proof_data` or `proof_account` is `Some(..)`,
2101
2108
// which is guaranteed by the previous check
@@ -2165,29 +2172,46 @@ where
2165
2172
TransferAccountInfo :: new ( confidential_transfer_account)
2166
2173
} ;
2167
2174
2168
- let TransferProofData {
2169
- equality_proof_data,
2170
- ciphertext_validity_proof_data,
2171
- range_proof_data,
2172
- } = account_info
2173
- . generate_split_transfer_proof_data (
2174
- transfer_amount,
2175
- source_elgamal_keypair,
2176
- source_aes_key,
2177
- destination_elgamal_pubkey,
2178
- auditor_elgamal_pubkey,
2175
+ let ( equality_proof_data, ciphertext_validity_proof_data, range_proof_data) = if [
2176
+ equality_proof_account,
2177
+ ciphertext_validity_proof_account,
2178
+ range_proof_account,
2179
+ ]
2180
+ . iter ( )
2181
+ . all ( |proof_account| proof_account. is_some ( ) )
2182
+ {
2183
+ ( None , None , None )
2184
+ } else {
2185
+ let TransferProofData {
2186
+ equality_proof_data,
2187
+ ciphertext_validity_proof_data,
2188
+ range_proof_data,
2189
+ } = account_info
2190
+ . generate_split_transfer_proof_data (
2191
+ transfer_amount,
2192
+ source_elgamal_keypair,
2193
+ source_aes_key,
2194
+ destination_elgamal_pubkey,
2195
+ auditor_elgamal_pubkey,
2196
+ )
2197
+ . map_err ( |_| TokenError :: ProofGeneration ) ?;
2198
+
2199
+ // if proof accounts are none, then proof data must be included as instruction
2200
+ // data
2201
+ let equality_proof_data = equality_proof_account
2202
+ . is_none ( )
2203
+ . then_some ( equality_proof_data) ;
2204
+ let ciphertext_validity_proof_data = ciphertext_validity_proof_account
2205
+ . is_none ( )
2206
+ . then_some ( ciphertext_validity_proof_data) ;
2207
+ let range_proof_data = range_proof_account. is_none ( ) . then_some ( range_proof_data) ;
2208
+
2209
+ (
2210
+ equality_proof_data,
2211
+ ciphertext_validity_proof_data,
2212
+ range_proof_data,
2179
2213
)
2180
- . map_err ( |_| TokenError :: ProofGeneration ) ?;
2181
-
2182
- // if proof accounts are none, then proof data must be included as instruction
2183
- // data
2184
- let equality_proof_data = equality_proof_account
2185
- . is_none ( )
2186
- . then_some ( equality_proof_data) ;
2187
- let ciphertext_validity_proof_data = ciphertext_validity_proof_account
2188
- . is_none ( )
2189
- . then_some ( ciphertext_validity_proof_data) ;
2190
- let range_proof_data = range_proof_account. is_none ( ) . then_some ( range_proof_data) ;
2214
+ } ;
2191
2215
2192
2216
// cannot panic as long as either `proof_data` or `proof_account` is `Some(..)`,
2193
2217
// which is guaranteed by the previous check
@@ -2457,7 +2481,7 @@ where
2457
2481
source_authority : & Pubkey ,
2458
2482
equality_proof_account : Option < & ProofAccount > ,
2459
2483
transfer_amount_ciphertext_validity_proof_account : Option < & ProofAccount > ,
2460
- fee_sigma_proof_account : Option < & ProofAccount > ,
2484
+ percentage_with_cap_proof_account : Option < & ProofAccount > ,
2461
2485
fee_ciphertext_validity_proof_account : Option < & ProofAccount > ,
2462
2486
range_proof_account : Option < & ProofAccount > ,
2463
2487
transfer_amount : u64 ,
@@ -2483,39 +2507,67 @@ where
2483
2507
TransferAccountInfo :: new ( confidential_transfer_account)
2484
2508
} ;
2485
2509
2486
- let TransferWithFeeProofData {
2510
+ let (
2487
2511
equality_proof_data,
2488
2512
transfer_amount_ciphertext_validity_proof_data,
2489
2513
percentage_with_cap_proof_data,
2490
2514
fee_ciphertext_validity_proof_data,
2491
2515
range_proof_data,
2492
- } = account_info
2493
- . generate_split_transfer_with_fee_proof_data (
2494
- transfer_amount,
2495
- source_elgamal_keypair,
2496
- source_aes_key,
2497
- destination_elgamal_pubkey,
2498
- auditor_elgamal_pubkey,
2499
- withdraw_withheld_authority_elgamal_pubkey,
2500
- fee_rate_basis_points,
2501
- maximum_fee,
2502
- )
2503
- . map_err ( |_| TokenError :: ProofGeneration ) ?;
2516
+ ) = if [
2517
+ equality_proof_account,
2518
+ transfer_amount_ciphertext_validity_proof_account,
2519
+ percentage_with_cap_proof_account,
2520
+ fee_ciphertext_validity_proof_account,
2521
+ range_proof_account,
2522
+ ]
2523
+ . iter ( )
2524
+ . all ( |proof_account| proof_account. is_some ( ) )
2525
+ {
2526
+ // is all proofs come from accounts, then skip proof generation
2527
+ ( None , None , None , None , None )
2528
+ } else {
2529
+ let TransferWithFeeProofData {
2530
+ equality_proof_data,
2531
+ transfer_amount_ciphertext_validity_proof_data,
2532
+ percentage_with_cap_proof_data,
2533
+ fee_ciphertext_validity_proof_data,
2534
+ range_proof_data,
2535
+ } = account_info
2536
+ . generate_split_transfer_with_fee_proof_data (
2537
+ transfer_amount,
2538
+ source_elgamal_keypair,
2539
+ source_aes_key,
2540
+ destination_elgamal_pubkey,
2541
+ auditor_elgamal_pubkey,
2542
+ withdraw_withheld_authority_elgamal_pubkey,
2543
+ fee_rate_basis_points,
2544
+ maximum_fee,
2545
+ )
2546
+ . map_err ( |_| TokenError :: ProofGeneration ) ?;
2504
2547
2505
- let equality_proof_data = equality_proof_account
2506
- . is_none ( )
2507
- . then_some ( equality_proof_data) ;
2508
- let transfer_amount_ciphertext_validity_proof_data =
2509
- transfer_amount_ciphertext_validity_proof_account
2548
+ let equality_proof_data = equality_proof_account
2549
+ . is_none ( )
2550
+ . then_some ( equality_proof_data) ;
2551
+ let transfer_amount_ciphertext_validity_proof_data =
2552
+ transfer_amount_ciphertext_validity_proof_account
2553
+ . is_none ( )
2554
+ . then_some ( transfer_amount_ciphertext_validity_proof_data) ;
2555
+ let percentage_with_cap_proof_data = percentage_with_cap_proof_account
2556
+ . is_none ( )
2557
+ . then_some ( percentage_with_cap_proof_data) ;
2558
+ let fee_ciphertext_validity_proof_data = fee_ciphertext_validity_proof_account
2510
2559
. is_none ( )
2511
- . then_some ( transfer_amount_ciphertext_validity_proof_data) ;
2512
- let fee_sigma_proof_data = fee_sigma_proof_account
2513
- . is_none ( )
2514
- . then_some ( percentage_with_cap_proof_data) ;
2515
- let fee_ciphertext_validity_proof_data = fee_ciphertext_validity_proof_account
2516
- . is_none ( )
2517
- . then_some ( fee_ciphertext_validity_proof_data) ;
2518
- let range_proof_data = range_proof_account. is_none ( ) . then_some ( range_proof_data) ;
2560
+ . then_some ( fee_ciphertext_validity_proof_data) ;
2561
+ let range_proof_data = range_proof_account. is_none ( ) . then_some ( range_proof_data) ;
2562
+
2563
+ (
2564
+ equality_proof_data,
2565
+ transfer_amount_ciphertext_validity_proof_data,
2566
+ percentage_with_cap_proof_data,
2567
+ fee_ciphertext_validity_proof_data,
2568
+ range_proof_data,
2569
+ )
2570
+ } ;
2519
2571
2520
2572
// cannot panic as long as either `proof_data` or `proof_account` is `Some(..)`,
2521
2573
// which is guaranteed by the previous check
@@ -2533,8 +2585,8 @@ where
2533
2585
)
2534
2586
. unwrap ( ) ;
2535
2587
let fee_sigma_proof_location = Self :: confidential_transfer_create_proof_location (
2536
- fee_sigma_proof_data . as_ref ( ) ,
2537
- fee_sigma_proof_account ,
2588
+ percentage_with_cap_proof_data . as_ref ( ) ,
2589
+ percentage_with_cap_proof_account ,
2538
2590
3 ,
2539
2591
)
2540
2592
. unwrap ( ) ;
0 commit comments