UNPKG

@aptos-labs/ts-sdk

Version:
1 lines 1.79 kB
{"version":3,"sources":["../../src/core/crypto/publicKey.ts"],"sourcesContent":["import { Serializable } from \"../../bcs\";\nimport { HexInput } from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { Signature } from \"./signature\";\n\n/**\n * Arguments for verifying a signature\n */\nexport interface VerifySignatureArgs {\n message: HexInput;\n signature: Signature;\n}\n\n/**\n * An abstract representation of a public key.\n *\n * Provides a common interface for verifying any signature.\n */\nexport abstract class PublicKey extends Serializable {\n /**\n * Verifies that the private key associated with this public key signed the message with the given signature.\n * @param args.message The message that was signed\n * @param args.signature The signature to verify\n */\n abstract verifySignature(args: VerifySignatureArgs): boolean;\n\n /**\n * Get the raw public key bytes\n */\n abstract toUint8Array(): Uint8Array;\n\n /**\n * Get the public key as a hex string with a 0x prefix e.g. 0x123456...\n */\n toString(): string {\n const bytes = this.toUint8Array();\n return Hex.fromHexInput(bytes).toString();\n }\n}\n\n/**\n * An abstract representation of an account public key.\n *\n * Provides a common interface for deriving an authentication key.\n */\nexport abstract class AccountPublicKey extends PublicKey {\n /**\n * Get the authentication key associated with this public key\n */\n abstract authKey(): AuthenticationKey;\n}\n"],"mappings":"kFAmBO,IAAeA,EAAf,cAAiCC,CAAa,CAgBnD,UAAmB,CACjB,IAAMC,EAAQ,KAAK,aAAa,EAChC,OAAOC,EAAI,aAAaD,CAAK,EAAE,SAAS,CAC1C,CACF,EAOsBE,EAAf,cAAwCJ,CAAU,CAKzD","names":["PublicKey","Serializable","bytes","Hex","AccountPublicKey"]}