Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
255 changes: 149 additions & 106 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clients/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ solana-remote-wallet = { version = "3.1.0", features = ["agave-unstable-api"] }
solana-sdk = "3.0.0"
solana-system-interface = "3.0.0"
solana-transaction-status = "3.0.0"
solana-zk-sdk-pod = "0.1.0"
spl-associated-token-account-interface = { version = "2.0.0" }
spl-pod = { version = "0.7.2" }
spl-token-interface = "2.0.0"
Expand Down
17 changes: 7 additions & 10 deletions clients/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use {
signature::{Keypair, Signer},
},
solana_system_interface::program as system_program,
solana_zk_sdk_pod::encryption::elgamal::PodElGamalPubkey,
spl_associated_token_account_interface::address::get_associated_token_address_with_program_id,
spl_pod::optional_keys::OptionalNonZeroPubkey,
spl_token_2022::extension::confidential_transfer::account_info::{
Expand Down Expand Up @@ -60,8 +61,7 @@ use {
},
solana_zk_sdk::encryption::{
auth_encryption::AeKey,
elgamal::{self, ElGamalKeypair},
pod::elgamal::PodElGamalPubkey,
elgamal::{ElGamalKeypair, ElGamalPubkey},
},
state::{Account, AccountState, Mint},
},
Expand Down Expand Up @@ -1653,14 +1653,11 @@ async fn command_transfer(
}
(None, None, Some(args)) => {
// deserialize `pod` ElGamal pubkeys
let recipient_elgamal_pubkey: elgamal::ElGamalPubkey = recipient_elgamal_pubkey
.unwrap()
.try_into()
.expect("Invalid recipient ElGamal pubkey");
let auditor_elgamal_pubkey = auditor_elgamal_pubkey.map(|pubkey| {
let auditor_elgamal_pubkey: elgamal::ElGamalPubkey =
pubkey.try_into().expect("Invalid auditor ElGamal pubkey");
auditor_elgamal_pubkey
let recipient_elgamal_pubkey =
ElGamalPubkey::try_from(recipient_elgamal_pubkey.unwrap().0.as_ref())
.expect("Invalid recipient ElGamal pubkey");
let auditor_elgamal_pubkey = auditor_elgamal_pubkey.map(|pubkey: PodElGamalPubkey| {
ElGamalPubkey::try_from(pubkey.0.as_ref()).expect("Invalid auditor ElGamal pubkey")
});

let context_state_authority = config.fee_payer()?;
Expand Down
10 changes: 4 additions & 6 deletions clients/cli/src/encryption_keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use {
base64::{prelude::BASE64_STANDARD, Engine},
clap::ArgMatches,
spl_token_2022_interface::solana_zk_sdk::encryption::{
elgamal::{ElGamalKeypair, ElGamalPubkey},
pod::elgamal::PodElGamalPubkey,
},
solana_zk_sdk_pod::encryption::elgamal::PodElGamalPubkey,
spl_token_2022_interface::solana_zk_sdk::encryption::elgamal::{ElGamalKeypair, ElGamalPubkey},
};

const ELGAMAL_PUBKEY_MAX_BASE64_LEN: usize = 44;
Expand Down Expand Up @@ -45,7 +43,7 @@ pub(crate) fn elgamal_pubkey_of(
name: &str,
) -> Result<PodElGamalPubkey, String> {
if let Ok(keypair) = elgamal_keypair_of(matches, name) {
let elgamal_pubkey = (*keypair.pubkey()).into();
let elgamal_pubkey = PodElGamalPubkey(keypair.pubkey().into());
Ok(elgamal_pubkey)
} else {
let arg_str = matches.value_of(name).unwrap();
Expand All @@ -71,5 +69,5 @@ fn elgamal_pubkey_from_str(s: &str) -> Option<PodElGamalPubkey> {
}
let pubkey_vec = BASE64_STANDARD.decode(s).ok()?;
let elgamal_pubkey = ElGamalPubkey::try_from(pubkey_vec.as_ref()).ok()?;
Some(elgamal_pubkey.into())
Some(PodElGamalPubkey(elgamal_pubkey.into()))
}
4 changes: 2 additions & 2 deletions clients/cli/tests/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use {
solana_sdk_ids::bpf_loader_upgradeable,
solana_system_interface::{instruction as system_instruction, program as system_program},
solana_test_validator::{TestValidator, TestValidatorGenesis, UpgradeableProgramInfo},
solana_zk_sdk_pod::encryption::elgamal::PodElGamalPubkey,
spl_associated_token_account_interface::address::get_associated_token_address_with_program_id,
spl_token_2022_interface::{
extension::{
Expand All @@ -35,7 +36,6 @@ use {
BaseStateWithExtensions, ExtensionType, StateWithExtensionsOwned,
},
instruction::create_native_mint,
solana_zk_sdk::encryption::pod::elgamal::PodElGamalPubkey,
state::{Account, AccountState, Mint, Multisig},
},
spl_token_cli::{
Expand Down Expand Up @@ -2957,7 +2957,7 @@ async fn confidential_transfer(test_validator: &TestValidator, payer: &Keypair)

// update confidential transfer mint settings
let auditor_keypair = ElGamalKeypair::new_rand();
let auditor_pubkey: PodElGamalPubkey = (*auditor_keypair.pubkey()).into();
let auditor_pubkey = PodElGamalPubkey(auditor_keypair.pubkey().into());
let new_auto_approve = true;

process_test_command(
Expand Down
1 change: 1 addition & 0 deletions clients/rust-legacy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ solana-signature = "3.0.0"
solana-signer = "3.0.0"
solana-system-interface = "3.0.0"
solana-transaction = "3.0.0"
solana-zk-sdk-pod = "0.1.0"
spl-associated-token-account-interface = { version = "2.0.0" }
spl-elgamal-registry = { version = "0.4.0", path = "../../confidential/elgamal-registry", features = ["no-entrypoint"] }
spl-memo-interface = "2.0.0"
Expand Down
5 changes: 3 additions & 2 deletions clients/rust-legacy/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use {
solana_signer::{signers::Signers, Signer, SignerError},
solana_system_interface::instruction as system_instruction,
solana_transaction::Transaction,
solana_zk_sdk_pod::encryption::elgamal::PodElGamalPubkey as ZkPodElGamalPubkey,
spl_associated_token_account_interface::{
address::get_associated_token_address_with_program_id,
instruction::{
Expand Down Expand Up @@ -152,7 +153,7 @@ pub enum ExtensionInitializationParams {
ConfidentialTransferMint {
authority: Option<Pubkey>,
auto_approve_new_accounts: bool,
auditor_elgamal_pubkey: Option<PodElGamalPubkey>,
auditor_elgamal_pubkey: Option<ZkPodElGamalPubkey>,
},
DefaultAccountState {
state: AccountState,
Expand Down Expand Up @@ -2036,7 +2037,7 @@ where
&self,
authority: &Pubkey,
auto_approve_new_account: bool,
auditor_elgamal_pubkey: Option<PodElGamalPubkey>,
auditor_elgamal_pubkey: Option<ZkPodElGamalPubkey>,
signing_keypairs: &S,
) -> TokenResult<T::Output> {
let signing_pubkeys = signing_keypairs.pubkeys();
Expand Down
31 changes: 17 additions & 14 deletions clients/rust-legacy/tests/confidential_mint_burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use {
transaction::TransactionError,
transport::TransportError,
},
solana_zk_sdk_pod::encryption::elgamal::PodElGamalPubkey as ZkPodElGamalPubkey,
spl_token_2022::extension::confidential_mint_burn::account_info::{
BurnAccountInfo, SupplyAccountInfo,
},
Expand All @@ -22,7 +23,9 @@ use {
},
instruction::AuthorityType,
solana_zk_sdk::encryption::{
auth_encryption::*, elgamal::*, pod::elgamal::PodElGamalCiphertext,
auth_encryption::*,
elgamal::*,
pod::elgamal::{PodElGamalCiphertext, PodElGamalPubkey},
},
},
spl_token_client::{
Expand Down Expand Up @@ -93,10 +96,10 @@ async fn confidential_mint_burn_config() {
let confidential_transfer_authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
let auditor_elgamal_pubkey = ZkPodElGamalPubkey(auditor_elgamal_keypair.pubkey().into());

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());

let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();
Expand Down Expand Up @@ -247,10 +250,10 @@ async fn confidential_mint_burn_rotate_supply_elgamal_pubkey_with_option(
let confidential_transfer_authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
let auditor_elgamal_pubkey = ZkPodElGamalPubkey(auditor_elgamal_keypair.pubkey().into());

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());
let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();

Expand Down Expand Up @@ -386,10 +389,10 @@ async fn confidential_mint_burn_update_decryptable_supply() {
let confidential_transfer_authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
let auditor_elgamal_pubkey = ZkPodElGamalPubkey(auditor_elgamal_keypair.pubkey().into());

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());
let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();

Expand Down Expand Up @@ -792,10 +795,10 @@ async fn confidential_mint_burn_with_option(option: ConfidentialTransferOption)
let confidential_transfer_authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
let auditor_elgamal_pubkey = ZkPodElGamalPubkey(auditor_elgamal_keypair.pubkey().into());

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());
let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();

Expand Down Expand Up @@ -1074,10 +1077,10 @@ async fn pause_confidential_mint_burn() {
let confidential_transfer_authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
let auditor_elgamal_pubkey = ZkPodElGamalPubkey(auditor_elgamal_keypair.pubkey().into());

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());
let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();

Expand Down Expand Up @@ -1207,10 +1210,10 @@ async fn fail_close_mint_with_confidential_supply() {
let confidential_transfer_authority = Keypair::new();
let auto_approve_new_accounts = true;
let auditor_elgamal_keypair = ElGamalKeypair::new_rand();
let auditor_elgamal_pubkey = (*auditor_elgamal_keypair.pubkey()).into();
let auditor_elgamal_pubkey = ZkPodElGamalPubkey(auditor_elgamal_keypair.pubkey().into());

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());
let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();

Expand Down Expand Up @@ -1305,7 +1308,7 @@ async fn confidential_burn_no_auditor() {
let auto_approve_new_accounts = true;

let supply_elgamal_keypair = ElGamalKeypair::new_rand();
let supply_elgamal_pubkey = (*supply_elgamal_keypair.pubkey()).into();
let supply_elgamal_pubkey = PodElGamalPubkey::from(*supply_elgamal_keypair.pubkey());
let supply_aes_key = AeKey::new_rand();
let decryptable_supply = supply_aes_key.encrypt(0).into();

Expand Down
Loading
Loading