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

    Class RsaKeys

    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 = DEFAULT_RSA_EXCHANGE
    INFO: string = 'keys'
    TYPE: "rsa" = ...
    WRITE_KEY_NAME: string = DEFAULT_RSA_WRITE
    • 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 privateWriteKey(): 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

    • Decrypt the given message. Expects encrypted AES key + encrypted content.

      The RSA-encrypted AES key is always exactly one RSA-modulus-sized block, so the split point between it and the AES-encrypted content is derived from this instance's RSA modulus length -- not from the (unrelated) AES key size.

      Parameters

      • msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>
      • Optional_keysize: string | CryptoKey | SymmKeyLength
      • Optional_aesAlgorithm: string

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Decrypt and return as string.

      Parameters

      • msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>
      • Optionalkeysize: string | CryptoKey | SymmKeyLength
      • Optional_aesAlgorithm: string

      Returns Promise<string>

    • Decrypt the given encrypted AES key. Return the key as Uint8Array.

      Parameters

      • key: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Decrypt the given AES key, return the result as a string.

      Parameters

      • msg: string | Uint8Array<ArrayBufferLike>
      • Optionalformat: SupportedEncodings

      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>

    • Encrypt content using hybrid encryption (RSA + AES).

      Parameters

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

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Encrypt and return as base64 string.

      Parameters

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

      Returns Promise<string>

    • Get the relevant AES key for RSA - decrypt the given encrypted key.

      Parameters

      • OptionalencryptedKey: string | CryptoKey | null
      • Optional_info: string | null

      Returns Promise<CryptoKey>

    • Sign the message, and return the signature as a Uint8Array.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Serialize this keys instance. Will return an object of { DID, publicExchangeKey }, where DID is the public signature key, and publicExchangeKey is the encryption key, base64 encoded.

      Parameters

      • Optionalformat: SupportedEncodings

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

    • 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 }

    • Factory function.

      Type Parameters

      Parameters

      • Optionalsession: boolean

        Session only? i.e., not saved in indexedDB. Default false.

      • Optionalextractable: boolean

        Can we extract the private keys? Default false.

      • Optionalkeys: {
            dbKey?: string;
            exchangeKeys?: CryptoKeyPair | null;
            writeKeys?: CryptoKeyPair | null;
        }

        Key options. dbKey prefixes the IndexedDB names used for both keypairs.

      Returns Promise<T>

      A new class instance.

    • 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 keys from indexedDB using the RSA key names.

      Type Parameters

      Parameters

      • this: typeof RsaKeys
      • Optionalopts: Partial<
            {
                dbKey: string;
                encryptionKeyName: string;
                extractable: boolean;
                persist: boolean;
                session: boolean;
                writeKeyName: string;
            },
        > = ...

        Prefix for both IndexedDB key names.

      Returns Promise<T>