Represents an ephemeral key pair used for signing transactions via the Keyless authentication scheme. This key pair is temporary and includes an expiration time. For more details on how this class is used, refer to the documentation: https://aptos.dev/guides/keyless-accounts/#1-present-the-user-with-a-sign-in-with-idp-button-on-the-ui

Hierarchy (view full)

Constructors

  • Creates an instance of the class with a specified private key, optional expiry date, and optional blinder. This constructor initializes the public key, sets the expiry date to a default value if not provided, generates a blinder if not supplied, and calculates the nonce based on the public key, expiry date, and blinder.

    Parameters

    • args: {
          blinder?: HexInput;
          expiryDateSecs?: number;
          privateKey: PrivateKey;
      }

      The parameters for constructing the instance.

      • Optionalblinder?: HexInput

        Optional blinder value. If not provided, a new blinder will be generated.

      • OptionalexpiryDateSecs?: number

        Optional expiry date in seconds from the current time. Defaults to two weeks from now.

      • privateKey: PrivateKey

        The private key used for creating the instance.

    Returns EphemeralKeyPair

Methods

  • Serializes a Serializable value to its BCS representation. This function is the TypeScript SDK equivalent of bcs::to_bytes in Move.

    Returns Uint8Array

    the BCS representation of the Serializable instance as a byte buffer.

  • Converts the BCS-serialized bytes of a value into a Hex instance. This function provides a Hex representation of the BCS-serialized data for easier handling and manipulation.

    Returns Hex

    A Hex instance with the BCS-serialized bytes loaded into its underlying Uint8Array.

  • Checks if the current time has surpassed the expiry date of the key pair.

    Returns boolean

    boolean - Returns true if the key pair is expired, otherwise false.

  • Serializes the object's properties into a format suitable for transmission or storage. This function is essential for preparing the object data for serialization processes.

    Parameters

    • serializer: Serializer

      The serializer instance used to serialize the object's properties.

    Returns void

  • Sign the given data using the private key, returning an ephemeral signature. This function is essential for creating a secure signature that can be used for authentication or verification purposes.

    Parameters

    • data: HexInput

      The data to be signed, provided in HexInput format.

    Returns EphemeralSignature

    EphemeralSignature - The resulting ephemeral signature.

    Error - Throws an error if the EphemeralKeyPair has expired.

  • Returns the hex string representation of the Serializable value with the 0x prefix.

    Returns string

    the hex formatas a string prefixed by 0x.

  • Deserialize a byte array into an EphemeralKeyPair object. This function allows you to reconstruct an EphemeralKeyPair from its serialized byte representation.

    Parameters

    • bytes: Uint8Array

      The byte array representing the serialized EphemeralKeyPair.

    Returns EphemeralKeyPair

  • Generates a new ephemeral key pair with an optional expiry date. This function allows you to create a temporary key pair for secure operations.

    Parameters

    • Optionalargs: {
          expiryDateSecs?: number;
          scheme?: Ed25519;
      }

      Optional parameters for key pair generation.

      • OptionalexpiryDateSecs?: number

        The date of expiry for the key pair in seconds.

      • Optionalscheme?: Ed25519

        The type of key pair to use for the EphemeralKeyPair. Only Ed25519 is supported for now.

    Returns EphemeralKeyPair

    An instance of EphemeralKeyPair containing the generated private key and expiry date.

Properties

blinder: Uint8Array

A byte array of length BLINDER_LENGTH used to obfuscate the public key from the IdP. Used in calculating the nonce passed to the IdP and as a secret witness in proof generation.

expiryDateSecs: number

A timestamp in seconds indicating when the ephemeral key pair is expired. After expiry, a new EphemeralKeyPair must be generated and a new JWT needs to be created.

nonce: string

The value passed to the IdP when the user authenticates. It consists of a hash of the ephemeral public key, expiry date, and blinder.

BLINDER_LENGTH: number = 31