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

Commit c2ec29a

Browse files
committed
review fixes
1 parent f795a3f commit c2ec29a

File tree

8 files changed

+529
-342
lines changed

8 files changed

+529
-342
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub mod burn;
1010
pub mod encryption;
1111
pub mod errors;
1212
pub mod mint;
13+
pub mod supply;
1314
pub mod transfer;
1415
pub mod transfer_with_fee;
1516
pub mod withdraw;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub fn mint_split_proof_data(
8080
.ok_or(TokenProofGenerationError::IllegalAmountBitLength)?;
8181

8282
// fresh mints are initialized with a zeroed decryptable_supply
83-
// TODO: @samkim is there a better way to do this?
83+
// TODO: don't clone here once AeCiphertext implement Copy in the zk-sdk
8484
let pod_decryptable_supply: PodAeCiphertext = current_decryptable_supply.clone().into();
8585
let current_decyptable_supply = if pod_decryptable_supply != PodAeCiphertext::default() {
8686
// decrypt the current supply
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
use {
2+
crate::errors::TokenProofGenerationError,
3+
solana_zk_sdk::{
4+
encryption::{
5+
elgamal::{ElGamalCiphertext, ElGamalKeypair},
6+
pedersen::PedersenOpening,
7+
},
8+
zk_elgamal_proof_program::proof_data::CiphertextCiphertextEqualityProofData,
9+
},
10+
};
11+
12+
pub fn supply_elgamal_pubkey_rotation_proof(
13+
current_supply: u64,
14+
supply_elgamal_keypair: &ElGamalKeypair,
15+
new_supply_elgamal_keypair: &ElGamalKeypair,
16+
current_supply_ciphertext: ElGamalCiphertext,
17+
) -> Result<CiphertextCiphertextEqualityProofData, TokenProofGenerationError> {
18+
let new_supply_opening = PedersenOpening::new_rand();
19+
let new_supply_ciphertext = new_supply_elgamal_keypair
20+
.pubkey()
21+
.encrypt_with(current_supply, &new_supply_opening);
22+
23+
Ok(CiphertextCiphertextEqualityProofData::new(
24+
supply_elgamal_keypair,
25+
new_supply_elgamal_keypair.pubkey(),
26+
&current_supply_ciphertext,
27+
&new_supply_ciphertext,
28+
&new_supply_opening,
29+
current_supply,
30+
)?)
31+
}

0 commit comments

Comments
 (0)