Key Provider¶
Class Name | KeyProvider |
---|---|
Implements | KeyProviderInterface |
Extends | Logger |
Extends | key-provider.ts |
Source | key-provider.ts |
This DApp browser KeyProvider is a adaption of the original DBCP 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(keys, accountId)
Creates a new KeyProvider instance.
Parameters¶
keys
-any
: object with key mappings of accounts (can be empty, will be filled dynamically).accountId
-string
: create KeyProvider for specific accountId, default the current logged in accountId will be used.
Returns¶
KeyProvider
instance
setKeys¶
keyProvider.setKeys();
set the keys for the within the constructor provided or global accountId
setKeys¶
keyProvider.setKeys();
Uses an account id and an encryptionKey to set account specific encryption keys.
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);