Key Provider¶
Class Name | KeyProvider |
---|---|
Implements | KeyProviderInterface |
Extends | Logger |
Source | key-provider.ts |
The KeyProvider returns given decryption/encryption keys for a given CryptoInfo. They use a given evan.network profile to retrieve the needed keys to encrypt/decrypt the envelope
constructor¶
new KeyProvider(options);
Creates a new KeyProvider instance.
Parameters¶
options
-KeyProviderOptions
: options for KeyProvider constructor.keys
-any
(optional): object with key mappings of accountslog
-Function
(optional): function to use for logging:(message, level) => {...}
logLevel
-LogLevel
(optional): messages with this level will be logged withlog
logLog
-LogLogInterface
(optional): container for collecting log messageslogLogLevel
-LogLevel
(optional): messages with this level will be pushed tologLog
Returns¶
KeyProvider
instance
init¶
keyProvider.init(_profile);
initialize a new KeyProvider with a given evan.network Profile
Parameters¶
_profile
-Profile
: initialized evan.network profile
getKey¶
keyProvider.getKey(info);
get a encryption/decryption key for a specific CryptoInfo from the associated AccountStore or the loaded evan.network profile
Parameters¶
cryptoAlgo
-string
: crypto algorithm
Returns¶
Promise resolves to string
: the found key for the cryptoinfo.
Example¶
const cryptoInfo = {
"public": {
"name": "envelope example"
},
"private": "...",
"cryptoInfo": {
"algorithm": "unencrypted",
"keyLength": 256,
"originator": "0x0000000000000000000000000000000000000001,0x0000000000000000000000000000000000000002",
"block": 123
}
};
const key = runtime.keyProvider.getKey(info);