From e7e54fa3f8711271c8606c561c61fd1d53fe41d1 Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Sun, 25 Jan 2026 17:10:40 +0900 Subject: [PATCH] deprecate `OptionalNonZeroElGamalPubkey` in `spl-pod` --- pod/src/optional_keys.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pod/src/optional_keys.rs b/pod/src/optional_keys.rs index 82a0726e..a9b6dc51 100644 --- a/pod/src/optional_keys.rs +++ b/pod/src/optional_keys.rs @@ -130,9 +130,14 @@ impl<'de> Deserialize<'de> for OptionalNonZeroPubkey { /// An `ElGamalPubkey` that encodes `None` as all `0`, meant to be usable as a /// `Pod` type. -#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable)] +#[deprecated( + since = "0.7.2", + note = "This type will be removed in a future version. Please use `OptionalNonZeroElGamalPubkey` directly from the `solana-zk-sdk`." +)] +#[derive(Clone, Copy, Debug, Default, PartialEq)] #[repr(transparent)] pub struct OptionalNonZeroElGamalPubkey(PodElGamalPubkey); +#[allow(deprecated)] impl OptionalNonZeroElGamalPubkey { /// Checks equality between an `OptionalNonZeroElGamalPubkey` and an /// `ElGamalPubkey` when interpreted as bytes. @@ -140,6 +145,12 @@ impl OptionalNonZeroElGamalPubkey { &self.0 == other } } +#[allow(deprecated)] +unsafe impl bytemuck::Zeroable for OptionalNonZeroElGamalPubkey {} + +#[allow(deprecated)] +unsafe impl bytemuck::Pod for OptionalNonZeroElGamalPubkey {} +#[allow(deprecated)] impl TryFrom> for OptionalNonZeroElGamalPubkey { type Error = ProgramError; fn try_from(p: Option) -> Result { @@ -155,6 +166,7 @@ impl TryFrom> for OptionalNonZeroElGamalPubkey { } } } +#[allow(deprecated)] impl From for Option { fn from(p: OptionalNonZeroElGamalPubkey) -> Self { if p.0 == PodElGamalPubkey::default() { @@ -165,6 +177,7 @@ impl From for Option { } } +#[allow(deprecated)] #[cfg(feature = "serde-traits")] impl Serialize for OptionalNonZeroElGamalPubkey { fn serialize(&self, s: S) -> Result @@ -182,6 +195,7 @@ impl Serialize for OptionalNonZeroElGamalPubkey { #[cfg(feature = "serde-traits")] struct OptionalNonZeroElGamalPubkeyVisitor; +#[allow(deprecated)] #[cfg(feature = "serde-traits")] impl Visitor<'_> for OptionalNonZeroElGamalPubkeyVisitor { type Value = OptionalNonZeroElGamalPubkey; @@ -206,6 +220,7 @@ impl Visitor<'_> for OptionalNonZeroElGamalPubkeyVisitor { } } +#[allow(deprecated)] #[cfg(feature = "serde-traits")] impl<'de> Deserialize<'de> for OptionalNonZeroElGamalPubkey { fn deserialize(deserializer: D) -> Result @@ -297,6 +312,7 @@ mod tests { } #[test] + #[allow(deprecated)] fn test_pod_non_zero_elgamal_option() { assert_eq!( Some(elgamal_pubkey_from_bytes( @@ -327,6 +343,7 @@ mod tests { #[cfg(feature = "serde-traits")] #[test] + #[allow(deprecated)] fn test_pod_non_zero_elgamal_option_serde_some() { let optional_non_zero_elgamal_pubkey_some = OptionalNonZeroElGamalPubkey( elgamal_pubkey_from_bytes(&[1; OPTIONAL_NONZERO_ELGAMAL_PUBKEY_LEN]), @@ -345,6 +362,7 @@ mod tests { #[cfg(feature = "serde-traits")] #[test] + #[allow(deprecated)] fn test_pod_non_zero_elgamal_option_serde_none() { let optional_non_zero_elgamal_pubkey_none = OptionalNonZeroElGamalPubkey( elgamal_pubkey_from_bytes(&[0; OPTIONAL_NONZERO_ELGAMAL_PUBKEY_LEN]),