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

Commit 13809a9

Browse files
committed
more changes
1 parent 7fbfcfd commit 13809a9

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

token/confidential-transfer/proof-generation/src/mint.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use {
55
},
66
solana_zk_sdk::{
77
encryption::{
8-
auth_encryption::{AeCiphertext, AeKey},
98
elgamal::{ElGamalCiphertext, ElGamalKeypair, ElGamalPubkey},
109
pedersen::Pedersen,
1110
},
@@ -28,15 +27,13 @@ pub struct MintProofData {
2827
pub ciphertext_validity_proof_data_with_ciphertext:
2928
CiphertextValidityProofWithAuditorCiphertext,
3029
pub range_proof_data: BatchedRangeProofU128Data,
31-
pub new_decryptable_supply: AeCiphertext,
3230
}
3331

3432
pub fn mint_split_proof_data(
3533
current_supply_ciphertext: &ElGamalCiphertext,
3634
mint_amount: u64,
3735
current_supply: u64,
3836
supply_elgamal_keypair: &ElGamalKeypair,
39-
supply_aes_key: &AeKey,
4037
destination_elgamal_pubkey: &ElGamalPubkey,
4138
auditor_elgamal_pubkey: Option<&ElGamalPubkey>,
4239
) -> Result<MintProofData, TokenProofGenerationError> {
@@ -161,6 +158,5 @@ pub fn mint_split_proof_data(
161158
equality_proof_data,
162159
ciphertext_validity_proof_data_with_ciphertext,
163160
range_proof_data,
164-
new_decryptable_supply: supply_aes_key.encrypt(new_supply),
165161
})
166162
}

token/confidential-transfer/proof-tests/tests/proof_test.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,18 @@ fn test_mint_validity(mint_amount: u64, supply: u64) {
222222
let auditor_pubkey = auditor_keypair.pubkey();
223223

224224
let supply_keypair = ElGamalKeypair::new_rand();
225-
let supply_aes_key = AeKey::new_rand();
226225

227226
let supply_ciphertext = supply_keypair.pubkey().encrypt(supply);
228227

229228
let MintProofData {
230229
equality_proof_data,
231230
ciphertext_validity_proof_data_with_ciphertext,
232231
range_proof_data,
233-
new_decryptable_supply: _,
234232
} = mint_split_proof_data(
235233
&supply_ciphertext,
236234
mint_amount,
237235
supply,
238236
&supply_keypair,
239-
&supply_aes_key,
240237
destination_pubkey,
241238
Some(auditor_pubkey),
242239
)

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl SupplyAccountInfo {
5252
/// Computes the current supply from the decryptable supply and the
5353
/// difference between the decryptable supply and the ElGamal encrypted
5454
/// supply ciphertext
55-
pub fn decrypt_current_supply(
55+
pub fn decrypted_current_supply(
5656
&self,
5757
aes_key: &AeKey,
5858
elgamal_keypair: &ElGamalKeypair,
@@ -91,7 +91,7 @@ impl SupplyAccountInfo {
9191
new_supply_elgamal_keypair: &ElGamalKeypair,
9292
) -> Result<CiphertextCiphertextEqualityProofData, TokenError> {
9393
let current_supply =
94-
self.decrypt_current_supply(aes_key, current_supply_elgamal_keypair)?;
94+
self.decrypted_current_supply(aes_key, current_supply_elgamal_keypair)?;
9595

9696
let new_supply_opening = PedersenOpening::new_rand();
9797
let new_supply_ciphertext = new_supply_elgamal_keypair
@@ -119,7 +119,6 @@ impl SupplyAccountInfo {
119119
mint_amount: u64,
120120
current_supply: u64,
121121
supply_elgamal_keypair: &ElGamalKeypair,
122-
aes_key: &AeKey,
123122
destination_elgamal_pubkey: &ElGamalPubkey,
124123
auditor_elgamal_pubkey: Option<&ElGamalPubkey>,
125124
) -> Result<MintProofData, TokenError> {
@@ -133,12 +132,26 @@ impl SupplyAccountInfo {
133132
mint_amount,
134133
current_supply,
135134
supply_elgamal_keypair,
136-
aes_key,
137135
destination_elgamal_pubkey,
138136
auditor_elgamal_pubkey,
139137
)
140138
.map_err(|e| -> TokenError { e.into() })
141139
}
140+
141+
/// Compute the new decryptable supply.
142+
pub fn new_decryptable_supply(
143+
&self,
144+
mint_amount: u64,
145+
aes_key: &AeKey,
146+
elgamal_keypair: &ElGamalKeypair, // TODO: check consistency of the order of params
147+
) -> Result<AeCiphertext, TokenError> {
148+
let current_decrypted_supply = self.decrypted_current_supply(aes_key, elgamal_keypair)?;
149+
let new_decrypted_available_balance = current_decrypted_supply
150+
.checked_add(mint_amount)
151+
.ok_or(TokenError::Overflow)?;
152+
153+
Ok(aes_key.encrypt(new_decrypted_available_balance))
154+
}
142155
}
143156

144157
/// Confidential Mint Burn extension information needed to construct a

0 commit comments

Comments
 (0)