Skip to content

Commit

Permalink
[zk-sdk] Rename elgamal_program to zk_elgamal_proof_program module (
Browse files Browse the repository at this point in the history
anza-xyz#1698)

* rename `elgamal_program` to `zk_elgamal_proof_program`

* update dependencies outside of `zk-sdk`
  • Loading branch information
samkim-crypto committed Jul 31, 2024
1 parent fe11487 commit c046d70
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 120 deletions.
2 changes: 1 addition & 1 deletion programs/zk-elgamal-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
bytemuck::Pod,
solana_program_runtime::{declare_process_instruction, ic_msg, invoke_context::InvokeContext},
solana_sdk::{instruction::InstructionError, system_program},
solana_zk_sdk::elgamal_program::{
solana_zk_sdk::zk_elgamal_proof_program::{
id,
instruction::ProofInstruction,
proof_data::*,
Expand Down
2 changes: 1 addition & 1 deletion zk-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
// `clippy::op_ref` is turned off to prevent clippy from warning that this is not idiomatic code.
#![allow(clippy::arithmetic_side_effects, clippy::op_ref)]

pub mod elgamal_program;
pub mod encryption;
pub mod errors;
pub mod pod;
mod range_proof;
mod sigma_proofs;
mod transcript;
pub mod zk_elgamal_proof_program;

/// Byte length of a compressed Ristretto point or scalar in Curve255519
const UNIT_LEN: usize = 32;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
//! [`context-state`]: https://docs.solanalabs.com/runtime/zk-token-proof#context-data
use {
crate::elgamal_program::proof_data::ZkProofData,
crate::zk_elgamal_proof_program::proof_data::ZkProofData,
bytemuck::{bytes_of, Pod},
num_derive::{FromPrimitive, ToPrimitive},
num_traits::{FromPrimitive, ToPrimitive},
Expand Down Expand Up @@ -306,7 +306,7 @@ pub fn close_context_state(
let data = vec![ToPrimitive::to_u8(&ProofInstruction::CloseContextState).unwrap()];

Instruction {
program_id: crate::elgamal_program::id(),
program_id: crate::zk_elgamal_proof_program::id(),
accounts,
data,
}
Expand Down Expand Up @@ -335,7 +335,7 @@ impl ProofInstruction {
data.extend_from_slice(bytes_of(proof_data));

Instruction {
program_id: crate::elgamal_program::id(),
program_id: crate::zk_elgamal_proof_program::id(),
accounts,
data,
}
Expand All @@ -361,7 +361,7 @@ impl ProofInstruction {
data.extend_from_slice(&offset.to_le_bytes());

Instruction {
program_id: crate::elgamal_program::id(),
program_id: crate::zk_elgamal_proof_program::id(),
accounts,
data,
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
//! grouped-ciphertext validity proof is shorter and more efficient than two individual
//! grouped-ciphertext validity proofs.
use {
crate::{
encryption::pod::{
elgamal::PodElGamalPubkey, grouped_elgamal::PodGroupedElGamalCiphertext2Handles,
},
sigma_proofs::pod::PodBatchedGroupedCiphertext2HandlesValidityProof,
zk_elgamal_proof_program::proof_data::{ProofType, ZkProofData},
},
bytemuck::{Pod, Zeroable},
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::errors::{ProofGenerationError, ProofVerificationError},
encryption::{
elgamal::ElGamalPubkey, grouped_elgamal::GroupedElGamalCiphertext,
pedersen::PedersenOpening,
},
sigma_proofs::batched_grouped_ciphertext_validity::BatchedGroupedCiphertext2HandlesValidityProof,
zk_elgamal_proof_program::errors::{ProofGenerationError, ProofVerificationError},
},
bytemuck::bytes_of,
merlin::Transcript,
};
use {
crate::{
elgamal_program::proof_data::{ProofType, ZkProofData},
encryption::pod::{
elgamal::PodElGamalPubkey, grouped_elgamal::PodGroupedElGamalCiphertext2Handles,
},
sigma_proofs::pod::PodBatchedGroupedCiphertext2HandlesValidityProof,
},
bytemuck::{Pod, Zeroable},
};

/// The instruction data that is needed for the
/// `ProofInstruction::VerifyBatchedGroupedCiphertextValidity` instruction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@
//! grouped-ciphertext validity proof is shorter and more efficient than two individual
//! grouped-ciphertext validity proofs.
use {
crate::{
encryption::pod::{
elgamal::PodElGamalPubkey, grouped_elgamal::PodGroupedElGamalCiphertext3Handles,
},
sigma_proofs::pod::PodBatchedGroupedCiphertext3HandlesValidityProof,
zk_elgamal_proof_program::proof_data::{ProofType, ZkProofData},
},
bytemuck::{Pod, Zeroable},
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::errors::{ProofGenerationError, ProofVerificationError},
encryption::{
elgamal::ElGamalPubkey, grouped_elgamal::GroupedElGamalCiphertext,
pedersen::PedersenOpening,
},
sigma_proofs::batched_grouped_ciphertext_validity::BatchedGroupedCiphertext3HandlesValidityProof,
zk_elgamal_proof_program::errors::{ProofGenerationError, ProofVerificationError},
},
bytemuck::bytes_of,
merlin::Transcript,
};
use {
crate::{
elgamal_program::proof_data::{ProofType, ZkProofData},
encryption::pod::{
elgamal::PodElGamalPubkey, grouped_elgamal::PodGroupedElGamalCiphertext3Handles,
},
sigma_proofs::pod::PodBatchedGroupedCiphertext3HandlesValidityProof,
},
bytemuck::{Pod, Zeroable},
};

/// The instruction data that is needed for the
/// `ProofInstruction::VerifyBatchedGroupedCiphertext3HandlesValidity` instruction.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//! The 128-bit batched range proof instruction.
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::proof_data::{
batched_range_proof::BatchedRangeProofContext, ProofType, ZkProofData,
encryption::pedersen::{PedersenCommitment, PedersenOpening},
range_proof::RangeProof,
zk_elgamal_proof_program::{
errors::{ProofGenerationError, ProofVerificationError},
proof_data::batched_range_proof::MAX_COMMITMENTS,
},
range_proof::pod::PodRangeProofU128,
},
bytemuck::{Pod, Zeroable},
std::convert::TryInto,
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::{
errors::{ProofGenerationError, ProofVerificationError},
proof_data::batched_range_proof::MAX_COMMITMENTS,
range_proof::pod::PodRangeProofU128,
zk_elgamal_proof_program::proof_data::{
batched_range_proof::BatchedRangeProofContext, ProofType, ZkProofData,
},
encryption::pedersen::{PedersenCommitment, PedersenOpening},
range_proof::RangeProof,
},
std::convert::TryInto,
bytemuck::{Pod, Zeroable},
};

/// The instruction data that is needed for the
Expand Down Expand Up @@ -102,8 +102,8 @@ mod test {
use {
super::*,
crate::{
elgamal_program::errors::ProofVerificationError, encryption::pedersen::Pedersen,
range_proof::errors::RangeProofVerificationError,
encryption::pedersen::Pedersen, range_proof::errors::RangeProofVerificationError,
zk_elgamal_proof_program::errors::ProofVerificationError,
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//! The 256-bit batched range proof instruction.
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::proof_data::{
batched_range_proof::BatchedRangeProofContext, ProofType, ZkProofData,
encryption::pedersen::{PedersenCommitment, PedersenOpening},
range_proof::RangeProof,
zk_elgamal_proof_program::{
errors::{ProofGenerationError, ProofVerificationError},
proof_data::batched_range_proof::{MAX_COMMITMENTS, MAX_SINGLE_BIT_LENGTH},
},
range_proof::pod::PodRangeProofU256,
},
bytemuck::{Pod, Zeroable},
std::convert::TryInto,
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::{
errors::{ProofGenerationError, ProofVerificationError},
proof_data::batched_range_proof::{MAX_COMMITMENTS, MAX_SINGLE_BIT_LENGTH},
range_proof::pod::PodRangeProofU256,
zk_elgamal_proof_program::proof_data::{
batched_range_proof::BatchedRangeProofContext, ProofType, ZkProofData,
},
encryption::pedersen::{PedersenCommitment, PedersenOpening},
range_proof::RangeProof,
},
std::convert::TryInto,
bytemuck::{Pod, Zeroable},
};

#[cfg(not(target_os = "solana"))]
Expand Down Expand Up @@ -116,8 +116,8 @@ mod test {
use {
super::*,
crate::{
elgamal_program::errors::ProofVerificationError, encryption::pedersen::Pedersen,
range_proof::errors::RangeProofVerificationError,
encryption::pedersen::Pedersen, range_proof::errors::RangeProofVerificationError,
zk_elgamal_proof_program::errors::ProofVerificationError,
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
//! The 64-bit batched range proof instruction.
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::proof_data::{
batched_range_proof::BatchedRangeProofContext, ProofType, ZkProofData,
encryption::pedersen::{PedersenCommitment, PedersenOpening},
range_proof::RangeProof,
zk_elgamal_proof_program::{
errors::{ProofGenerationError, ProofVerificationError},
proof_data::batched_range_proof::MAX_COMMITMENTS,
},
range_proof::pod::PodRangeProofU64,
},
bytemuck::{Pod, Zeroable},
std::convert::TryInto,
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::{
errors::{ProofGenerationError, ProofVerificationError},
proof_data::batched_range_proof::MAX_COMMITMENTS,
range_proof::pod::PodRangeProofU64,
zk_elgamal_proof_program::proof_data::{
batched_range_proof::BatchedRangeProofContext, ProofType, ZkProofData,
},
encryption::pedersen::{PedersenCommitment, PedersenOpening},
range_proof::RangeProof,
},
std::convert::TryInto,
bytemuck::{Pod, Zeroable},
};

/// The instruction data that is needed for the
Expand Down Expand Up @@ -101,8 +101,8 @@ mod test {
use {
super::*,
crate::{
elgamal_program::errors::ProofVerificationError, encryption::pedersen::Pedersen,
range_proof::errors::RangeProofVerificationError,
encryption::pedersen::Pedersen, range_proof::errors::RangeProofVerificationError,
zk_elgamal_proof_program::errors::ProofVerificationError,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use {
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::errors::{ProofGenerationError, ProofVerificationError},
encryption::pedersen::{PedersenCommitment, PedersenOpening},
zk_elgamal_proof_program::errors::{ProofGenerationError, ProofVerificationError},
},
bytemuck::bytes_of,
curve25519_dalek::traits::IsIdentity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
//! the proof, a prover must provide the decryption key for the first ciphertext and the randomness
//! used to generate the second ciphertext.
use {
crate::{
encryption::pod::elgamal::{PodElGamalCiphertext, PodElGamalPubkey},
sigma_proofs::pod::PodCiphertextCiphertextEqualityProof,
zk_elgamal_proof_program::proof_data::{ProofType, ZkProofData},
},
bytemuck::{Pod, Zeroable},
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::errors::{ProofGenerationError, ProofVerificationError},
encryption::{
elgamal::{ElGamalCiphertext, ElGamalKeypair, ElGamalPubkey},
pedersen::PedersenOpening,
},
sigma_proofs::ciphertext_ciphertext_equality::CiphertextCiphertextEqualityProof,
zk_elgamal_proof_program::errors::{ProofGenerationError, ProofVerificationError},
},
bytemuck::bytes_of,
merlin::Transcript,
std::convert::TryInto,
};
use {
crate::{
elgamal_program::proof_data::{ProofType, ZkProofData},
encryption::pod::elgamal::{PodElGamalCiphertext, PodElGamalPubkey},
sigma_proofs::pod::PodCiphertextCiphertextEqualityProof,
},
bytemuck::{Pod, Zeroable},
};

/// The instruction data that is needed for the
/// `ProofInstruction::VerifyCiphertextCiphertextEquality` instruction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,31 @@
//! encrypts/encodes the same message. To generate the proof, a prover must provide the decryption
//! key for the first ciphertext and the Pedersen opening for the commitment.
use {
crate::{
encryption::pod::{
elgamal::{PodElGamalCiphertext, PodElGamalPubkey},
pedersen::PodPedersenCommitment,
},
sigma_proofs::pod::PodCiphertextCommitmentEqualityProof,
zk_elgamal_proof_program::proof_data::{ProofType, ZkProofData},
},
bytemuck::{Pod, Zeroable},
};
#[cfg(not(target_os = "solana"))]
use {
crate::{
elgamal_program::errors::{ProofGenerationError, ProofVerificationError},
encryption::{
elgamal::{ElGamalCiphertext, ElGamalKeypair},
pedersen::{PedersenCommitment, PedersenOpening},
},
sigma_proofs::ciphertext_commitment_equality::CiphertextCommitmentEqualityProof,
zk_elgamal_proof_program::errors::{ProofGenerationError, ProofVerificationError},
},
bytemuck::bytes_of,
merlin::Transcript,
std::convert::TryInto,
};
use {
crate::{
elgamal_program::proof_data::{ProofType, ZkProofData},
encryption::pod::{
elgamal::{PodElGamalCiphertext, PodElGamalPubkey},
pedersen::PodPedersenCommitment,
},
sigma_proofs::pod::PodCiphertextCommitmentEqualityProof,
},
bytemuck::{Pod, Zeroable},
};
/// The instruction data that is needed for the
/// `ProofInstruction::VerifyCiphertextCommitmentEquality` instruction.
///
Expand Down
Loading

0 comments on commit c046d70

Please sign in to comment.