Skip to main content

AgreementKey

Struct AgreementKey 

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

A device’s long-term key-agreement secret.

This is the private half a device uses to agree a session key with a peer. It is built from a 32-byte seed the device is provisioned with and keeps in secure storage, so the same agreement key is recreated deterministically across reboots.

It is separate from the device’s ed25519 signing identity in pamoja-security. Key agreement gives confidentiality; it does not by itself prove who the peer is. A deployment authenticates the peer by pinning its public value, or by signing that value with the peer’s pamoja-security identity, the same way it already pins a signing identity. Without that pinning the channel is private but unauthenticated and a man in the middle is possible.

§Examples

use pamoja_session::AgreementKey;

let device = AgreementKey::from_seed(&[7u8; 32]);
let public = device.public();
// `public.to_bytes()` is what a peer pins or has signed to trust this device.
assert_eq!(public.to_bytes().len(), 32);

Implementations§

Source§

impl AgreementKey

Source

pub fn from_seed(seed: &[u8; 32]) -> Self

Builds a key-agreement secret from a 32-byte seed.

§Arguments
  • seed - the 32 secret bytes the key is derived from.
§Returns

The agreement key.

Source

pub fn public(&self) -> AgreementPublicKey

Returns the public key a peer needs to agree a session with this device.

§Returns

The matching AgreementPublicKey, safe to share once it is authenticated.

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.