Struct smol_mpc::vm::VirtualMachine

source ·
pub struct VirtualMachine<'a, T: MersenneField> {
    pub id: &'a str,
    pub private_values: HashMap<&'a str, T>,
    pub shares: HashMap<&'a str, Share<'a, T>>,
}
Expand description

Defines a virtual machine.

The virtual machine is represented as a node that has an ID based memory in which it saves the information. All the machines have an ID used to identify them during a protocol execution. The inspiration of this design comes from the way in wich an ideal functionality is specified in a Universal Composability proof, that is, as a entity that has a ID based memory to store elements and that also sends, process and receives information. However, we stress that this implementation is not the implementation of an ideal functionality, we just take the some elements.

The memory is divided into two types. The private memory will hold values that a certain node knows but are not secret-shared among the parties. The shares memory stores the shares of a certain value. To make things simple, when a value is public, it is stored in the private memory because, at the end, it is a value that is known all the machines. Each variable stored in the memory has also an ID to refer to it during the protocol execution. In particular, if a value is secret-shared among a certain set of parties, it will have the same ID in memory for all the virtual machines involved in the protocol.

Fields§

§id: &'a str

ID of the virtual machine.

§private_values: HashMap<&'a str, T>

Memory for private values.

§shares: HashMap<&'a str, Share<'a, T>>

Memory for shared values.

Implementations§

source§

impl<'a, 'b, T: MersenneField> VirtualMachine<'a, T>where 'a: 'b,

source

pub fn new(id_machine: &'a str) -> Self

Creates a new virtual machine using a provided ID.

source

pub fn insert_priv_value(&mut self, id: &'a str, value: T)

Inserts a value in the private memory using a provided ID.

source

pub fn insert_share(&mut self, id: &'a str, share: Share<'a, T>)

Insert a share in the share memory using a provided ID.

source

pub fn get_priv_value(&'a self, id: &'a str) -> &'b T

Returns a private value with the provided id stored in the private memory.

source

pub fn get_share(&'a self, id: &'a str) -> &'b Share<'a, T>

Returns the share with the provided ID previously stored in the share memory.

Auto Trait Implementations§

§

impl<'a, T> RefUnwindSafe for VirtualMachine<'a, T>where T: RefUnwindSafe,

§

impl<'a, T> Send for VirtualMachine<'a, T>where T: Send,

§

impl<'a, T> Sync for VirtualMachine<'a, T>where T: Sync,

§

impl<'a, T> Unpin for VirtualMachine<'a, T>where T: Unpin,

§

impl<'a, T> UnwindSafe for VirtualMachine<'a, T>where T: UnwindSafe,

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.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
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.