Skip to content

Commit

Permalink
primitives: elgamal: publicize key fields
Browse files Browse the repository at this point in the history
  • Loading branch information
joeykraut committed Feb 25, 2024
1 parent 8fd52e2 commit 38d13e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion plonk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ test_apis = ["ark-bn254", "rand", "ark-mpc/test_helpers"]
parallel = [
"ark-ec/parallel",
"ark-ff/parallel",
"ark-mpc/multithreaded_executor",
"ark-poly/parallel",
"ark-std/parallel",
"jf-utils/parallel",
Expand Down
19 changes: 14 additions & 5 deletions primitives/src/elgamal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ pub struct EncKey<P>
where
P: Config,
{
pub(crate) key: Projective<P>,
/// The underlying elliptic curve point
pub key: Projective<P>,
}

impl<P: Config> Hash for EncKey<P> {
Expand All @@ -69,11 +70,12 @@ impl<P: Config> PartialEq for EncKey<P> {
Clone(bound = "P: Config"),
PartialEq(bound = "P: Config")
)]
pub(crate) struct DecKey<P>
pub struct DecKey<P>
where
P: Config,
{
key: P::ScalarField,
/// The underlying field element of the key
pub key: P::ScalarField,
}

impl<P: Config> Drop for DecKey<P> {
Expand Down Expand Up @@ -117,8 +119,10 @@ pub struct Ciphertext<P>
where
P: Config,
{
pub(crate) ephemeral: EncKey<P>,
pub(crate) data: Vec<P::BaseField>,
/// The ephemeral key used for encryption
pub ephemeral: EncKey<P>,
/// The encrypted data
pub data: Vec<P::BaseField>,
}

impl<P> Ciphertext<P>
Expand Down Expand Up @@ -166,6 +170,11 @@ where
KeyPair { enc, dec }
}

/// Get the decryption key
pub fn dec_key(&self) -> DecKey<P> {
self.dec.clone()
}

/// Get decryption key reference
pub(crate) fn dec_key_ref(&self) -> &DecKey<P> {
&self.dec
Expand Down
2 changes: 1 addition & 1 deletion relation/src/gadgets/ecc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ where

#[derive(Debug, Copy, Clone, Eq, PartialEq)]
/// Represent variable of an EC point.
pub struct PointVariable(Variable, Variable);
pub struct PointVariable(pub Variable, pub Variable);

impl PointVariable {
/// Get the variable representing the x coordinate of the point.
Expand Down

0 comments on commit 38d13e5

Please sign in to comment.