* Verifies a payload signature. * @param algorithm The algorithm to use (e.g., "ed25519", "secp256k1", "secp256k1_prehashed") * @param data The data that was signed. * @param signature The signature to verify. * @param publicKey The public key to use for verification. * @returns A Ver
(
algorithm: string,
data: string | Buffer | Uint8Array,
signature: string | Buffer | Uint8Array,
publicKey: string | Buffer | Uint8Array
)
| 384 | * @returns A VerifyResponse indicating if the signature is valid. |
| 385 | */ |
| 386 | async verify( |
| 387 | algorithm: string, |
| 388 | data: string | Buffer | Uint8Array, |
| 389 | signature: string | Buffer | Uint8Array, |
| 390 | publicKey: string | Buffer | Uint8Array |
| 391 | ): Promise<VerifyResponse> { |
| 392 | const payload = JSON.stringify({ |
| 393 | algorithm: algorithm, |
| 394 | data: to_hex(data), |
| 395 | signature: to_hex(signature), |
| 396 | public_key: to_hex(publicKey) |
| 397 | }); |
| 398 | |
| 399 | const result = await send_rpc_request<{ valid: boolean }>(this.endpoint, '/Verify', payload); |
| 400 | |
| 401 | return Object.freeze({ |
| 402 | ...result, |
| 403 | __name__: 'VerifyResponse', |
| 404 | }); |
| 405 | } |
| 406 | |
| 407 | // |
| 408 | // Legacy methods for backward compatibility with a warning to notify users about migrating to new methods. |