PHP WebShell

Текущая директория: /opt/BitGoJS/node_modules/@aptos-labs/ts-sdk/dist/esm

Просмотр файла: chunk-L4SWQLAJ.mjs.map

{"version":3,"sources":["../../src/account/Ed25519Account.ts"],"sourcesContent":["import { AccountAuthenticatorEd25519 } from \"../transactions/authenticator/account\";\nimport { HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { Ed25519PrivateKey, Ed25519PublicKey, Ed25519Signature } from \"../core/crypto\";\nimport type { Account } from \"./Account\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport { generateSigningMessageForTransaction } from \"../transactions/transactionBuilder/signingMessage\";\n\n/**\n * Arguments required to create an instance of an Ed25519 signer.\n *\n * @param privateKey - The private key used for signing.\n * @param address - Optional account address associated with the signer.\n */\nexport interface Ed25519SignerConstructorArgs {\n  privateKey: Ed25519PrivateKey;\n  address?: AccountAddressInput;\n}\n\n/**\n * Arguments for creating an Ed25519 signer from a derivation path.\n *\n * @param path - The derivation path for the Ed25519 key.\n * @param mnemonic - The mnemonic phrase used to generate the key.\n */\nexport interface Ed25519SignerFromDerivationPathArgs {\n  path: string;\n  mnemonic: string;\n}\n\n/**\n * Arguments required to verify an Ed25519 signature against a given message.\n *\n * @param message - The message to be verified, represented in hexadecimal format.\n * @param signature - The Ed25519 signature to validate.\n */\nexport interface VerifyEd25519SignatureArgs {\n  message: HexInput;\n  signature: Ed25519Signature;\n}\n\n/**\n * Represents an Ed25519 account that provides signing capabilities through an Ed25519 private key.\n * This class allows for the creation of accounts, signing messages and transactions, and verifying signatures.\n *\n * Note: Generating an instance of this class does not create the account on-chain.\n */\nexport class Ed25519Account implements Account {\n  /**\n   * Private key associated with the account\n   */\n  readonly privateKey: Ed25519PrivateKey;\n\n  readonly publicKey: Ed25519PublicKey;\n\n  readonly accountAddress: AccountAddress;\n\n  readonly signingScheme = SigningScheme.Ed25519;\n\n  // region Constructors\n\n  /**\n   * Creates an instance of the Ed25519Signer with the specified parameters.\n   * This constructor initializes the private key, public key, and account address for the signer.\n   *\n   * @param args - The constructor arguments for the Ed25519Signer.\n   * @param args.privateKey - The private key used for signing.\n   * @param args.address - The optional account address; if not provided, it will derive the address from the public key.\n   */\n  constructor(args: Ed25519SignerConstructorArgs) {\n    const { privateKey, address } = args;\n    this.privateKey = privateKey;\n    this.publicKey = privateKey.publicKey();\n    this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n  }\n\n  /**\n   * Generates a new Ed25519 account using a randomly generated private key.\n   * This function is useful for creating a signer that can be used for cryptographic operations.\n   *\n   * @returns {Ed25519Account} The newly generated Ed25519 account.\n   */\n  static generate(): Ed25519Account {\n    const privateKey = Ed25519PrivateKey.generate();\n    return new Ed25519Account({ privateKey });\n  }\n\n  /**\n   * Derives an Ed25519 account using a specified BIP44 path and mnemonic seed phrase.\n   *\n   * @param args - The arguments for deriving the account.\n   * @param args.path - The BIP44 derive hardened path, e.g., m/44'/637'/0'/0'/0'.\n   * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}\n   * @param args.mnemonic - The mnemonic seed phrase of the account.\n   */\n  static fromDerivationPath(args: Ed25519SignerFromDerivationPathArgs) {\n    const { path, mnemonic } = args;\n    const privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);\n    return new Ed25519Account({ privateKey });\n  }\n  // endregion\n\n  // region Account\n  /**\n   * Verify the given message and signature with the public key.\n   *\n   * @param args - The arguments for verifying the signature.\n   * @param args.message - Raw message data in HexInput format.\n   * @param args.signature - Signed message signature.\n   * @returns A boolean indicating whether the signature is valid.\n   */\n  verifySignature(args: VerifyEd25519SignatureArgs): boolean {\n    return this.publicKey.verifySignature(args);\n  }\n\n  /**\n   * Sign a message using the account's Ed25519 private key.\n   * This function returns an AccountAuthenticator containing the signature along with the account's public key.\n   *\n   * @param message - The signing message, represented as hexadecimal input.\n   * @returns An AccountAuthenticator containing the signature and the account's public key.\n   */\n  signWithAuthenticator(message: HexInput): AccountAuthenticatorEd25519 {\n    return new AccountAuthenticatorEd25519(this.publicKey, this.privateKey.sign(message));\n  }\n\n  /**\n   * Sign a transaction using the account's Ed25519 private key.\n   * This function returns an AccountAuthenticator that contains the signature of the transaction along with the account's public key.\n   *\n   * @param transaction - The raw transaction to be signed.\n   * @returns An AccountAuthenticator containing the signature and the public key.\n   */\n  signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorEd25519 {\n    return new AccountAuthenticatorEd25519(this.publicKey, this.signTransaction(transaction));\n  }\n\n  /**\n   * Sign the given message using the account's Ed25519 private key.\n   * @param message - The message to be signed in HexInput format.\n   * @returns Signature - The resulting signature of the signed message.\n   */\n  sign(message: HexInput): Ed25519Signature {\n    return this.privateKey.sign(message);\n  }\n\n  /**\n   * Sign the given transaction using the available signing capabilities.\n   * This function helps ensure that the transaction is properly authenticated before submission.\n   *\n   * @param transaction - The transaction to be signed.\n   * @returns Signature - The resulting signature for the transaction.\n   */\n  signTransaction(transaction: AnyRawTransaction): Ed25519Signature {\n    return this.sign(generateSigningMessageForTransaction(transaction));\n  }\n\n  // endregion\n}\n"],"mappings":"oKA+CO,IAAMA,EAAN,MAAMC,CAAkC,CAsB7C,YAAYC,EAAoC,CAZhD,KAAS,cAAgB,EAavB,GAAM,CAAE,WAAAC,EAAY,QAAAC,CAAQ,EAAIF,EAChC,KAAK,WAAaC,EAClB,KAAK,UAAYA,EAAW,UAAU,EACtC,KAAK,eAAiBC,EAAUC,EAAe,KAAKD,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,CACzG,CAQA,OAAO,UAA2B,CAChC,IAAMD,EAAaG,EAAkB,SAAS,EAC9C,OAAO,IAAIL,EAAe,CAAE,WAAAE,CAAW,CAAC,CAC1C,CAUA,OAAO,mBAAmBD,EAA2C,CACnE,GAAM,CAAE,KAAAK,EAAM,SAAAC,CAAS,EAAIN,EACrBC,EAAaG,EAAkB,mBAAmBC,EAAMC,CAAQ,EACtE,OAAO,IAAIP,EAAe,CAAE,WAAAE,CAAW,CAAC,CAC1C,CAYA,gBAAgBD,EAA2C,CACzD,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CASA,sBAAsBO,EAAgD,CACpE,OAAO,IAAIC,EAA4B,KAAK,UAAW,KAAK,WAAW,KAAKD,CAAO,CAAC,CACtF,CASA,iCAAiCE,EAA6D,CAC5F,OAAO,IAAID,EAA4B,KAAK,UAAW,KAAK,gBAAgBC,CAAW,CAAC,CAC1F,CAOA,KAAKF,EAAqC,CACxC,OAAO,KAAK,WAAW,KAAKA,CAAO,CACrC,CASA,gBAAgBE,EAAkD,CAChE,OAAO,KAAK,KAAKC,EAAqCD,CAAW,CAAC,CACpE,CAGF","names":["Ed25519Account","_Ed25519Account","args","privateKey","address","AccountAddress","Ed25519PrivateKey","path","mnemonic","message","AccountAuthenticatorEd25519","transaction","generateSigningMessageForTransaction"]}

Выполнить команду


Для локальной разработки. Не используйте в интернете!