Skip to main content

Manager

Struct Manager 

Source
pub struct Manager {
    pub ks: Keeper,
    pub encrypter: Option<Encrypter>,
    pub decrypter: Option<Decrypter>,
    pub inited: bool,
    /* private fields */
}
Expand description

Manager struct for key pair creation, storage, retrieval, and message signing

§Attributes

  • ks - Keeper instance for storing public and private keys
  • encrypter - Instance for encrypting secrets, derived from aeid
  • decrypter - Instance for decrypting secrets, derived from seed
  • inited - Flag indicating if manager is fully initialized
  • _seed - Private signing key for the aeid (memory only, never persisted)
  • _inits - Initialization parameters for later setup

Fields§

§ks: Keeper

Key store LMDB database instance for storing public and private keys

§encrypter: Option<Encrypter>

Instance for encrypting secrets. Public encryption key derived from aeid

§decrypter: Option<Decrypter>

Instance for decrypting secrets. Private decryption key derived from seed

§inited: bool

True means fully initialized wrt database. False means not yet fully initialized

Implementations§

Source§

impl Manager

Source

pub fn new( ks: Keeper, seed: Option<Vec<u8>>, aeid: Option<Vec<u8>>, pidx: Option<usize>, algo: Option<Algos>, salt: Option<Vec<u8>>, tier: Option<Tiers>, ) -> Result<Self, KERIError>

Create new Manager instance

§Parameters
  • ks - Optional Keeper instance
  • seed - Optional qb64 private signing key for the aeid
  • kwa - Additional parameters to pass to setup method
§Returns
  • Result<Self, DBError> - Result containing new Manager or error
Source

pub fn setup( &mut self, aeid: Option<Vec<u8>>, pidx: Option<usize>, algo: Option<Algos>, salt: Option<Vec<u8>>, tier: Option<Tiers>, ) -> Result<(), KERIError>

Set up manager root or global attributes and properties

§Parameters
  • aeid - qb64b non-transferable identifier prefix for authentication and encryption
  • pidx - Index of next new created key pair sequence
  • algo - Root algorithm for creating key pairs
  • salt - qb64 of root salt
  • tier - Default security tier for root salt
§Returns
  • Result<(), DBError> - Success or error
Source

pub fn ingest( &mut self, secrecies: Vec<Vec<String>>, iridx: Option<usize>, ncount: Option<usize>, ncode: Option<&str>, dcode: Option<&str>, algo: Option<Algos>, salt: Option<Vec<u8>>, stem: Option<String>, tier: Option<Tiers>, rooted: Option<bool>, transferable: Option<bool>, temp: Option<bool>, ) -> Result<(String, Vec<Vec<Verfer>>), KERIError>

Ingest secrecies as a list of lists of secrets organized in event order to register the sets of secrets of associated externally generated keypair lists into the database.

Returns: (ipre, verferies) where: ipre is prefix index of ingested key pairs needed to fetch later for replay verferies is list of lists of all the verfers for the public keys from the private keys in secrecies in order of appearance.

§Parameters
  • secrecies - List of lists of fully qualified secrets (private keys)
  • iridx - Initial ridx at which to set PubSit after ingestion
  • ncount - Count of next public keys for next after end of secrecies
  • ncode - Derivation code qb64 of all ncount next public keys after end of secrecies
  • dcode - Derivation code qb64 of next digers after end of secrecies
  • algo - Key creation algorithm code for next after end of secrecies
  • salt - qb64 salt for randomization when salty algorithm used
  • stem - Path modifier used with salt to derive private keys when using salty algorithms
  • tier - Security criticality tier code when using salty algorithm
  • rooted - True means derive incept salt from root salt when incept salt not provided
  • transferable - True means each public key uses transferable derivation code
  • temp - True is temporary for testing
Source

pub fn replay( &mut self, pre: &[u8], dcode: Option<&str>, advance: Option<bool>, erase: Option<bool>, ) -> Result<(Vec<Verfer>, Vec<Diger>), KERIError>

Source

pub fn update_aeid( &mut self, aeid: Vec<u8>, seed: Vec<u8>, ) -> Result<(), KERIError>

Update the aeid (authentication and encryption identifier) and re-encrypt all secrets

§Parameters
  • aeid - qb64b of new auth encrypt id (public signing key) aeid may match current aeid (no change) aeid may be empty (unencrypts and removes aeid) aeid may be different and not empty (reencrypts)
  • seed - qb64b of new seed from which new aeid is derived (private signing key seed)
§Returns
  • Result<(), KERIError> - Success or error
Source

pub fn aeid(&self) -> Vec<u8> ⓘ

Get the aeid (authentication and encryption identifier)

§Returns
  • String - The aeid value
Source

pub fn pidx(&self) -> Option<usize>

Get the pidx (prefix index)

§Returns
  • Option - The pidx value if it exists
Source

pub fn set_pidx(&self, value: usize) -> Result<(), KERIError>

Set the pidx (prefix index)

§Parameters
  • value - New pidx value
§Returns
  • Result<(), DBError> - Success or error
Source

pub fn algo(&self) -> Option<String>

Get the algo (algorithm)

§Returns
  • Option - The algo value if it exists
Source

pub fn set_algo(&self, value: Algos) -> Result<(), KERIError>

Set the algo (algorithm)

§Parameters
  • value - New algo value
§Returns
  • Result<(), DBError> - Success or error
Source

pub fn salt(&self) -> Option<Vec<u8>>

Get the salt

§Returns
  • Option - The salt value if it exists
Source

pub fn set_salt(&self, value: Vec<u8>) -> Result<(), KERIError>

Set the salt

§Parameters
  • value - New salt value
§Returns
  • Result<(), KERIError> - Success or error
Source

pub fn tier(&self) -> Option<Tiers>

Get the tier

§Returns
  • Option - The tier value if it exists
Source

pub fn set_tier(&self, value: Tiers) -> Result<(), KERIError>

Set the tier

§Parameters
  • value - New tier value
§Returns
  • Result<(), DBError> - Success or error
Source

pub fn seed(&self) -> &Vec<u8> ⓘ

Get the seed

§Returns
  • String - The seed value
Source

pub fn incept( &mut self, icodes: Option<Vec<&str>>, icount: Option<usize>, icode: Option<&str>, ncodes: Option<Vec<&str>>, ncount: Option<usize>, ncode: Option<&str>, dcode: Option<String>, algo: Option<Algos>, salt: Option<Vec<u8>>, stem: Option<&str>, tier: Option<Tiers>, rooted: Option<bool>, transferable: Option<bool>, temp: Option<bool>, ) -> Result<(Vec<Verfer>, Vec<Diger>), KERIError>

Incept a prefix with key parameters

§Parameters
  • icodes - Optional list of private key derivation codes qb64 str, one per incepting key pair
  • icount - Count of incepting public keys when icodes not provided
  • icode - Derivation code of all icount incepting private keys when icodes list not provided
  • ncodes - Optional list of private key derivation codes qb64 str, one per next key pair
  • ncount - Count of next public keys when ncodes not provided
  • ncode - Derivation code of all ncount next private keys when ncodes list not provided
  • dcode - Derivation code of next digesters. Default is Blake3_256
  • algo - Optional key creation algorithm code
  • salt - Optional qb64 salt for randomization when salty algorithm used
  • stem - Optional path modifier used with salt to derive private keys when using salty algorithm
  • tier - Optional security criticality tier code when using salty algorithm
  • rooted - Whether to derive incept salt from root salt when incept salt not provided
  • transferable - Whether each public key uses transferable derivation code
  • temp - Whether the inception is temporary for testing, modifies tier of salty algorithm
§Returns
  • Result<(Vec<Verfer>, Vec<Diger>), KERIError> - Tuple containing:
    • Vector of current public key verfers
    • Vector of next public key digesters
Source

pub fn move_prefix(&self, old: &[u8], new: &[u8]) -> Result<(), KERIError>

Source

pub fn rotate( &self, pre: &[u8], ncodes: Option<Vec<&str>>, ncount: Option<usize>, ncode: Option<&str>, dcode: Option<&str>, transferable: Option<bool>, temp: Option<bool>, erase: Option<bool>, ) -> Result<(Vec<Verfer>, Vec<Diger>), KERIError>

Rotates keys for a prefix and returns tuple of verfers and digers

Returns tuple (verfers, digers) for rotation event of keys for pre where verfers is list of current public key verfers public key is verfer.qb64 digers is list of next public key digers digest to xor is diger.raw

Rotates a prefix. Store the updated dictified PreSit in the keeper under pre

§Parameters
  • pre - qb64b of prefix to rotate
  • ncodes - Optional list of private key derivation codes (qb64 string refs) one per next key pair
  • ncount - Count of next public keys when ncodes not provided
  • ncode - Derivation code qb64 of all ncount next private keys when ncodes not provided
  • dcode - Derivation code qb64 of next key digest of digers Default is mtr_dex::BLAKE3_256
  • transferable - True means each public key uses transferable derivation code Default is transferable. Special case is non-transferable. Normally no use case for rotation to use transferable = False. When the derivation process of the identifier prefix is transferable then one should not use transferable = False for the associated public key(s).
  • temp - True is temporary for testing. It modifies tier of salty algorithm
  • erase - True means erase old private keys made stale by rotation

When both ncodes is empty and ncount is 0 then the nxt is null and will not be rotatable. This makes the identifier non-transferable in effect even when the identifier prefix is transferable.

§Returns
  • Result<(Vec<Verfer>, Vec<Diger>), KERIError> - Tuple containing:
    • Vector of current public key verfers
    • Vector of next public key digers
Source

pub fn sign( &self, ser: &[u8], pubs: Option<Vec<String>>, verfers: Option<Vec<Verfer>>, indexed: Option<bool>, indices: Option<Vec<u32>>, ondices: Option<Vec<Option<u32>>>, pre: Option<&[u8]>, _path: Option<(usize, usize)>, ) -> Result<Vec<Sigmat>, KERIError>

Signs serialized data using private keys looked up from public keys

§Parameters
  • ser - Serialized data to sign
  • pubs - Optional list of qb64 public keys to lookup private keys one of pubs or verfers is required. If both then verfers is ignored.
  • verfers - Optional list of Verfer instances of public keys one of pubs or verfers is required. If both then verfers is ignored. If not pubs then gets public key from verfer.qb64
  • indexed - True means use indexed signatures and return list of Siger instances. False means do not use indexed signatures and return list of Cigar instances
  • indices - Optional list of indices (offsets) when indexed == true, to use for indexed signatures whose offset into the current keys or prior next list may differ from the order of appearance in the provided coherent pubs, verfers, signers lists.
  • ondices - Optional list of other indices (offsets) when indexed is true for indexed signatures whose offset into the prior next list may differ from the order of appearance in the provided coherent lists.
  • pre - Optional identity prefix (aid) of signer. Used for HDK salty algo key lookup or re-creation.
  • path - Optional HDX randy algo signing key path tuple part
§Returns
  • Result<Vec<Siger>, KERIError> - List of Siger instances if indexed is true
  • Result<Vec<Cigar>, KERIError> - List of Cigar instances if indexed is false
§Notes

When indexed, each index is an offset that maps the offset in the coherent lists onto the appropriate offset into the signing keys or prior next keys lists of a key event.

Source

pub fn decrypt( &self, qb64: &[u8], pubs: Option<Vec<&str>>, verfers: Option<Vec<Verfer>>, ) -> Result<Vec<u8>, KERIError>

Returns decrypted plaintext of encrypted qb64 ciphertext serialization.

§Parameters
  • qb64 - Fully qualified base64 ciphertext serialization to decrypt
  • pubs - Optional list of qb64 public keys to lookup private keys one of pubs or verfers is required. If both then verfers is ignored.
  • verfers - Optional list of Verfer instances of public keys one of pubs or verfers is required. If both then verfers is ignored. If not pubs then gets public key from verfer.qb64 used to lookup private keys
§Returns
  • Result<Vec<u8>, KERIError> - Decrypted plaintext or error

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more