Struct chain_vote::cryptography::elgamal::PublicKey
source · pub struct PublicKey {
pub pk: GroupElement,
}
Expand description
ElGamal public key. pk = sk * G, where sk is the SecretKey
and G is the group
generator.
Fields§
§pk: GroupElement
Implementations§
source§impl PublicKey
impl PublicKey
pub const BYTES_LEN: usize = 32usize
pub fn to_bytes(&self) -> Vec<u8>
pub fn from_bytes(buf: &[u8]) -> Option<Self>
sourcepub(crate) fn encrypt_point<R>(
&self,
message: &GroupElement,
rng: &mut R
) -> Ciphertextwhere
R: RngCore + CryptoRng,
pub(crate) fn encrypt_point<R>( &self, message: &GroupElement, rng: &mut R ) -> Ciphertextwhere R: RngCore + CryptoRng,
Given a message
represented as a group element, return a ciphertext.
fn encrypt_point_return_r<R>( &self, message: &GroupElement, rng: &mut R ) -> (Ciphertext, Scalar)where R: RngCore + CryptoRng,
fn encrypt_point_with_r( &self, message: &GroupElement, randomness: &Scalar ) -> Ciphertext
sourcepub(crate) fn encrypt<R>(&self, message: &Scalar, rng: &mut R) -> Ciphertextwhere
R: RngCore + CryptoRng,
pub(crate) fn encrypt<R>(&self, message: &Scalar, rng: &mut R) -> Ciphertextwhere R: RngCore + CryptoRng,
Given a message
represented as a Scalar
, return a ciphertext using the
“lifted ElGamal” mechanism. Mainly, return (r * G; message
* G + r * self
)
sourcepub(crate) fn encrypt_return_r<R>(
&self,
message: &Scalar,
rng: &mut R
) -> (Ciphertext, Scalar)where
R: RngCore + CryptoRng,
pub(crate) fn encrypt_return_r<R>( &self, message: &Scalar, rng: &mut R ) -> (Ciphertext, Scalar)where R: RngCore + CryptoRng,
Given a message
represented as a Scalar
, return a ciphertext and return
the randomness used.
sourcepub(crate) fn encrypt_with_r(
&self,
message: &Scalar,
randomness: &Scalar
) -> Ciphertext
pub(crate) fn encrypt_with_r( &self, message: &Scalar, randomness: &Scalar ) -> Ciphertext
Given a message
represented as a Scalar
, and some value used as randomness
,
return the corresponding ciphertext. This function should only be called when the
randomness value is not random (e.g. verification procedure of the unit vector ZKP).
Otherwise, encrypt_point
should be used.
sourcepub(crate) fn hybrid_encrypt<R>(
&self,
message: &[u8],
rng: &mut R
) -> HybridCiphertextwhere
R: RngCore + CryptoRng,
pub(crate) fn hybrid_encrypt<R>( &self, message: &[u8], rng: &mut R ) -> HybridCiphertextwhere R: RngCore + CryptoRng,
Given a message
passed as bytes, encrypt it using hybrid encryption.
Trait Implementations§
source§impl From<PublicKey> for MemberCommunicationPublicKey
impl From<PublicKey> for MemberCommunicationPublicKey
source§fn from(pk: PublicKey) -> MemberCommunicationPublicKey
fn from(pk: PublicKey) -> MemberCommunicationPublicKey
Converts to this type from the input type.
source§impl From<PublicKey> for MemberPublicKey
impl From<PublicKey> for MemberPublicKey
source§fn from(pk: PublicKey) -> MemberPublicKey
fn from(pk: PublicKey) -> MemberPublicKey
Converts to this type from the input type.
source§impl PartialEq<PublicKey> for PublicKey
impl PartialEq<PublicKey> for PublicKey
impl Eq for PublicKey
impl StructuralEq for PublicKey
impl StructuralPartialEq for PublicKey
Auto Trait Implementations§
impl RefUnwindSafe for PublicKey
impl Send for PublicKey
impl Sync for PublicKey
impl Unpin for PublicKey
impl UnwindSafe for PublicKey
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more