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
impl Keycard
Sourcepub fn from(data: &str) -> Result<Keycard, LKCError>
pub fn from(data: &str) -> Result<Keycard, LKCError>
Creates a new keycard entry chain from text.
Sourcepub fn find(&self, hash: &CryptoString) -> Result<&Entry, LKCError>
pub fn find(&self, hash: &CryptoString) -> Result<&Entry, LKCError>
Finds the entry in a keycard which has the requested hash
Sourcepub fn get_current(&self) -> Option<&Entry>
pub fn get_current(&self) -> Option<&Entry>
Returns the last entry of the keycard
Sourcepub fn get_current_mut(&mut self) -> Option<&mut Entry>
pub fn get_current_mut(&mut self) -> Option<&mut Entry>
Returns a mutable reference to the last entry of the keycard
Sourcepub fn get_owner(&self) -> Result<String, LKCError>
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.
Sourcepub fn chain(
&mut self,
spair: &SigningPair,
expires: u16,
) -> Result<HashMap<&'static str, CryptoString>, LKCError>
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.
Sourcepub fn cross_sign(&mut self, signing_pair: &SigningPair) -> Result<(), LKCError>
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.
Sourcepub fn user_sign(
&mut self,
hash_algorithm: &str,
signing_pair: &SigningPair,
) -> Result<(), LKCError>
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.