Expose RSA keys only for now, because we are waiting for more browsers to support ECC.

Create an instance with Keys.create b/c async.

Constructors

  • Parameters

    • opts: ConstructorOpts

    Returns Keys

Properties

decrypt: (
    msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>,
    keysize?: SymmKeyLength,
) => Promise<Uint8Array<ArrayBufferLike>> & {
    asString: (msg: string, keysize?: SymmKeyLength) => Promise<string>;
} = ...

Type declaration

    • (
          msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>,
          keysize?: SymmKeyLength,
      ): Promise<Uint8Array<ArrayBufferLike>>
    • Expect the given cipher content to be the format returned by encryptTo. That is, encrypted AES key + iv` + encrypted content.

      Parameters

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

      Returns Promise<Uint8Array<ArrayBufferLike>>

  • asString: (msg: string, keysize?: SymmKeyLength) => Promise<string>
decryptKey: (
    key: string | ArrayBuffer | Uint8Array<ArrayBufferLike>,
) => Promise<Uint8Array<ArrayBufferLike>> & {
    asString: (
        msg: string | Uint8Array<ArrayBufferLike>,
        format?: SupportedEncodings,
    ) => Promise<string>;
} = ...

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

Type declaration

    • (
          key: string | ArrayBuffer | Uint8Array<ArrayBufferLike>,
      ): Promise<Uint8Array<ArrayBufferLike>>
    • Parameters

      • key: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

      Returns Promise<Uint8Array<ArrayBufferLike>>

  • asString: (
        msg: string | Uint8Array<ArrayBufferLike>,
        format?: SupportedEncodings,
    ) => Promise<string>

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

DID: `did:key:z${string}`
ENCRYPTION_KEY_NAME: string = DEFAULT_ENC_NAME
getPublicEncryptKey: (format?: SupportedEncodings) => Promise<string> & {
    uint8Array: () => Promise<Uint8Array<ArrayBufferLike>>;
} = ...

Get the public encryption key as a string.

Optional string format for uint8arrays. Defaults to base64.

Return a string b/c mostly would use this for serializing the public encryption key.

persisted: boolean
sign: (msg: Msg, charsize?: CharSize) => Promise<Uint8Array<ArrayBufferLike>> & {
    asString: (msg: Msg, charsize?: CharSize) => Promise<string>;
} = ...

Type declaration

    • (msg: Msg, charsize?: CharSize): Promise<Uint8Array<ArrayBufferLike>>
    • Sign the message, and return the signature as a Uint8Array.

      Parameters

      • msg: Msg
      • charsize: CharSize = DEFAULT_CHAR_SIZE

      Returns Promise<Uint8Array<ArrayBufferLike>>

  • asString: (msg: Msg, charsize?: CharSize) => Promise<string>

    Sign a message, return the signature as a base64 encoded string.

SIGNING_KEY_NAME: string = DEFAULT_SIG_NAME
_instance: any

Accessors

  • get deviceName(): Promise<string>

    Returns Promise<string>

  • get encryptKeypair(): CryptoKeyPair

    Returns CryptoKeyPair

  • get privateEncryptKey(): CryptoKey

    Returns CryptoKey

  • get privateSignKey(): CryptoKey

    Returns CryptoKey

  • get publicEncryptKey(): CryptoKey

    Returns CryptoKey

  • get publicSignKey(): CryptoKey

    Returns CryptoKey

  • get signKeypair(): CryptoKeyPair

    Returns CryptoKeyPair

Methods

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

    Returns Promise<string>

  • Save this keys instance to indexedDB.

    Returns Promise<void>

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

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

  • 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

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

    Parameters

    • opts: { encryptionKeyName: any; signingKeyName: any } = ...

      Strings to use as keys in indexedDB.

    Returns Promise<Keys>