Skip to content

Commit

Permalink
move ProofVerificationError to elgamal-program module
Browse files Browse the repository at this point in the history
  • Loading branch information
samkim-crypto committed May 8, 2024
1 parent 59fc814 commit fa9ab7d
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
7 changes: 7 additions & 0 deletions zk-sdk/src/elgamal_program/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use thiserror::Error;

#[derive(Error, Clone, Debug, Eq, PartialEq)]
pub enum ProofVerificationError {
#[error("Invalid proof context")]
ProofContext,
}
1 change: 1 addition & 0 deletions zk-sdk/src/elgamal_program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion zk-sdk/src/elgamal_program/proof_data/errors.rs
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion zk-sdk/src/elgamal_program/proof_data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
crate::errors::ProofVerificationError,
crate::elgamal_program::errors::ProofVerificationError,
bytemuck::Pod,
num_derive::{FromPrimitive, ToPrimitive},
};
Expand Down
4 changes: 2 additions & 2 deletions zk-sdk/src/elgamal_program/proof_data/pod.rs
Original file line number Diff line number Diff line change
@@ -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},
};
Expand All @@ -13,7 +13,7 @@ impl From<ProofType> for PodProofType {
}
}
impl TryFrom<PodProofType> for ProofType {
type Error = ElGamalProofProgramError;
type Error = ProofDataError;

fn try_from(pod: PodProofType) -> Result<Self, Self::Error> {
FromPrimitive::from_u8(pod.0).ok_or(Self::Error::InvalidProofType)
Expand Down
6 changes: 0 additions & 6 deletions zk-sdk/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit fa9ab7d

Please sign in to comment.