RandomState

Struct RandomState 

Source
pub struct RandomState {
    pub id: RandomId,
    pub size: usize,
    pub owners: Vec<String>,
    pub options: Vec<String>,
    pub status: RandomStatus,
    pub masks: Vec<Mask>,
    pub ciphertexts: Vec<LockedCiphertext>,
    pub secret_shares: Vec<Share>,
    pub revealed: HashMap<usize, String>,
}
Expand description

RandomState represents the public information for a single randomness.

Fields§

§id: RandomId§size: usize§owners: Vec<String>§options: Vec<String>§status: RandomStatus§masks: Vec<Mask>§ciphertexts: Vec<LockedCiphertext>§secret_shares: Vec<Share>§revealed: HashMap<usize, String>

Implementations§

Source§

impl RandomState

Source

pub fn is_fully_masked(&self) -> bool

Source

pub fn is_fully_locked(&self) -> bool

Source

pub fn is_shared(&self) -> bool

Source

pub fn is_ready(&self) -> bool

Source

pub fn get_ciphertext(&self, index: usize) -> Option<&LockedCiphertext>

Source

pub fn get_ciphertext_unchecked(&self, index: usize) -> &LockedCiphertext

Source

pub fn try_new( id: RandomId, spec: RandomSpec, owners: &[String], ) -> Result<Self>

Source

pub fn mask<S: AsRef<str>>( &mut self, addr: S, ciphertexts: Vec<Ciphertext>, ) -> Result<()>

Source

pub fn lock<S>( &mut self, addr: S, ciphertexts_and_digests: Vec<(Ciphertext, SecretDigest)>, ) -> Result<()>
where S: Into<String> + AsRef<str> + Clone,

Source

pub fn assign<S>(&mut self, addr: S, indexes: Vec<usize>) -> Result<()>
where S: ToOwned<Owned = String>,

Source

pub fn reveal(&mut self, indexes: Vec<usize>) -> Result<()>

Source

pub fn list_required_secrets_by_from_addr( &self, from_addr: &str, ) -> Vec<SecretIdent>

Source

pub fn list_revealed_secrets(&self) -> Result<HashMap<usize, Vec<Ciphertext>>>

Source

pub fn list_assigned_ciphertexts( &self, addr: &str, ) -> HashMap<usize, Ciphertext>

List all ciphertexts assigned to a specific address. Return a mapping from item index to ciphertext.

Source

pub fn list_revealed_ciphertexts(&self) -> HashMap<usize, Ciphertext>

Source

pub fn list_shared_secrets( &self, to_addr: &str, ) -> Result<HashMap<usize, Vec<SecretKey>>>

List shared secrets by receiver address. Return a mapping from item index to list of secrets(each is in HEX format). Return [Error::SecretsNotReady] in case of any missing secret.

Source

pub fn add_revealed(&mut self, revealed: HashMap<usize, String>) -> Result<()>

Source

pub fn get_revealed(&self) -> &HashMap<usize, String>

Source

pub fn add_secret( &mut self, from_addr: String, to_addr: Option<String>, index: usize, secret: SecretKey, ) -> Result<()>

Source

pub fn list_operating_addrs(&self) -> Vec<String>

Return addresses those haven’t submitted operation

Source

pub fn update_status(&mut self)

Update randomness status

Trait Implementations§

Source§

impl BorshDeserialize for RandomState

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

impl BorshSerialize for RandomState

Source§

fn serialize<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn try_to_vec(&self) -> Result<Vec<u8>, Error>

Serialize this instance into a vector of bytes.
Source§

impl Clone for RandomState

Source§

fn clone(&self) -> RandomState

Returns a duplicate 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 RandomState

Source§

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

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

impl Default for RandomState

Source§

fn default() -> RandomState

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RandomState

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for RandomState

Source§

impl StructuralPartialEq for RandomState

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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 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.