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 keysencrypter- Instance for encrypting secrets, derived from aeiddecrypter- Instance for decrypting secrets, derived from seedinited- 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: KeeperKey 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: boolTrue means fully initialized wrt database. False means not yet fully initialized
Implementations§
Source§impl Manager
impl Manager
Sourcepub 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>
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>
Sourcepub fn setup(
&mut self,
aeid: Option<Vec<u8>>,
pidx: Option<usize>,
algo: Option<Algos>,
salt: Option<Vec<u8>>,
tier: Option<Tiers>,
) -> Result<(), KERIError>
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 encryptionpidx- Index of next new created key pair sequencealgo- Root algorithm for creating key pairssalt- qb64 of root salttier- Default security tier for root salt
§Returns
Result<(), DBError>- Success or error
Sourcepub 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>
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 ingestionncount- Count of next public keys for next after end of secreciesncode- Derivation code qb64 of all ncount next public keys after end of secreciesdcode- Derivation code qb64 of next digers after end of secreciesalgo- Key creation algorithm code for next after end of secreciessalt- qb64 salt for randomization when salty algorithm usedstem- Path modifier used with salt to derive private keys when using salty algorithmstier- Security criticality tier code when using salty algorithmrooted- True means derive incept salt from root salt when incept salt not providedtransferable- True means each public key uses transferable derivation codetemp- True is temporary for testing
pub fn replay( &mut self, pre: &[u8], dcode: Option<&str>, advance: Option<bool>, erase: Option<bool>, ) -> Result<(Vec<Verfer>, Vec<Diger>), KERIError>
Sourcepub fn update_aeid(
&mut self,
aeid: Vec<u8>,
seed: Vec<u8>,
) -> Result<(), KERIError>
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
Sourcepub 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>
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 pairicount- Count of incepting public keys when icodes not providedicode- Derivation code of all icount incepting private keys when icodes list not providedncodes- Optional list of private key derivation codes qb64 str, one per next key pairncount- Count of next public keys when ncodes not providedncode- Derivation code of all ncount next private keys when ncodes list not provideddcode- Derivation code of next digesters. Default is Blake3_256algo- Optional key creation algorithm codesalt- Optional qb64 salt for randomization when salty algorithm usedstem- Optional path modifier used with salt to derive private keys when using salty algorithmtier- Optional security criticality tier code when using salty algorithmrooted- Whether to derive incept salt from root salt when incept salt not providedtransferable- Whether each public key uses transferable derivation codetemp- 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
pub fn move_prefix(&self, old: &[u8], new: &[u8]) -> Result<(), KERIError>
Sourcepub 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>
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 rotatencodes- Optional list of private key derivation codes (qb64 string refs) one per next key pairncount- Count of next public keys when ncodes not providedncode- Derivation code qb64 of all ncount next private keys when ncodes not provideddcode- Derivation code qb64 of next key digest of digers Default is mtr_dex::BLAKE3_256transferable- 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 algorithmerase- 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
Sourcepub 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>
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 signpubs- 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.qb64indexed- True means use indexed signatures and return list of Siger instances. False means do not use indexed signatures and return list of Cigar instancesindices- 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 trueResult<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.
Sourcepub fn decrypt(
&self,
qb64: &[u8],
pubs: Option<Vec<&str>>,
verfers: Option<Vec<Verfer>>,
) -> Result<Vec<u8>, KERIError>
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 decryptpubs- 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