UNPKG

@firefly-exchange/library-sui

Version:

Sui library housing helper methods, classes to interact with Bluefin protocol(s) deployed on Sui

44 lines (43 loc) 1.98 kB
import { PAYLOAD_REQUEST_TYPE } from "../enums"; import { Address, Signer, SuiClient } from "../../types"; export declare class Signature { /** * Given a hex data string computes its blake2b hash and returns the hex * @param hexData a hex string * @returns hex sha256 hash */ static hash(hexData: string): string; /** * Signs the provided request object * @param signer The signer object * @param data A JSON request payload * @returns A base64 representation of signature containing: * 1. scheme (1 byte), * 2. signature (64 bytes) * 3. public key (32/33 bytes) */ static signRequest(signer: Signer, msgBytes: Uint8Array): Promise<string>; /** * Validates if the signature is for the provided quote * @param data The JSON request data that was signed to create the signature * @param signature The base64 signature containing wallet scheme + signature + public key * @param signer The expected address of the signer * @returns True if the signature is created on the given quote and belongs to provided `signer` */ static verifyRequestSignature(data: unknown, signature: string, signer: Address): Promise<boolean>; /** * Verifies the given payload/signature on-chain * @param serializedData The BCS serialized data of the payload that was signed * @param signature The signature created * @param type The payload/request type * @param expectedSigner The address of the expected signer * @param chain chain details including the pkg id and the sui client * @param stringify * @returns True if the signature is verified on-chain */ static verifyRequestSignatureOnChain(serializedData: string, signature: string, type: PAYLOAD_REQUEST_TYPE, expectedSigner: Address, chain: { pkg: string; client: SuiClient; }, verbose?: boolean): Promise<boolean>; private static marshalDataToMsgBytes; }