Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit bf7b09a

Browse files
committed
cargo fmt
1 parent a502871 commit bf7b09a

File tree

6 files changed

+55
-43
lines changed

6 files changed

+55
-43
lines changed

token/client/src/token.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,7 +2090,8 @@ where
20902090
.generate_proof_data(withdraw_amount, elgamal_keypair, aes_key)
20912091
.map_err(|_| TokenError::ProofGeneration)?;
20922092

2093-
// if proof accounts are none, then proof data must be included as instruction data
2093+
// if proof accounts are none, then proof data must be included as instruction
2094+
// data
20942095
let equality_proof_data = equality_proof_account
20952096
.is_none()
20962097
.then_some(equality_proof_data);
@@ -2347,8 +2348,8 @@ where
23472348
.await
23482349
}
23492350

2350-
/// Create a context state account containing zero-knowledge proof needed for a confidential
2351-
/// transfer instruction.
2351+
/// Create a context state account containing zero-knowledge proof needed
2352+
/// for a confidential transfer instruction.
23522353
pub async fn confidential_transfer_create_context_state_account<
23532354
S: Signer,
23542355
ZK: Pod + ZkProofData<U>,

token/program-2022-test/tests/confidential_transfer.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,8 @@ async fn confidential_transfer_withdraw_with_option(option: ConfidentialTransfer
11311131
// let account_info = WithdrawAccountInfo::new(extension);
11321132
//
11331133
// let withdraw_proof = account_info
1134-
// .generate_proof_data(42, &alice_meta.elgamal_keypair, &alice_meta.aes_key)
1135-
// .unwrap();
1134+
// .generate_proof_data(42, &alice_meta.elgamal_keypair,
1135+
// &alice_meta.aes_key) .unwrap();
11361136
//
11371137
// let record_account = Keypair::new();
11381138
// let record_account_authority = Keypair::new();
@@ -3126,10 +3126,11 @@ async fn confidential_transfer_empty_account_with_proof_context() {
31263126
// let extension = state
31273127
// .get_extension::<ConfidentialTransferAccount>()
31283128
// .unwrap();
3129-
// let current_ciphertext = extension.available_balance.try_into().unwrap();
3129+
// let current_ciphertext =
3130+
// extension.available_balance.try_into().unwrap();
31303131
//
3131-
// let proof_data = confidential_transfer::instruction::WithdrawData::new(
3132-
// 0,
3132+
// let proof_data =
3133+
// confidential_transfer::instruction::WithdrawData::new( 0,
31333134
// &alice_meta.elgamal_keypair,
31343135
// 42,
31353136
// &current_ciphertext,
@@ -3147,8 +3148,8 @@ async fn confidential_transfer_empty_account_with_proof_context() {
31473148
// space as u64,
31483149
// &zk_elgamal_proof_program::id(),
31493150
// ),
3150-
// instruction_type.encode_verify_proof(Some(context_state_info), &proof_data),
3151-
// ];
3151+
// instruction_type.encode_verify_proof(Some(context_state_info),
3152+
// &proof_data), ];
31523153
//
31533154
// let last_blockhash = ctx.get_new_latest_blockhash().await.unwrap();
31543155
// let tx = Transaction::new_signed_with_payer(
@@ -3178,12 +3179,13 @@ async fn confidential_transfer_empty_account_with_proof_context() {
31783179
// .unwrap();
31793180
//
31803181
// // attempt to create an account with a wrong proof type context state
3181-
// let bob_meta = ConfidentialTokenAccountMeta::new(&token, &bob, None, false, false).await;
3182-
// let context_state_account = Keypair::new();
3182+
// let bob_meta = ConfidentialTokenAccountMeta::new(&token, &bob, None,
3183+
// false, false).await; let context_state_account = Keypair::new();
31833184
//
31843185
// {
31853186
// let context_state_authority = Keypair::new();
3186-
// let space = size_of::<ProofContextState<PubkeyValidityProofContext>>();
3187+
// let space =
3188+
// size_of::<ProofContextState<PubkeyValidityProofContext>>();
31873189
//
31883190
// let instruction_type = ProofInstruction::VerifyPubkeyValidity;
31893191
//
@@ -3193,8 +3195,9 @@ async fn confidential_transfer_empty_account_with_proof_context() {
31933195
// };
31943196
//
31953197
// let proof_data =
3196-
// confidential_transfer::instruction::PubkeyValidityData::new(&bob_meta.elgamal_keypair)
3197-
// .unwrap();
3198+
//
3199+
// confidential_transfer::instruction::PubkeyValidityData::new(&bob_meta.
3200+
// elgamal_keypair) .unwrap();
31983201
//
31993202
// let mut ctx = context.context.lock().await;
32003203
// let rent = ctx.banks_client.get_rent().await.unwrap();
@@ -3207,8 +3210,8 @@ async fn confidential_transfer_empty_account_with_proof_context() {
32073210
// space as u64,
32083211
// &zk_elgamal_proof_program::id(),
32093212
// ),
3210-
// instruction_type.encode_verify_proof(Some(context_state_info), &proof_data),
3211-
// ];
3213+
// instruction_type.encode_verify_proof(Some(context_state_info),
3214+
// &proof_data), ];
32123215
//
32133216
// let last_blockhash = ctx.get_new_latest_blockhash().await.unwrap();
32143217
// let tx = Transaction::new_signed_with_payer(
@@ -3240,7 +3243,7 @@ async fn confidential_transfer_empty_account_with_proof_context() {
32403243
// assert_eq!(
32413244
// err,
32423245
// TokenClientError::Client(Box::new(TransportError::TransactionError(
3243-
// TransactionError::InstructionError(0, InstructionError::InvalidArgument,)
3244-
// )))
3246+
// TransactionError::InstructionError(0,
3247+
// InstructionError::InvalidArgument,) )))
32453248
// );
32463249
// }

token/program-2022/src/extension/confidential_transfer/account_info.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ impl TransferAccountInfo {
270270
.map_err(|e| -> TokenError { e.into() })
271271
}
272272

273-
/// Create a transfer proof data that is split into equality, ciphertext validity (transfer
274-
/// amount), percentage-with-cap, ciphertext validity (fee), and range proofs.
273+
/// Create a transfer proof data that is split into equality, ciphertext
274+
/// validity (transfer amount), percentage-with-cap, ciphertext validity
275+
/// (fee), and range proofs.
275276
pub fn generate_split_transfer_with_fee_proof_data(
276277
&self,
277278
transfer_amount: u64,

token/program-2022/src/extension/confidential_transfer/instruction.rs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pub use solana_zk_sdk::zk_elgamal_proof_program::{
22
instruction::ProofInstruction, proof_data::*, state::ProofContextState,
33
};
4-
54
#[cfg(feature = "serde-traits")]
65
use {
76
crate::serialization::aeciphertext_fromstr,
@@ -205,13 +204,14 @@ pub enum ConfidentialTransferInstruction {
205204
/// Withdraw SPL Tokens from the available balance of a confidential token
206205
/// account.
207206
///
208-
/// In order for this instruction to be successfully processed, it must be accompanied by the
209-
/// following list of `zk_elgamal_proof` program instructions:
207+
/// In order for this instruction to be successfully processed, it must be
208+
/// accompanied by the following list of `zk_elgamal_proof` program
209+
/// instructions:
210210
/// - `VerifyCiphertextCommitmentEquality`
211211
/// - `VerifyBatchedRangeProofU64`
212-
/// These instructions can be accompanied in the same transaction or can be pre-verified into a
213-
/// context state account, in which case, only their context state account address need to be
214-
/// provided.
212+
/// These instructions can be accompanied in the same transaction or can be
213+
/// pre-verified into a context state account, in which case, only their
214+
/// context state account address need to be provided.
215215
///
216216
/// Fails if the source or destination accounts are frozen.
217217
/// Fails if the associated mint is extended as `NonTransferable`.
@@ -221,19 +221,25 @@ pub enum ConfidentialTransferInstruction {
221221
/// * Single owner/delegate
222222
/// 0. `[writable]` The SPL Token account.
223223
/// 1. `[]` The token mint.
224-
/// 2. `[]` (Optional) Instructions sysvar if at least one of the `zk_elgamal_proof`
225-
/// instructions are included in the same transaction.
226-
/// 3. `[]` (Optional) Equality proof record account or context state account.
227-
/// 4. `[]` (Optional) Range proof record account or context state account.
224+
/// 2. `[]` (Optional) Instructions sysvar if at least one of the
225+
/// `zk_elgamal_proof` instructions are included in the same
226+
/// transaction.
227+
/// 3. `[]` (Optional) Equality proof record account or context state
228+
/// account.
229+
/// 4. `[]` (Optional) Range proof record account or context state
230+
/// account.
228231
/// 5. `[signer]` The single source account owner.
229232
///
230233
/// * Multisignature owner/delegate
231234
/// 0. `[writable]` The SPL Token account.
232235
/// 1. `[]` The token mint.
233-
/// 2. `[]` (Optional) Instructions sysvar if at least one of the `zk_elgamal_proof`
234-
/// instructions are included in the same transaction.
235-
/// 3. `[]` (Optional) Equality proof record account or context state account.
236-
/// 4. `[]` (Optional) Range proof record account or context state account.
236+
/// 2. `[]` (Optional) Instructions sysvar if at least one of the
237+
/// `zk_elgamal_proof` instructions are included in the same
238+
/// transaction.
239+
/// 3. `[]` (Optional) Equality proof record account or context state
240+
/// account.
241+
/// 4. `[]` (Optional) Range proof record account or context state
242+
/// account.
237243
/// 5. `[]` The multisig source account owner.
238244
/// 6.. `[signer]` Required M signer accounts for the SPL Token Multisig
239245
/// account.
@@ -549,13 +555,14 @@ pub struct WithdrawInstructionData {
549555
/// The new decryptable balance if the withdrawal succeeds
550556
#[cfg_attr(feature = "serde-traits", serde(with = "aeciphertext_fromstr"))]
551557
pub new_decryptable_available_balance: DecryptableBalance,
552-
/// Relative location of the `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction
558+
/// Relative location of the
559+
/// `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction
553560
/// to the `Withdraw` instruction in the transaction. If the offset is
554561
/// `0`, then use a context state account for the proof.
555562
pub equality_proof_instruction_offset: i8,
556-
/// Relative location of the `ProofInstruction::BatchedRangeProofU64` instruction
557-
/// to the `Withdraw` instruction in the transaction. If the offset is
558-
/// `0`, then use a context state account for the proof.
563+
/// Relative location of the `ProofInstruction::BatchedRangeProofU64`
564+
/// instruction to the `Withdraw` instruction in the transaction. If the
565+
/// offset is `0`, then use a context state account for the proof.
559566
pub range_proof_instruction_offset: i8,
560567
}
561568

token/program-2022/src/extension/confidential_transfer/verify_proof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use {
1515
std::slice::Iter,
1616
};
1717

18-
/// Verify zero-knowledge proofs needed for a [Withdraw] instruction and return the corresponding
19-
/// proof context.
18+
/// Verify zero-knowledge proofs needed for a [Withdraw] instruction and return
19+
/// the corresponding proof context.
2020
#[cfg(feature = "zk-ops")]
2121
pub fn verify_withdraw_proof(
2222
account_info_iter: &mut Iter<AccountInfo>,

token/program-2022/src/proof.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ pub fn verify_and_extract_context<'a, T: Pod + ZkProofData<U>, U: Pod>(
134134
}
135135
}
136136

137-
/// Converts a zk proof type to a corresponding ZK ElGamal proof program instruction that verifies
138-
/// the proof.
137+
/// Converts a zk proof type to a corresponding ZK ElGamal proof program
138+
/// instruction that verifies the proof.
139139
pub fn zk_proof_type_to_instruction(
140140
proof_type: ProofType,
141141
) -> Result<ProofInstruction, ProgramError> {

0 commit comments

Comments
 (0)