Skip to main content

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:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.AppUtils.verifyAccountProof(appIdentifier, accountProofData, opts)

Or import the namespace directly:


_10
import { AppUtils } from "@onflow/fcl-core"
_10
_10
AppUtils.verifyAccountProof(appIdentifier, accountProofData, opts)

Usage


_13
import * as fcl from "@onflow/fcl"
_13
_13
const 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
_13
const 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:

_10
export interface AccountProofData {
_10
address: string
_10
nonce: string
_10
signatures: CompositeSignature[]
_10
}

opts (optional)
  • Type:

_10
export 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:


_10
import * as fcl from "@onflow/fcl-core"
_10
_10
fcl.AppUtils.verifyUserSignatures(message, compSigs, opts)

Or import the namespace directly:


_10
import { AppUtils } from "@onflow/fcl-core"
_10
_10
AppUtils.verifyUserSignatures(message, compSigs, opts)

Usage


_18
// Basic message signature verification
_18
import * as fcl from "@onflow/fcl"
_18
_18
const originalMessage = "Hello, Flow blockchain!"
_18
const hexMessage = Buffer.from(originalMessage).toString("hex")
_18
_18
const 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
_18
const 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:

_10
export interface VerifySignaturesScriptOptions {
_10
fclCryptoContract?: string
_10
}

  • Description: Optional configuration parameters

Returns

Promise<boolean>


Rate this page