pub struct EncryptedTally {
    r: Vec<Ciphertext>,
    fingerprint: ElectionFingerprint,
    max_stake: u64,
}
Expand description

EncryptedTally is formed by one ciphertext per existing option and a fingerprint that identifies the election parameters used (crs and election public key)

Fields§

§r: Vec<Ciphertext>§fingerprint: ElectionFingerprint§max_stake: u64

Implementations§

source§

impl EncryptedTally

source

const MAX_STAKE_BYTES_LEN: usize = 8usize

source

pub fn new(options: usize, election_pk: ElectionPublicKey, crs: Crs) -> Self

Initialise a new tally with N different options. The EncryptedTally is computed using the additive homomorphic property of the elgamal Ciphertexts, and is therefore initialised with zero ciphertexts.

source

pub fn to_base64(&self) -> String

Returns base64 representation of EncryptedTally

source

pub fn from_base_64(encrypted_tally_b64: String) -> Result<Self, Box<dyn Error>>

Generate EncryptedTally type from base64 representation

Errors
  • Base64DecodeError
source

pub fn add(&mut self, ballot: &Ballot, weight: u64)

Add a submitted ballot, with a specific weight to the tally. Remember that a vote is only valid for a specific election (i.e. pair of election public key and crs), and trying to add a ballot validated for a different one will result in a panic.

Note that the encrypted vote needs to have the exact same number of options as the initialised tally, otherwise an assert will trigger.

source

pub fn partial_decrypt<R: RngCore + CryptoRng>( &self, rng: &mut R, secret_key: &OpeningVoteKey ) -> TallyDecryptShare

Given a single committee member’s secret_key, returns a partial decryption of the EncryptedTally

source

pub fn validate_partial_decryptions( &self, pks: &[MemberPublicKey], decrypt_shares: &[TallyDecryptShare] ) -> Result<ValidatedTally, DecryptionError>

Given the members pks, and their corresponding decrypte_shares, this function validates the different shares, and returns a ValidatedTally, or a DecryptionError.

source

pub fn to_bytes(&self) -> Vec<u8>

Returns a byte array with every ciphertext in the EncryptedTally

source

pub fn from_bytes(bytes: &[u8]) -> Option<Self>

Tries to generate an EncryptedTally out of an array of bytes. Returns None if the size of the byte array is not a multiply of Ciphertext::BYTES_LEN.

Trait Implementations§

source§

impl Add<EncryptedTally> for EncryptedTally

§

type Output = EncryptedTally

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for EncryptedTally

source§

fn clone(&self) -> EncryptedTally

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EncryptedTally

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq<EncryptedTally> for EncryptedTally

source§

fn eq(&self, other: &EncryptedTally) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for EncryptedTally

source§

impl StructuralEq for EncryptedTally

source§

impl StructuralPartialEq for EncryptedTally

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V