From 31737406da1e18e054fe2bd351576e273378c333 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 21 Oct 2021 10:49:29 -0700 Subject: [PATCH] Adapt to changes to native program entrypoint --- zk-token-sdk/src/encryption/auth_encryption.rs | 11 +---------- zk-token-sdk/src/encryption/pedersen.rs | 8 +------- zk-token-sdk/src/zk_token_proof_instruction.rs | 10 +++------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/zk-token-sdk/src/encryption/auth_encryption.rs b/zk-token-sdk/src/encryption/auth_encryption.rs index 1027b2acd..c6df99bb7 100644 --- a/zk-token-sdk/src/encryption/auth_encryption.rs +++ b/zk-token-sdk/src/encryption/auth_encryption.rs @@ -97,7 +97,7 @@ pub type Nonce = [u8; 12]; pub type Ciphertext = [u8; 24]; /// Authenticated encryption nonce and ciphertext -#[derive(Debug)] +#[derive(Debug, Default)] pub struct AeCiphertext { pub nonce: Nonce, pub ciphertext: Ciphertext, @@ -129,15 +129,6 @@ impl AeCiphertext { } } -impl Default for AeCiphertext { - fn default() -> Self { - AeCiphertext { - nonce: [0_u8; 12], - ciphertext: [0_u8; 24], - } - } -} - #[cfg(test)] mod tests { use { diff --git a/zk-token-sdk/src/encryption/pedersen.rs b/zk-token-sdk/src/encryption/pedersen.rs index 462e9ae8b..7f17a6b7b 100644 --- a/zk-token-sdk/src/encryption/pedersen.rs +++ b/zk-token-sdk/src/encryption/pedersen.rs @@ -70,7 +70,7 @@ impl Pedersen { } } -#[derive(Serialize, Deserialize, Clone, Debug, Zeroize)] +#[derive(Serialize, Deserialize, Default, Clone, Debug, Zeroize)] #[zeroize(drop)] pub struct PedersenOpening(pub(crate) Scalar); impl PedersenOpening { @@ -107,12 +107,6 @@ impl ConstantTimeEq for PedersenOpening { } } -impl Default for PedersenOpening { - fn default() -> Self { - PedersenOpening(Scalar::default()) - } -} - impl<'a, 'b> Add<&'b PedersenOpening> for &'a PedersenOpening { type Output = PedersenOpening; diff --git a/zk-token-sdk/src/zk_token_proof_instruction.rs b/zk-token-sdk/src/zk_token_proof_instruction.rs index 576e2c559..c35ef4853 100644 --- a/zk-token-sdk/src/zk_token_proof_instruction.rs +++ b/zk-token-sdk/src/zk_token_proof_instruction.rs @@ -4,7 +4,7 @@ use { bytemuck::{bytes_of, Pod}, num_derive::{FromPrimitive, ToPrimitive}, num_traits::{FromPrimitive, ToPrimitive}, - solana_program::{instruction::Instruction, pubkey::Pubkey}, + solana_program::instruction::Instruction, }; #[derive(Clone, Copy, Debug, FromPrimitive, ToPrimitive, PartialEq)] @@ -52,12 +52,8 @@ impl ProofInstruction { } } - pub fn decode_type(program_id: &Pubkey, input: &[u8]) -> Option { - if *program_id != crate::zk_token_proof_program::id() || input.is_empty() { - None - } else { - FromPrimitive::from_u8(input[0]) - } + pub fn decode_type(input: &[u8]) -> Option { + FromPrimitive::from_u8(input[0]) } pub fn decode_data(input: &[u8]) -> Option<&T> {