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

Commit 42e0193

Browse files
committed
fix clippy; serde logic
1 parent e010003 commit 42e0193

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub fn mint_split_proof_data(
9696
let decryptable_supply_ciphertext = supply_elgamal_keypair
9797
.pubkey()
9898
.encrypt(current_decyptable_supply);
99+
#[allow(clippy::arithmetic_side_effects)]
99100
let ct_decryptable_to_current_diff = decryptable_supply_ciphertext - current_supply_ciphertext;
100101
let decryptable_to_current_diff = supply_elgamal_keypair
101102
.secret()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ fn test_mint_validity(mint_amount: u64, supply: u64) {
223223
equality_proof_data,
224224
ciphertext_validity_proof_data,
225225
range_proof_data,
226+
new_decryptable_supply: _,
226227
} = mint_split_proof_data(
227228
&supply_ciphertext,
228229
&decryptable_supply,

token/program-2022/src/serialization.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
//! serialization module - contains helpers for serde types from other crates,
22
//! deserialization visitors
33
4-
use {
5-
base64::{prelude::BASE64_STANDARD, Engine},
6-
serde::de::Error,
7-
};
8-
94
/// helper function to ser/deser COption wrapped values
105
pub mod coption_fromstr {
116
use {
@@ -135,24 +130,22 @@ pub mod elgamalciphertext_fromstr {
135130
de::{Error, Visitor},
136131
Deserializer, Serializer,
137132
},
138-
solana_zk_token_sdk::zk_token_elgamal::pod::ElGamalCiphertext,
139-
std::fmt,
133+
solana_zk_sdk::encryption::pod::elgamal::PodElGamalCiphertext,
134+
std::{fmt, str::FromStr},
140135
};
141136

142-
const AE_CIPHERTEXT_LEN: usize = 64;
143-
144137
/// serialize AeCiphertext values supporting Display trait
145-
pub fn serialize<S>(x: &ElGamalCiphertext, s: S) -> Result<S::Ok, S::Error>
138+
pub fn serialie<S>(x: &PodElGamalCiphertext, s: S) -> Result<S::Ok, S::Error>
146139
where
147140
S: Serializer,
148141
{
149142
s.serialize_str(&x.to_string())
150143
}
151144

152-
struct AeCiphertextVisitor;
145+
struct ElGamalCiphertextVisitor;
153146

154-
impl<'de> Visitor<'de> for AeCiphertextVisitor {
155-
type Value = ElGamalCiphertext;
147+
impl<'de> Visitor<'de> for ElGamalCiphertextVisitor {
148+
type Value = PodElGamalCiphertext;
156149

157150
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
158151
formatter.write_str("a FromStr type")
@@ -162,17 +155,16 @@ pub mod elgamalciphertext_fromstr {
162155
where
163156
E: Error,
164157
{
165-
let array = super::base64_to_bytes::<AE_CIPHERTEXT_LEN, E>(v)?;
166-
Ok(ElGamalCiphertext(array))
158+
FromStr::from_str(v).map_err(Error::custom)
167159
}
168160
}
169161

170162
/// deserialize AeCiphertext values from str
171-
pub fn deserialize<'de, D>(d: D) -> Result<ElGamalCiphertext, D::Error>
163+
pub fn deserialize<'de, D>(d: D) -> Result<PodElGamalCiphertext, D::Error>
172164
where
173165
D: Deserializer<'de>,
174166
{
175-
d.deserialize_str(AeCiphertextVisitor)
167+
d.deserialize_str(ElGamalCiphertextVisitor)
176168
}
177169
}
178170

token/program-2022/tests/serialization.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@ use {
55
solana_program::program_option::COption,
66
solana_sdk::pubkey::Pubkey,
77
spl_pod::optional_keys::{OptionalNonZeroElGamalPubkey, OptionalNonZeroPubkey},
8-
spl_token_2022::{
9-
extension::confidential_transfer,
10-
instruction,
11-
solana_zk_sdk::encryption::pod::{
12-
auth_encryption::PodAeCiphertext, elgamal::PodElGamalPubkey,
13-
},
14-
},
8+
spl_token_2022::{extension::confidential_transfer, instruction},
159
std::str::FromStr,
1610
};
1711

0 commit comments

Comments
 (0)