Skip to main content

SecretState

Struct SecretState 

Source
pub struct SecretState { /* private fields */ }
Expand description

Represent a private state contains generated secrets.

§Random Secrets

A group of secrets will be created when a new randomness is initialized. The group contains a mask secret and a list of lock secrets. Use mask, unmask and lock to encrypt the ciphertexts from a randomness.

The mask secret should never be shared with others. If all mask secrets are shared, then the whole randomness is possibly revealed. We only share lock secrets When reveal or assign a random item.

§Decision Secrets

A decision is an immutable hidden answer from a player. We generate the secret when encrypting the answer. By sharing the secret, the answer is revealed.

Implementations§

Source§

impl SecretState

Source

pub fn new(encryptor: Arc<dyn EncryptorT>) -> Self

Source

pub fn clear(&mut self)

Source

pub fn gen_random_secrets(&mut self, random_id: RandomId, size: usize)

Source

pub fn is_random_loaded(&self, random_id: RandomId) -> bool

Source

pub fn is_decision_loaded(&self, decision_id: DecisionId) -> bool

Source

pub fn get_random_lock( &self, random_id: RandomId, index: usize, ) -> Result<SecretKey>

Source

pub fn get_decision_secret(&self, decision_id: DecisionId) -> Option<SecretKey>

Source

pub fn mask( &mut self, random_id: RandomId, ciphertexts: Vec<Ciphertext>, ) -> Result<Vec<Ciphertext>>

Source

pub fn unmask( &mut self, random_id: RandomId, ciphertexts: Vec<Ciphertext>, ) -> Result<Vec<Ciphertext>>

Source

pub fn lock( &mut self, random_id: RandomId, ciphertexts: Vec<Ciphertext>, ) -> Result<Vec<(Ciphertext, SecretDigest)>>

Source

pub fn encrypt_answer( &mut self, decision_id: DecisionId, answer: String, ) -> Result<(Ciphertext, SecretDigest)>

Source

pub fn list_random_secrets(&self) -> Vec<&RandomSecretGroup>

Source

pub fn list_decision_secerts(&self) -> Vec<&SecretKey>

Trait Implementations§

Source§

impl Debug for SecretState

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.