Struct ockam::Contact[][src]

pub struct Contact { /* fields omitted */ }

Contact is an abstraction responsible for storing user’s public data (mainly - public keys). It is designed to share users’ public keys in cryptographically verifiable way. Public keys together with metadata are organised into verifiable events chain exactly like crate::Profile. There are two ways to get Contact:

  1. From another user (in this case Contact will be cryptographically verified)
  2. Generate one from user’s own crate::Profile

Public keys from Contact can be used for many purposes, e.g. running key exchange, or signing&encrypting data.

Examples

Creating Contact from crate::Profile

let vault = Arc::new(Mutex::new(SoftwareVault::default()));
let mut alice = Profile::create(None, vault)?;

let truck_key_attributes = KeyAttributes::new(
    "Truck management".to_string(),
);

alice.create_key(truck_key_attributes.clone(), None)?;

let alice_contact = alice.to_contact();

let public_key = alice.get_public_key(&truck_key_attributes)?;

Sending Contact over the network

// Send this over the network
let alice_contact_binary = alice.serialize_to_contact()?;

Implementations

impl Contact[src]

pub fn identifier(&self) -> &ProfileIdentifier[src]

Return unique identifier, which equals to crate::Profile’s identifier

pub fn change_events(&self) -> &[ProfileChangeEvent]

Notable traits for &'_ [u8]

impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
[src]

Return change history chain

impl Contact[src]

pub fn new(
    identifier: ProfileIdentifier,
    change_events: Vec<ProfileChangeEvent>
) -> Self
[src]

impl Contact[src]

pub fn verify(&self, vault: &mut dyn ProfileVault) -> Result<()>[src]

Verify cryptographically whole event chain. Also verify sequence correctness

pub fn verify_and_update(
    &mut self,
    change_events: Vec<ProfileChangeEvent>,
    vault: &mut dyn ProfileVault
) -> Result<()>
[src]

Update Contact by using new change events

impl Contact[src]

pub fn get_profile_update_public_key(&self) -> Result<PublicKey>[src]

pub fn get_public_key(
    &self,
    key_attributes: &KeyAttributes
) -> Result<PublicKey>
[src]

Get PublicKey. Key is uniquely identified by label in KeyAttributes

pub fn get_last_event_id(&self) -> Result<EventIdentifier>[src]

Get EventIdentifier of the last known event

Trait Implementations

impl Clone for Contact[src]

impl Debug for Contact[src]

impl<'de> Deserialize<'de> for Contact[src]

impl Serialize for Contact[src]

Auto Trait Implementations

impl RefUnwindSafe for Contact

impl Send for Contact

impl Sync for Contact

impl Unpin for Contact

impl UnwindSafe for Contact

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Message for T where
    T: Serialize + DeserializeOwned + Send + 'static, 
[src]

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,