diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index 54e0306..8af9587 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -1,7 +1,6 @@ "use client"; import { useState, useEffect } from "react"; -import { GetServerSideProps } from 'next'; import { Box, Card, @@ -22,9 +21,6 @@ import { import { CheckCircleIcon, TimeIcon, WarningIcon } from "@chakra-ui/icons"; import styled from "@emotion/styled"; import axios from "axios"; -// import { generateJWTVerifierInputs } from "@zk-jwt/helpers/dist/input-generators"; -// import { genAccountCode } from "@zk-email/relayer-utils"; - declare global { interface Window { @@ -54,30 +50,6 @@ interface HomeProps { data: string; } - - -// Helper function to generate random BigInt -// function genAccountCode(): bigint { -// // BN254 Scalar Field fr -// const fr = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"); -// const maxBytes = 32; -// let randomBytes = new Uint8Array(maxBytes); - -// // Continuously generate random numbers until we get one within the range [0, fr) -// while (true) { -// // Fill the array with random values -// window.crypto.getRandomValues(randomBytes); - -// // Convert random bytes to a BigInt -// let randomValue = BigInt('0x' + Array.from(randomBytes).map(byte => byte.toString(16).padStart(2, '0')).join('')); - -// // Return if the randomValue is less than max (fr in this case) -// if (randomValue < fr) { -// return randomValue; -// } -// } -// } - export default function Home() { const [command, setCommand] = useState(""); const [jwt, setJwt] = useState(""); @@ -100,16 +72,11 @@ export default function Home() { try { setStepStatuses((prev) => ["success", "processing", "idle"]); - // const accountCode = await genAccountCode(); - // const circuitInputs = generateJWTVerifierInputs( - // jwt, - // pubkey, - // accountCode, - // { - // maxMessageLength: 1024, - // } - // ); - const response1 = await axios.post('/api/generateCircuitInputs', { jwt, pubkey, maxMessageLength: 1024 }); + const response1 = await axios.post("/api/generateCircuitInputs", { + jwt, + pubkey, + maxMessageLength: 1024, + }); console.log(response1); const { circuitInputs, accountCode } = response1.data.circuitInputs; @@ -133,20 +100,18 @@ export default function Home() { try { const jwt = response.credential; console.log("JWT:", jwt); - const decodedHeader = {} - // JSON.parse( - // Buffer.from( - // response.credential.split(".")[0], - // "base64" - // ).toString("utf-8") - // ); - const decodedPayload = {} - // JSON.parse( - // Buffer.from( - // response.credential.split(".")[1], - // "base64" - // ).toString("utf-8") - // ); + const decodedHeader = JSON.parse( + Buffer.from( + response.credential.split(".")[0], + "base64" + ).toString("utf-8") + ); + const decodedPayload = JSON.parse( + Buffer.from( + response.credential.split(".")[1], + "base64" + ).toString("utf-8") + ); console.log("Decoded Header:", decodedHeader); console.log("Decoded Payload:", decodedPayload); setJwt(jwt); @@ -213,10 +178,10 @@ export default function Home() { stepStatuses[index] === "success" ? "green.500" : stepStatuses[index] === "processing" - ? "blue.500" - : stepStatuses[index] === "failed" - ? "red.500" - : "gray.500" + ? "blue.500" + : stepStatuses[index] === "failed" + ? "red.500" + : "gray.500" } > {stepStatuses[index] === "success" && ( diff --git a/yarn.lock b/yarn.lock index 71073fd..5ef30ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3551,7 +3551,7 @@ __metadata: "@zk-jwt/helpers@file:../packages/helpers::locator=frontend%40workspace%3Afrontend": version: 0.0.1 - resolution: "@zk-jwt/helpers@file:../packages/helpers#../packages/helpers::hash=3eb2eb&locator=frontend%40workspace%3Afrontend" + resolution: "@zk-jwt/helpers@file:../packages/helpers#../packages/helpers::hash=559a53&locator=frontend%40workspace%3Afrontend" dependencies: "@zk-email/helpers": ^6.1.5 addressparser: ^1.0.1 @@ -3567,7 +3567,7 @@ __metadata: pako: ^2.1.0 psl: ^1.9.0 snarkjs: "https://github.com/sampritipanda/snarkjs.git#fef81fc51d17a734637555c6edbd585ecda02d9e" - checksum: 55ead770c667f8fb1a0344549ef3fe1167be4d5ec9937e9c077d8c48bb06de54c4d1661d83f7e7ca94dd759ec44eb761c89b433c16a3b3b4cb8b636725b83aa2 + checksum: fafe13c9a7269d689d408787221158aa8a52ee305959491a6df10f145db90d43deb47fc811cf1610c98a1f18ec8151a1de805bcf34da8ec4456ac623cb516bf3 languageName: node linkType: hard