@aptos-labs/ts-sdk - v5.1.4
    Preparing search index...

    Class KeylessPublicKey

    Represents a Keyless Public Key used for authentication.

    This class encapsulates the public key functionality for keyless authentication, including methods for generating and verifying signatures, as well as serialization and deserialization of the key. The KeylessPublicKey is represented in the SDK as AnyPublicKey.

    Hierarchy (View Summary)

    Index

    Implementation - BCS

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

    Implementation - Serialization

    idCommitment: Uint8Array

    A value representing a cryptographic commitment to a user identity.

    It is calculated from the aud, uidKey, uidVal, pepper.

    iss: string

    The value of the 'iss' claim on the JWT which identifies the OIDC provider.

    ID_COMMITMENT_LENGTH: number = 32

    The number of bytes that idCommitment should be

    • Serializes the current instance into a format suitable for transmission or storage. This function ensures that all relevant fields are properly serialized, including the proof and optional fields.

      Parameters

      • serializer: Serializer

        The serializer instance used to perform the serialization.

      Returns void

    • Creates a KeylessPublicKey from the JWT components plus pepper

      Parameters

      • args: { aud: string; iss: string; pepper: HexInput; uidKey: string; uidVal: string }
        • aud: string

          the client ID of the application

        • iss: string

          the iss of the identity

        • pepper: HexInput

          The pepper used to maintain privacy of the account

        • uidKey: string

          the key to use to get the uidVal in the JWT token

        • uidVal: string

          the value of the uidKey in the JWT token

      Returns KeylessPublicKey

      KeylessPublicKey

    • Creates a KeylessPublicKey instance from a JWT and a pepper value. This function is useful for generating a public key that can be used for authentication based on the provided JWT claims and pepper.

      Parameters

      • args: { jwt: string; pepper: HexInput; uidKey?: string }

        The arguments for creating the KeylessPublicKey.

        • jwt: string

          The JSON Web Token to decode.

        • pepper: HexInput

          The pepper value used in the key creation process.

        • OptionaluidKey?: string

          An optional key to retrieve the unique identifier from the JWT payload, defaults to "sub".

      Returns KeylessPublicKey

      A KeylessPublicKey instance created from the provided JWT and pepper.

    • Checks if the provided public key is a valid instance by verifying its structure and types.

      Parameters

      • publicKey: PublicKey

        The public key to validate.

      Returns boolean

      A boolean indicating whether the public key is a valid instance.

    Methods

    • Verifies a keyless signature for a given message. It will fetch the keyless configuration and the JWK to use for verification from the appropriate network as defined by the aptosConfig.

      Parameters

      • args: {
            aptosConfig: AptosConfig;
            message: HexInput;
            options?: { throwErrorWithReason?: boolean };
            signature: Signature;
        }
        • aptosConfig: AptosConfig

          The aptos config to use for fetching the keyless configuration.

        • message: HexInput

          The message to verify the signature against.

        • Optionaloptions?: { throwErrorWithReason?: boolean }
          • OptionalthrowErrorWithReason?: boolean

            Whether to throw an error with the reason for the failure instead of returning false.

        • signature: Signature

          The signature to verify.

      Returns Promise<boolean>

      true if the signature is valid