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

    Class EccKeys

    Class for ECC keys

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    DID: `did:key:z${string}`
    exchangeKey: CryptoKeyPair
    hasPersisted: boolean
    isSessionOnly: boolean
    writeKey: CryptoKeyPair
    _instance: any
    EXCHANGE_KEY_NAME: string = DEFAULT_ECC_EXCHANGE
    INFO: string = 'keys'
    TYPE: "ecc" | "rsa" = ...
    WRITE_KEY_NAME: string = DEFAULT_ECC_WRITE

    Accessors

    • get deviceName(): Promise<string>

      The machine-readable name for this keypair.

      Returns Promise<string>

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

    Methods

    • Decrypt the given message. The encrypted message should be salt + iv + cipher text.

      Parameters

      • msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>

        The encrypted content

      • OptionalpublicKey: string | CryptoKey

        The public key used to generate the AES key used on this message. If omitted, decrypt with our own public key.

      • OptionalaesAlgorithm: string
      • Optionalinfo: string

      Returns Promise<ArrayBuffer | Uint8Array<ArrayBufferLike>>

      The decrypted content.

    • Decrypt and return as string.

      Parameters

      • msg: string | ArrayBuffer | Uint8Array<ArrayBufferLike>
      • OptionalpublicKey: string | CryptoKey
      • OptionalaesAlgorithm: string
      • Optionalinfo: string

      Returns Promise<string>

    • Encrypt the given content to the given public key, or encrypt to our public key if it is not passed in.

      Parameters

      • content: string | Uint8Array<ArrayBufferLike>

        Content to encrypt

      • Optionalrecipient: string | CryptoKey

        Their public key. Optional b/c we will use our own public key if not passed in.

      • Optionalinfo: string

        info tag for HKDF. Default is the class property.

      • OptionalaesKey: string | Uint8Array<ArrayBufferLike> | CryptoKey

        This is not relevant for most use cases.

      • Optionalkeysize: SymmKeyLength

        Default is 256

      Returns Promise<Uint8Array<ArrayBufferLike>>

      Buffer of salt + iv + cipher text

    • Encrypt and return as base64 string.

      Parameters

      • content: string | Uint8Array<ArrayBufferLike>
      • Optionalrecipient: string | CryptoKey
      • Optionalinfo: string
      • OptionalaesKey: string | Uint8Array<ArrayBufferLike> | CryptoKey
      • Optionalkeysize: SymmKeyLength

      Returns Promise<string>

    • Do DHKE, create a new AES-GCM key.

      Parameters

      • OptionalpublicKey: null | string | CryptoKey

        Public key to use in DHKE. Will use our public key if it is not passed in.

      • Optionalinfo: null | string

        The info parameter for DHKE. Will use the class property INFO if it is not passed in.

      Returns Promise<CryptoKey>

      New AES key

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

      Returns Promise<string>

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

      Parameters

      • Optionalformat: SupportedEncodings

      Returns Promise<{ DID: `did:key:z${string}`; publicExchangeKey: 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. Overrides base class to use ECC-specific key names.

      Type Parameters

      Parameters

      • this: typeof EccKeys
      • opts: Partial<{ encryptionKeyName: string; session: boolean; signingKeyName: string }> = ...

      Returns Promise<T>