11import type { NextApiRequest , NextApiResponse } from 'next' ;
2- import { UltraHonkBackend , BarretenbergVerifier } from '@aztec/bb.js' ;
2+ import { UltraHonkBackend } from '@aztec/bb.js' ;
33import { promises as fs } from 'fs' ;
44import path from 'path' ;
55
@@ -12,7 +12,7 @@ async function initializeCircuit() {
1212 const circuitPath = path . resolve ( process . cwd ( ) , '../../circuits/target/noir_uh_starter.json' ) ;
1313 const circuitData = await fs . readFile ( circuitPath , 'utf-8' ) ;
1414 circuit = JSON . parse ( circuitData ) ;
15- honk = new UltraHonkBackend ( circuit . bytecode , {
15+ honk = new UltraHonkBackend ( circuit . bytecode , {
1616 threads : 8 ,
1717
1818 // By default, bb.js downloads CRS files to ~/.bb-crs. For serverless environments where
@@ -36,11 +36,11 @@ export default async function handler(
3636 await initializeCircuit ( ) ;
3737
3838 const { proof, publicInputs } = req . body ;
39-
39+
4040 if ( ! proof || ! publicInputs ) {
41- return res . status ( 400 ) . json ( {
41+ return res . status ( 400 ) . json ( {
4242 error : 'Missing proof or publicInputs' ,
43- verified : false
43+ verified : false
4444 } ) ;
4545 }
4646
@@ -61,23 +61,23 @@ export default async function handler(
6161 } else {
6262 throw new Error ( 'Invalid proof format' ) ;
6363 }
64-
64+
6565 const publicInputsArray = Array . isArray ( publicInputs ) ? publicInputs : [ publicInputs ] ;
66-
67- const verified = await honk . verifyProof ( {
68- proof : proofArray ,
69- publicInputs : publicInputsArray
66+
67+ const verified = await honk . verifyProof ( {
68+ proof : proofArray ,
69+ publicInputs : publicInputsArray
7070 } ) ;
71-
72- return res . status ( 200 ) . json ( {
71+
72+ return res . status ( 200 ) . json ( {
7373 verified,
7474 message : verified ? 'Proof verified successfully' : 'Proof verification failed'
7575 } ) ;
7676 } catch ( error ) {
7777 console . error ( 'Server-side verification error:' , error ) ;
78- return res . status ( 500 ) . json ( {
79- error : String ( error ) ,
80- verified : false
78+ return res . status ( 500 ) . json ( {
79+ error : String ( error ) ,
80+ verified : false
8181 } ) ;
8282 }
8383}
0 commit comments