Keycard

Struct Keycard 

Source
pub struct Keycard {
    pub entries: Vec<Entry>,
    /* private fields */
}
Expand description

A Keycard object is a collection of entries tied together in an authenticated blockchain. It consists of the root entry for the entity all the way through the current entry.

Fields§

§entries: Vec<Entry>

Implementations§

Source§

impl Keycard

Source

pub fn new(t: EntryType) -> Keycard

Creates a new Keycard of the specified type

Source

pub fn from(data: &str) -> Result<Keycard, LKCError>

Creates a new keycard entry chain from text.

Source

pub fn find(&self, hash: &CryptoString) -> Result<&Entry, LKCError>

Finds the entry in a keycard which has the requested hash

Source

pub fn get_current(&self) -> Option<&Entry>

Returns the last entry of the keycard

Source

pub fn get_current_mut(&mut self) -> Option<&mut Entry>

Returns a mutable reference to the last entry of the keycard

Source

pub fn get_type(&self) -> EntryType

Returns the type of entries stored in the keycard

Source

pub fn get_owner(&self) -> Result<String, LKCError>

Returns a string containing the owner of the keycard, which will be a domain for an organization and a workspace address for a user. This call will fail if the card has no entries or if the current entry does not have the required fields, i.e. Domain or Domain + Workspace-ID.

Source

pub fn get_text(&self) -> Result<String, LKCError>

Returns the entire keycard chain as text

Source

pub fn chain( &mut self, spair: &SigningPair, expires: u16, ) -> Result<HashMap<&'static str, CryptoString>, LKCError>

Creates a new Entry object in the keycard. Organization keycards are complete and compliant when chain() returns. User keycards will require cross_sign() and user_sign() to be called before it is complete.

This method returns a HashMap which contains the newly-generated keys associated with the new keycard entry. The fields returned will depend on the keycard type.

Organization keycards will return the fields primary.public, primary.private, encryption.public, and encryption.private. The secondary signing keypair is not returned because the signing pair passed to the method becomes the secondary signing keypair after this call completes.

User keycards will return the fields crsigning.public, crsigning.private, crencryption.public, crencryption.private, signing.public, signing.private, encryption.public, and encryption.private.

Source

pub fn cross_sign(&mut self, signing_pair: &SigningPair) -> Result<(), LKCError>

This convenience method applies only to user keycards and is used to set the organization’s signature for the current entry.

Source

pub fn user_sign( &mut self, hash_algorithm: &str, signing_pair: &SigningPair, ) -> Result<(), LKCError>

This convenience method applies only to user keycards and is used to add the final user signature and generate the hash for the entry. Once this has been applied, the current entry for the card should be compliant and should pass verification.

Source

pub fn verify(&self) -> Result<(), LKCError>

Verifies the keycard’s complete chain of entries

Trait Implementations§

Source§

impl Debug for Keycard

Source§

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

Formats the value using the given formatter. Read more

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 = 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.
Source§

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

Source§

fn vzip(self) -> V