@substrate-system/keys
    Preparing search index...

    Class AbstractKeysAbstract

    The parent key. Doesn't implement the encrypt/sign functions.

    Hierarchy (View Summary)

    Index
    _exchangeKey: CryptoKeyPair | null
    _writeKey: CryptoKeyPair | null
    destroyed: boolean

    Have these keys been deleted? A deleted keypair is terminal -- the key material is gone, and any use of it throws.

    DID: `did:key:z${string}`
    exchangeKeyName: string

    The indexedDB names this keypair was loaded from, and the names persist and delete will use.

    hasPersisted: boolean
    isSessionOnly: boolean
    writeKeyName: string
    _instance: any
    EXCHANGE_KEY_NAME: string
    WRITE_KEY_NAME: string
    • get deviceName(): Promise<string>

      The machine-readable name for this keypair.

      Returns Promise<string>

    • get exchangeKey(): CryptoKeyPair

      Returns CryptoKeyPair

    • get privateExchangeKey(): CryptoKey

      Returns CryptoKey

    • get publicExchangeKey(): CryptoKey & {
          asString: (format?: SupportedEncodings) => Promise<string>;
      }

      Returns CryptoKey & { asString: (format?: SupportedEncodings) => Promise<string> }

    • get publicWriteKey(): CryptoKey & {
          asString: (format?: SupportedEncodings) => Promise<string>;
      }

      Returns CryptoKey & { asString: (format?: SupportedEncodings) => Promise<string> }

    • get writeKey(): CryptoKeyPair

      Returns CryptoKeyPair

    • Drop the in-memory key material. Internal -- call delete instead.

      Returns void

    • Parameters

      • msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>
      • OptionalpublicKeyOrKeysize: string | CryptoKey | SymmKeyLength | null
      • OptionalaesAlgorithm: string | null

      Returns Promise<ArrayBuffer | Uint8Array<ArrayBufferLike>>

    • Parameters

      • msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>
      • OptionalpublicKeyOrKeysize: string | CryptoKey | SymmKeyLength | null
      • OptionalaesAlgorithm: string | null

      Returns Promise<string>

    • Delete this keypair. This deletes the keys from indexedDB, drops the in-memory key material, and clears the instance cache, so load will not hand out these keys again.

      After this, the instance is destroyed -- using it throws a KeysDeletedError.

      Returns Promise<void>

    • By default, encrypt the given data to yourself, as a "note to self".

      Parameters

      • content: string | Uint8Array<ArrayBufferLike>
      • Optionalrecipient: string | CryptoKey | null
      • OptionalaesKeyOrInfo: string | Uint8Array<ArrayBufferLike> | CryptoKey | null
      • OptionalkeysizeOrAesKey: string | Uint8Array<ArrayBufferLike> | CryptoKey | SymmKeyLength | null
      • Optionalkeysize: SymmKeyLength | null

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Parameters

      • content: string | Uint8Array<ArrayBufferLike>
      • Optionalrecipient: string | CryptoKey | null
      • OptionalaesKeyOrInfo: string | Uint8Array<ArrayBufferLike> | CryptoKey | null
      • OptionalkeysizeOrAesKey: string | Uint8Array<ArrayBufferLike> | CryptoKey | SymmKeyLength | null
      • Optionalkeysize: SymmKeyLength | null

      Returns Promise<string>

    • Get the relevant AES key.

      • if this is an ECC keypair, then use DHKE with the given public key
      • if this is RSA, use your private key to decrypt the given AES key

      Parameters

      • OptionalpublicKey: string | CryptoKey | null
      • Optionalinfo: string | null

      Returns Promise<CryptoKey>

    • Return a 32-character, DNS friendly hash of the public signing key.

      Returns Promise<string>

    • Save this keys instance to indexedDB.

      Returns Promise<void>

    • Parameters

      • Optionalformat: SupportedEncodings

      Returns Promise<string>

    • Parameters

      • Optionalformat: SupportedEncodings

      Returns Promise<string>

    • Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Parameters

      Returns Promise<string>

    • Parameters

      • Optionalformat: SupportedEncodings

      Returns Promise<{ DID: `did:key:z${string}`; publicExchangeKey: string }>

    • Parameters

      • Optional_extractable: boolean

      Returns Promise<CryptoKeyPair>

    • Parameters

      • Optional_extractable: boolean

      Returns Promise<CryptoKeyPair>

    • If the cached instance was loaded from the given names, then its keys are gone too. Destroy it, and clear the cache. Internal.

      Parameters

      • exchangeName: string
      • writeName: string

      Returns void

    • The indexedDB names for this class, optionally prefixed with dbKey. Pure -- never writes to the class statics.

      Parameters

      • OptionaldbKey: string

      Returns { exchangeKeyName: string; writeKeyName: string }

    • Type Parameters

      Parameters

      • this: ChildKeys<AbstractKeys> & typeof AbstractKeys
      • Optionalsession: boolean
      • Optionalextractable: boolean
      • Optionalkeys: {
            dbKey?: string;
            exchangeKeys?: CryptoKeyPair | null;
            writeKeys?: CryptoKeyPair | null;
        }

      Returns Promise<T>

    • Delete a stored keypair without loading it first. Deletes the keys from indexedDB, and destroys the cached instance, if there is one for these names.

      Parameters

      • Optionalopts: { encryptionKeyName?: string; writeKeyName?: string } = {}

        The indexedDB names to delete. Defaults to this class's names.

      Returns Promise<void>

    • Return a 32-character, DNS-friendly hash of the given DID.

      Parameters

      • did: `did:key:z${string}`

        A DID format string

      Returns Promise<string>

      32 character, base32 hash of the DID

    • Parameters

      • opts: { encryptionKeyName?: string; writeKeyName?: string } = {}

      Returns Promise<boolean>

    • Restore some keys from indexedDB, or create a new keypair if it doesn't exist yet.

      By default this saves the keys to indexedDB before returning, so the keypair you get back survives a page reload. Pass { persist: false } to skip that and call .persist() yourself. Session keys are never written to indexedDB, so { session: true } wins over persist.

      Type Parameters

      Parameters

      • this: ChildKeys<AbstractKeys> & typeof AbstractKeys
      • opts: Partial<
            {
                dbKey: string;
                encryptionKeyName: string;
                extractable: boolean;
                persist: boolean;
                session: boolean;
                writeKeyName: string;
            },
        > = ...

        dbKey prefixes both default indexedDB names. Other strings are custom names, plus session and persist options.

      Returns Promise<T>