@aptos-labs/ts-sdk
Version:
Aptos TypeScript SDK
64 lines • 2.44 kB
TypeScript
import { HexInput, PrivateKeyVariants } from "../../types/index.js";
import { Hex } from "../hex.js";
import { PublicKey } from "./publicKey.js";
import { Signature } from "./signature.js";
/**
* Represents a private key used for signing messages and deriving the associated public key.
* @group Implementation
* @category Serialization
*/
export interface PrivateKey {
/**
* Sign the given message with the private key to create a signature.
* @param message - The message to be signed, provided in HexInput format.
* @returns A Signature object representing the signed message.
* @group Implementation
* @category Serialization
*/
sign(message: HexInput): Signature;
/**
* Derive the public key associated with the private key.
* @group Implementation
* @category Serialization
*/
publicKey(): PublicKey;
/**
* Get the private key in bytes (Uint8Array).
* @group Implementation
* @category Serialization
*/
toUint8Array(): Uint8Array;
}
export declare class PrivateKey {
/**
* The AIP-80 compliant prefixes for each private key type. Append this to a private key's hex representation
* to get an AIP-80 compliant string.
*
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
*/
static readonly AIP80_PREFIXES: {
ed25519: string;
secp256k1: string;
secp256r1: string;
};
/**
* Format a HexInput to an AIP-80 compliant string.
*
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
*
* @param privateKey - The HexString or Uint8Array format of the private key.
* @param privateKeyType - The private key type
*/
static formatPrivateKey(privateKey: HexInput, type: PrivateKeyVariants): string;
/**
* Parse a HexInput that may be a HexString, Uint8Array, or a AIP-80 compliant string to a Hex instance.
*
* [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)
*
* @param value - A HexString, Uint8Array, or a AIP-80 compliant string.
* @param privateKeyType - The private key type
* @param strict - If true, the value MUST be compliant with AIP-80.
*/
static parseHexInput(value: HexInput, type: PrivateKeyVariants, strict?: boolean): Hex;
}
//# sourceMappingURL=privateKey.d.ts.map