AppUtils
Overview
Namespace containing AppUtils utilities
Functions
verifyAccountProof
Verifies the authenticity of an account proof signature on the Flow blockchain. Account proofs are cryptographic signatures used to prove ownership of a Flow account without revealing private keys. This function validates that the provided signatures were indeed created by the private keys associated with the specified Flow account address.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.AppUtils.verifyAccountProof(appIdentifier, accountProofData, opts)
Or import the namespace directly:
_10import { AppUtils } from "@onflow/fcl-core"_10_10AppUtils.verifyAccountProof(appIdentifier, accountProofData, opts)
Usage
_13import * as fcl from "@onflow/fcl"_13_13const accountProofData = {_13 address: "0x123",_13 nonce: "F0123"_13 signatures: [{f_type: "CompositeSignature", f_vsn: "1.0.0", addr: "0x123", keyId: 0, signature: "abc123"}],_13}_13_13const isValid = await fcl.AppUtils.verifyAccountProof(_13 "AwesomeAppId",_13 accountProofData,_13 {fclCryptoContract}_13)
Parameters
appIdentifier
- Type:
string
- Description: A unique identifier for your application. This is typically your app's name or domain and is included in the signed message to prevent replay attacks across different applications.
accountProofData
- Type:
_10export interface AccountProofData {_10 address: string_10 nonce: string_10 signatures: CompositeSignature[]_10}
opts
(optional)
- Type:
_10export interface VerifySignaturesScriptOptions {_10 fclCryptoContract?: string_10}
- Description: Optional configuration parameters
Returns
Promise<boolean>
verifyUserSignatures
Verifies user signatures for arbitrary messages on the Flow blockchain. This function validates that the provided signatures were created by the private keys associated with the specified Flow account when signing the given message. This is useful for authenticating users or validating signed data outside of transaction contexts.
Import
You can import the entire package and access the function:
_10import * as fcl from "@onflow/fcl-core"_10_10fcl.AppUtils.verifyUserSignatures(message, compSigs, opts)
Or import the namespace directly:
_10import { AppUtils } from "@onflow/fcl-core"_10_10AppUtils.verifyUserSignatures(message, compSigs, opts)
Usage
_18// Basic message signature verification_18import * as fcl from "@onflow/fcl"_18_18const originalMessage = "Hello, Flow blockchain!"_18const hexMessage = Buffer.from(originalMessage).toString("hex")_18_18const signatures = [{_18 f_type: "CompositeSignature",_18 f_vsn: "1.0.0",_18 addr: "0x1234567890abcdef",_18 keyId: 0,_18 signature: "abc123def456..." // signature from user's wallet_18}]_18_18const isValid = await fcl.AppUtils.verifyUserSignatures(_18 hexMessage,_18 signatures_18)
Parameters
message
- Type:
string
- Description: The message that was signed, encoded as a hexadecimal string. The original message should be converted to hex before passing to this function.
compSigs
- Type:
CompositeSignature[]
- Description: Array of composite signatures to verify. All signatures must be from the same account address.
opts
(optional)
- Type:
_10export interface VerifySignaturesScriptOptions {_10 fclCryptoContract?: string_10}
- Description: Optional configuration parameters
Returns
Promise<boolean>