From fa9ab7d98cca8233c1b67fc857a4ec7626857108 Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Wed, 8 May 2024 09:28:41 +0900 Subject: [PATCH] move `ProofVerificationError` to `elgamal-program` module --- zk-sdk/src/elgamal_program/errors.rs | 7 +++++++ zk-sdk/src/elgamal_program/mod.rs | 1 + zk-sdk/src/elgamal_program/proof_data/errors.rs | 2 +- zk-sdk/src/elgamal_program/proof_data/mod.rs | 2 +- zk-sdk/src/elgamal_program/proof_data/pod.rs | 4 ++-- zk-sdk/src/errors.rs | 6 ------ 6 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 zk-sdk/src/elgamal_program/errors.rs diff --git a/zk-sdk/src/elgamal_program/errors.rs b/zk-sdk/src/elgamal_program/errors.rs new file mode 100644 index 00000000000000..514140d56d2c87 --- /dev/null +++ b/zk-sdk/src/elgamal_program/errors.rs @@ -0,0 +1,7 @@ +use thiserror::Error; + +#[derive(Error, Clone, Debug, Eq, PartialEq)] +pub enum ProofVerificationError { + #[error("Invalid proof context")] + ProofContext, +} diff --git a/zk-sdk/src/elgamal_program/mod.rs b/zk-sdk/src/elgamal_program/mod.rs index 4cf60792a8938c..b8adc8744893dc 100644 --- a/zk-sdk/src/elgamal_program/mod.rs +++ b/zk-sdk/src/elgamal_program/mod.rs @@ -7,6 +7,7 @@ //! //! [`ZK ElGamal proof`]: https://docs.solanalabs.com/runtime/zk-token-proof +pub mod errors; pub mod instruction; pub mod proof_data; pub mod state; diff --git a/zk-sdk/src/elgamal_program/proof_data/errors.rs b/zk-sdk/src/elgamal_program/proof_data/errors.rs index db15a8cbd24d6d..423981a1a81499 100644 --- a/zk-sdk/src/elgamal_program/proof_data/errors.rs +++ b/zk-sdk/src/elgamal_program/proof_data/errors.rs @@ -1,7 +1,7 @@ use thiserror::Error; #[derive(Error, Clone, Debug, Eq, PartialEq)] -pub enum ElGamalProofProgramError { +pub enum ProofDataError { #[error("decryption error")] Decryption, #[error("missing ciphertext")] diff --git a/zk-sdk/src/elgamal_program/proof_data/mod.rs b/zk-sdk/src/elgamal_program/proof_data/mod.rs index 99fe60ac004882..da3989d5ef74ff 100644 --- a/zk-sdk/src/elgamal_program/proof_data/mod.rs +++ b/zk-sdk/src/elgamal_program/proof_data/mod.rs @@ -1,5 +1,5 @@ use { - crate::errors::ProofVerificationError, + crate::elgamal_program::errors::ProofVerificationError, bytemuck::Pod, num_derive::{FromPrimitive, ToPrimitive}, }; diff --git a/zk-sdk/src/elgamal_program/proof_data/pod.rs b/zk-sdk/src/elgamal_program/proof_data/pod.rs index eb1c75b6279582..7d3f346a684d59 100644 --- a/zk-sdk/src/elgamal_program/proof_data/pod.rs +++ b/zk-sdk/src/elgamal_program/proof_data/pod.rs @@ -1,5 +1,5 @@ use { - crate::elgamal_program::proof_data::{errors::ElGamalProofProgramError, ProofType}, + crate::elgamal_program::proof_data::{errors::ProofDataError, ProofType}, bytemuck::{Pod, Zeroable}, num_traits::{FromPrimitive, ToPrimitive}, }; @@ -13,7 +13,7 @@ impl From for PodProofType { } } impl TryFrom for ProofType { - type Error = ElGamalProofProgramError; + type Error = ProofDataError; fn try_from(pod: PodProofType) -> Result { FromPrimitive::from_u8(pod.0).ok_or(Self::Error::InvalidProofType) diff --git a/zk-sdk/src/errors.rs b/zk-sdk/src/errors.rs index 95f6cdeb44a2e1..fcd8e248cb9f78 100644 --- a/zk-sdk/src/errors.rs +++ b/zk-sdk/src/errors.rs @@ -36,9 +36,3 @@ pub enum TranscriptError { #[error("point is the identity")] ValidationError, } - -#[derive(Error, Clone, Debug, Eq, PartialEq)] -pub enum ProofVerificationError { - #[error("Invalid proof context")] - ProofContext, -}