Skip to main content

AnnihlKey

Struct AnnihlKey 

Source
pub struct AnnihlKey {
    pub solution: Solution,
    /* private fields */
}
Expand description

An AnnihlKey represents the mined proof-of-work solution and elliptic curve point of an annihilative key.

Fields§

§solution: Solution

Serialised proof-of-work solution.

Implementations§

Source§

impl AnnihlKey

Source

pub fn new(solution: Solution, base_point: EdwardsPoint) -> Self

Construct a new AnnihlKey from a mined proof-of-work solution and shared base curve point.

Source

pub fn new_pair(ikm: &[u8], iam: &[u8], constraint: u8) -> (Self, Self)

Derive a new annihilative pair from keying material.

Returns a pair that satisfies the given proof-of-work constraint, where each AnnihlKey consists of the mined Solution, and an EdwardsPoint at an offset from the pair’s shared base curve point.

Source

pub fn verify(&self, other: &Self) -> Result<[u8; 32], AnnihlErr>

Verify that two annihilative keys form a valid pair.

First checks that both members share the same base curve point, then checks if the hash of their XOR satisfies the proof-of-work constraint.

Returns the XOR hash as an artifact on success, or an error when the members do not form a valid annihilative pair.

Source

pub fn authenticate(&self, keying_material: &[u8]) -> Result<(), AnnihlErr>

Authenticate than an AnnihlKey was derived from given keying material.

Returns an error if the annihilative key could not be authenticated by the keying material.

Source

pub fn to_annihilation(&self, other: &Self) -> Result<[u8; 32], AnnihlErr>

Compute an annihilation key from an annihilative pair.

Verifies the pair, then computes an Hmac of the verification artifact, keyed by the sum of both curve points. Requires both a key and antikey to compute. As long as one half of the annihilative pair remains secret, the secrecy of the derived annihilation key is preserved.

Returns the MAC as the annihilation key on success, or an error when the pair is invalid or the proof-of-work constraint is not satisfied.

Source

pub fn into_annihilation(self, other: Self) -> Result<[u8; 32], AnnihlErr>

Compute an annihilation key from an annihilative pair, consuming both keys.

Convenience method that consumes ownership of both keys while delegating to to_annihilation.

Returns the MAC as the annihilation key on success, or an error when the pair is invalid or the proof-of-work constraint is not satisfied.

Source

pub fn to_bytes(&self) -> [u8; 64]

Copy this AnnihlKey to a 64 byte array.

Source

pub fn to_edwards_point(&self) -> EdwardsPoint

Return this AnnihlKey’s curve point as an EdwardsPoint.

Trait Implementations§

Source§

impl Clone for AnnihlKey

Source§

fn clone(&self) -> AnnihlKey

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 ConstantTimeEq for AnnihlKey

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl Debug for AnnihlKey

Source§

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

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

impl Drop for AnnihlKey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl PartialEq for AnnihlKey

Source§

fn eq(&self, other: &Self) -> 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 TryFrom<&[u8; 64]> for AnnihlKey

Source§

fn try_from(value: &[u8; 64]) -> Result<Self, Self::Error>

Construct an AnnihlKey from a 64 byte array.

Source§

type Error = AnnihlErr

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

impl Zeroize for AnnihlKey

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.
Source§

impl Eq for AnnihlKey

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> Same for T

Source§

type Output = T

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