Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ECDSAKeyIdentity

An identity interface that wraps an ECDSA keypair using the P-256 named curve. Supports DER-encoding and decoding for agent calls

Hierarchy

  • SignIdentity
    • ECDSAKeyIdentity

Index

Constructors

  • new ECDSAKeyIdentity(keyPair: CryptoKeyPair, derKey: DerEncodedPublicKey, subtleCrypto: SubtleCrypto): ECDSAKeyIdentity

Properties

_derKey: DerEncodedPublicKey
_keyPair: CryptoKeyPair
_principal: undefined | Principal
_subtleCrypto: SubtleCrypto

Methods

  • getKeyPair(): CryptoKeyPair
  • getPrincipal(): Principal
  • Get the principal represented by this identity. Normally should be a Principal.selfAuthenticating().

    Returns Principal

  • sign(challenge: ArrayBuffer): Promise<Signature>
  • Signs a blob of data, with this identity's private key.

    Parameters

    • challenge: ArrayBuffer

      challenge to sign with this identity's secretKey, producing a signature

    Returns Promise<Signature>

    signature

  • transformRequest(request: HttpAgentRequest): Promise<unknown>
  • Transform a request into a signed version of the request. This is done last after the transforms on the body of a request. The returned object can be anything, but must be serializable to CBOR.

    Parameters

    • request: HttpAgentRequest

      internet computer request to transform

    Returns Promise<unknown>

  • fromKeyPair(keyPair: CryptoKeyPair | { privateKey: CryptoKey; publicKey: CryptoKey }, subtleCrypto?: SubtleCrypto): Promise<ECDSAKeyIdentity>
  • generates an identity from a public and private key. Please ensure that you are generating these keys securely and protect the user's private key

    Parameters

    • keyPair: CryptoKeyPair | { privateKey: CryptoKey; publicKey: CryptoKey }

      a CryptoKeyPair

    • Optional subtleCrypto: SubtleCrypto

      a SubtleCrypto interface in case one is not available globally

    Returns Promise<ECDSAKeyIdentity>

Generated using TypeDoc