MCPcopy Create free account
hub / github.com/circlefin/arc-node / callVerify

Function callVerify

tests/localdev/PQ.test.ts:46–91  ·  view source on GitHub ↗
(
    vk: Hex,
    msg: Hex,
    sig: Hex,
  )

Source from the content-addressed store, hash-verified

44
45 // Helper function to call the precompile via ABI-encoded calldata
46 async function callVerify(
47 vk: Hex,
48 msg: Hex,
49 sig: Hex,
50 ): Promise<{ result: boolean; gasUsed: bigint; success: boolean; error?: string; details?: string }> {
51 try {
52 const calldata = encodeFunctionData({
53 abi: PQ.abi,
54 functionName: 'verifySlhDsaSha2128s',
55 args: [vk, msg, sig],
56 })
57
58 const result = await publicClient.call({
59 to: PQ.address,
60 data: calldata,
61 })
62
63 // Decode the boolean result
64 const isValid = result.data === '0x0000000000000000000000000000000000000000000000000000000000000001'
65
66 // Estimate gas
67 const gasEstimate = await publicClient.estimateGas({
68 to: PQ.address,
69 data: calldata,
70 })
71
72 return { result: isValid, gasUsed: gasEstimate, success: true }
73 } catch (error: unknown) {
74 let errorMessage = ''
75 let errorDetails = ''
76 if (error && typeof error === 'object') {
77 const err = error as Record<string, unknown>
78 errorMessage = (err.shortMessage as string) || (err.message as string) || JSON.stringify(err)
79 errorDetails = (err.details as string) || ''
80 } else {
81 errorMessage = String(error)
82 }
83 return {
84 result: false,
85 gasUsed: 0n,
86 success: false,
87 error: errorMessage,
88 details: errorDetails,
89 }
90 }
91 }
92
93 describe('SLH-DSA-SHA2-128s Signature Verification', () => {
94 it('should verify valid SLH-DSA-SHA2-128s signature', async () => {

Callers 1

PQ.test.tsFile · 0.85

Calls 1

callMethod · 0.80

Tested by

no test coverage detected