@aptos-labs/ts-sdk - v3.1.1
    Preparing search index...

    Class MultiKey

    Represents a multi-key authentication scheme for accounts, allowing multiple public keys to be associated with a single account. This class enforces a minimum number of valid signatures required to authorize actions, ensuring enhanced security for multi-agent accounts.

    The public keys of each individual agent can be any type of public key supported by Aptos. Since AIP-55, Aptos supports Legacy and Unified authentication keys.

    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

    • Signature for a K-of-N multi-sig transaction. This constructor initializes a multi-signature transaction with the provided signatures and bitmap.

      Parameters

      • args: { publicKeys: PublicKey[]; signaturesRequired: number }

        An object containing the parameters for the multi-signature transaction.

      Returns MultiKey

      Error if the number of signatures exceeds the maximum supported, if the bitmap length is incorrect, or if the number of signatures does not match the bitmap.

    publicKeys: AnyPublicKey[]

    List of any public keys

    signaturesRequired: number

    The minimum number of valid signatures required, for the number of public keys specified

    • Create a bitmap that holds the mapping from the original public keys to the signatures passed in

      Parameters

      • args: { bits: number[] }
        • bits: number[]

          array of the index mapping to the matching public keys

      Returns Uint8Array

      Uint8array bit map

    • Serializes the object by writing its signatures and bitmap to the provided serializer. This allows the object to be converted into a format suitable for transmission or storage.

      Parameters

      • serializer: Serializer

        The serializer instance used to perform the serialization.

      Returns void

    • Verifies the provided signature against the given message. This function helps ensure the integrity and authenticity of the message by checking if the signature is valid.

      Parameters

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

        The arguments for verifying the signature.

        • aptosConfig: AptosConfig

          The Aptos configuration to use

        • message: HexInput

          The message that was signed.

        • Optionaloptions?: { throwErrorWithReason?: boolean }
        • signature: Signature

          The signature to verify.

      Returns Promise<boolean>

    • Deserializes a MultiKeySignature from the provided deserializer. This function retrieves the signatures and bitmap necessary for creating a MultiKeySignature object.

      Parameters

      • deserializer: Deserializer

        The deserializer instance used to read the serialized data.

      Returns MultiKey

    Implementation - Other

    • Get the index of the provided public key.

      This function retrieves the index of a specified public key within the MultiKey. If the public key does not exist, it throws an error.

      Parameters

      • publicKey: PublicKey

        The public key to find the index for.

      Returns number

      The corresponding index of the public key, if it exists.

      Error - If the public key is not found in the MultiKey.

    Methods