Skip to main content

ScalarProduct

Struct ScalarProduct 

Source
pub struct ScalarProduct;
Expand description

Приватное вычисление скалярного произведения (GNUnet SCALARPRODUCT). Каждое вычисление — отдельное соединение с сервисом; drop Future отменяет его.

Implementations§

Source§

impl ScalarProduct

Source

pub async fn compute( runtime: &GnunetRuntime, config: &Config, session: &HashCode, peer: PeerId, elements: &[ScalarProductElement], ) -> Result<i128, ScalarProductError>

Сторона, запрашивающая вычисление: возвращает скалярное произведение по ключам, общим с peer. Вторая сторона должна вызвать ScalarProduct::respond с тем же session.

Сервис находит результат перебором и поддерживает только небольшие по модулю произведения (до 2^20 в сборке 0.29.0); иначе вычисление завершается ошибкой Failed. Если у сторон нет ни одного общего ключа, сервис 0.29.0 не отвечает вовсе — ограничивайте ожидание своим тайм-аутом.

Source

pub async fn respond( runtime: &GnunetRuntime, config: &Config, session: &HashCode, elements: &[ScalarProductElement], ) -> Result<(), ScalarProductError>

Отвечающая сторона: передаёт сервису свой вектор для сессии session и ждёт завершения вычисления. Результат узнаёт только запрашивающая сторона.

К вектору добавляется один служебный элемент со случайным ключом: без него сервис 0.29.0 аварийно завершается, если у отвечающей стороны нет ни одного ключа, отсутствующего у запрашивающей.

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.