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

Commit 9e02934

Browse files
Rename encryption pubkey (#3147)
* token-2022: change elgamal pubkey to encryption pubkey * token-2022: update client and tests for elgamal pubkey to encryption pubkey
1 parent b6eb64b commit 9e02934

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

token/client/src/token.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ where
949949
&self.program_id,
950950
token_account,
951951
&self.pubkey,
952-
elgamal_pubkey,
952+
elgamal_pubkey.into(),
953953
decryptable_zero_balance,
954954
&authority.pubkey(),
955955
&[],
@@ -1131,7 +1131,7 @@ where
11311131
source_elgamal_keypair,
11321132
(
11331133
&destination_extension.encryption_pubkey.try_into().unwrap(),
1134-
&ct_mint.auditor_pubkey.try_into().unwrap(),
1134+
&ct_mint.auditor_encryption_pubkey.try_into().unwrap(),
11351135
),
11361136
)
11371137
.map_err(TokenError::Proof)?;
@@ -1197,14 +1197,14 @@ where
11971197
source_elgamal_keypair,
11981198
(
11991199
&destination_extension.encryption_pubkey.try_into().unwrap(),
1200-
&ct_mint.auditor_pubkey.try_into().unwrap(),
1200+
&ct_mint.auditor_encryption_pubkey.try_into().unwrap(),
12011201
),
12021202
FeeParameters {
12031203
fee_rate_basis_points: u16::from(fee_parameters.transfer_fee_basis_points),
12041204
maximum_fee: u64::from(fee_parameters.maximum_fee),
12051205
},
12061206
&ct_mint
1207-
.withdraw_withheld_authority_pubkey
1207+
.withdraw_withheld_authority_encryption_pubkey
12081208
.try_into()
12091209
.unwrap(),
12101210
)

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ impl ConfidentialTransferMintWithKeypairs {
6060
let ct_mint = ConfidentialTransferMint {
6161
authority: ct_mint_authority.pubkey().into(),
6262
auto_approve_new_accounts: true.into(),
63-
auditor_pubkey: ct_mint_transfer_auditor.public.into(),
64-
withdraw_withheld_authority_pubkey: ct_mint_withdraw_withheld_authority.public.into(),
63+
auditor_encryption_pubkey: ct_mint_transfer_auditor.public.into(),
64+
withdraw_withheld_authority_encryption_pubkey: ct_mint_withdraw_withheld_authority
65+
.public
66+
.into(),
6567
withheld_amount: EncryptedWithheldAmount::zeroed(),
6668
};
6769
Self {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[cfg(not(target_arch = "bpf"))]
2-
use solana_zk_token_sdk::encryption::{auth_encryption::AeCiphertext, elgamal::ElGamalPubkey};
2+
use solana_zk_token_sdk::encryption::auth_encryption::AeCiphertext;
33
pub use solana_zk_token_sdk::zk_token_proof_instruction::*;
44
use {
55
crate::{
@@ -516,7 +516,7 @@ pub fn configure_account(
516516
token_program_id: &Pubkey,
517517
token_account: &Pubkey,
518518
mint: &Pubkey,
519-
encryption_pubkey: ElGamalPubkey,
519+
encryption_pubkey: EncryptionPubkey,
520520
decryptable_zero_balance: AeCiphertext,
521521
authority: &Pubkey,
522522
multisig_signers: &[&Pubkey],
@@ -538,7 +538,7 @@ pub fn configure_account(
538538
TokenInstruction::ConfidentialTransferExtension,
539539
ConfidentialTransferInstruction::ConfigureAccount,
540540
&ConfigureAccountInstructionData {
541-
encryption_pubkey: encryption_pubkey.into(),
541+
encryption_pubkey,
542542
decryptable_zero_balance: decryptable_zero_balance.into(),
543543
},
544544
))

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ pub struct ConfidentialTransferMint {
5050
/// * If non-zero, transfers must include ElGamal cypertext with this public key permitting the
5151
/// auditor to decode the transfer amount.
5252
/// * If all zero, auditing is currently disabled.
53-
pub auditor_pubkey: EncryptionPubkey,
53+
pub auditor_encryption_pubkey: EncryptionPubkey,
5454

5555
/// * If non-zero, transfers must include ElGamal cypertext of the transfer fee with this
5656
/// public key. If this is the case, but the base mint is not extended for fees, then any
5757
/// transfer will fail.
5858
/// * If all zero, transfer fee is disabled. If this is the case, but the base mint is extended
5959
/// for fees, then any transfer will fail.
60-
pub withdraw_withheld_authority_pubkey: EncryptionPubkey,
60+
pub withdraw_withheld_authority_encryption_pubkey: EncryptionPubkey,
6161

6262
/// Withheld transfer fee confidential tokens that have been moved to the mint for withdrawal.
6363
/// This will always be zero if fees are never enabled.
@@ -79,10 +79,10 @@ pub struct ConfidentialTransferAccount {
7979
/// The public key associated with ElGamal encryption
8080
pub encryption_pubkey: EncryptionPubkey,
8181

82-
/// The pending balance (encrypted by `pubkey_elgamal`)
82+
/// The pending balance (encrypted by `encryption_pubkey`)
8383
pub pending_balance: EncryptedBalance,
8484

85-
/// The available balance (encrypted by `pubkey_elgamal`)
85+
/// The available balance (encrypted by `encrypiton_pubkey`)
8686
pub available_balance: EncryptedBalance,
8787

8888
/// The decryptable available balance

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ fn decode_proof_instruction<T: Pod>(
3333
expected: ProofInstruction,
3434
instruction: &Instruction,
3535
) -> Result<&T, ProgramError> {
36-
if ProofInstruction::decode_type(&instruction.data) != Some(expected) {
37-
msg!("decode type failed ----------------------------------");
38-
}
39-
4036
if instruction.program_id != zk_token_proof_program::id()
4137
|| ProofInstruction::decode_type(&instruction.data) != Some(expected)
4238
{
@@ -486,7 +482,7 @@ fn process_transfer(
486482
)?;
487483

488484
if proof_data.transfer_with_fee_pubkeys.auditor_pubkey
489-
!= confidential_transfer_mint.auditor_pubkey
485+
!= confidential_transfer_mint.auditor_encryption_pubkey
490486
{
491487
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
492488
}
@@ -495,7 +491,7 @@ fn process_transfer(
495491
if proof_data
496492
.transfer_with_fee_pubkeys
497493
.withdraw_withheld_authority_pubkey
498-
!= confidential_transfer_mint.withdraw_withheld_authority_pubkey
494+
!= confidential_transfer_mint.withdraw_withheld_authority_encryption_pubkey
499495
{
500496
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
501497
}
@@ -565,7 +561,9 @@ fn process_transfer(
565561
&previous_instruction,
566562
)?;
567563

568-
if proof_data.transfer_pubkeys.auditor_pubkey != confidential_transfer_mint.auditor_pubkey {
564+
if proof_data.transfer_pubkeys.auditor_pubkey
565+
!= confidential_transfer_mint.auditor_encryption_pubkey
566+
{
569567
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
570568
}
571569

@@ -875,7 +873,7 @@ fn process_withdraw_withheld_tokens_from_mint(
875873

876874
// withdraw withheld authority ElGamal pubkey should match in the proof data and mint
877875
if proof_data.withdraw_withheld_authority_pubkey
878-
!= confidential_transfer_mint.withdraw_withheld_authority_pubkey
876+
!= confidential_transfer_mint.withdraw_withheld_authority_encryption_pubkey
879877
{
880878
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
881879
}
@@ -998,7 +996,7 @@ fn process_withdraw_withheld_tokens_from_accounts(
998996
// withdraw withheld authority ElGamal pubkey should match in the proof data and mint
999997
let confidential_transfer_mint = mint.get_extension_mut::<ConfidentialTransferMint>()?;
1000998
if proof_data.withdraw_withheld_authority_pubkey
1001-
!= confidential_transfer_mint.withdraw_withheld_authority_pubkey
999+
!= confidential_transfer_mint.withdraw_withheld_authority_encryption_pubkey
10021000
{
10031001
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
10041002
}

0 commit comments

Comments
 (0)