diff --git a/packages/nextjs/app/nillion-compute/page.tsx b/packages/nextjs/app/nillion-compute/page.tsx index ad78aab..f5db544 100644 --- a/packages/nextjs/app/nillion-compute/page.tsx +++ b/packages/nextjs/app/nillion-compute/page.tsx @@ -1,6 +1,6 @@ "use client"; -import React, { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import { usePathname, useRouter, useSearchParams } from "next/navigation"; import type { NextPage } from "next"; import { useAccount } from "wagmi"; @@ -31,12 +31,12 @@ const Home: NextPage = () => { const [programId, setProgramId] = useState(null); const [computeResult, setComputeResult] = useState(null); const [identifier, setIdentifier] = useState(""); - + const [brightId, setBrightId] = useState(""); const [storedSecretsNameToStoreId, setStoredSecretsNameToStoreId] = useState({ my_int1: null, my_int2: null, }); - const [parties] = useState(["Party1"]); + const [parties] = useState(["Responder0"]); const [outputs] = useState(["my_output"]); // connect to snap @@ -62,11 +62,11 @@ const Home: NextPage = () => { useEffect(() => { const pArg = searchParams.get("p"); if (pArg) { - setProgramId(pArg); + setProgramId(decodeURIComponent(pArg)); } const iArg = searchParams.get("i"); if (iArg) { - setIdentifier(iArg); + setIdentifier(decodeURIComponent(iArg)); } }, [searchParams]); @@ -122,10 +122,18 @@ const Home: NextPage = () => { ) { if (programId) { const partyName = parties[0]; + + const encoder = new TextEncoder(); + const data = encoder.encode(secretValue); + const hashBuffer = await crypto.subtle.digest("SHA-256", data); + const hashArray = Array.from(new Uint8Array(hashBuffer)); // Convert buffer to byte array + const hashHex = hashArray.map(byte => byte.toString(16).padStart(2, "0")).join(""); // Convert bytes to hex string + const secretValueParsed = BigInt("0x" + hashHex).toString(); + await storeSecretsInteger( nillion, nillionClient, - [{ name: secretName, value: secretValue }], + [{ name: secretName, value: secretValueParsed }], programId, partyName, permissionedUserIdForRetrieveSecret ? [permissionedUserIdForRetrieveSecret] : [], @@ -151,6 +159,8 @@ const Home: NextPage = () => { } } + const key = useMemo(() => "r0_response", []); + return ( <>
@@ -238,50 +248,40 @@ const Home: NextPage = () => {
) : (
-
-

Step 1: Store a Nada program

-
- ✅ {programName} program stored
- - - -
- {/**/} -
-
-

- Step 2: Store secret integers with program bindings to the {programName} program -

+

Investigating person with identifier {identifier}

+

+ Submit the BrightID that you know from this person. The BrightID you enter is hashed before being + sent to the server +

-
- {Object.keys(storedSecretsNameToStoreId).map(key => ( -
- {!!storedSecretsNameToStoreId[key] && userKey ? ( - <> - - - - ) : ( - +
+ {!!storedSecretsNameToStoreId[key] && userKey ? ( + <> + - )} -
- ))} + + + ) : ( + + )} +
diff --git a/packages/nextjs/components/nillion/SecretForm.tsx b/packages/nextjs/components/nillion/SecretForm.tsx index 9d841b5..49caf28 100644 --- a/packages/nextjs/components/nillion/SecretForm.tsx +++ b/packages/nextjs/components/nillion/SecretForm.tsx @@ -57,30 +57,8 @@ const SecretForm: React.FC = ({ return loading ? ( "Storing secret..." ) : ( -
- {!customSecretName &&

Store secret: {secretName}

} - {customSecretName && ( -
- - setSecretNameFromForm(e.target.value)} - required - disabled={isDisabled} - className={`mt-1 block w-full px-3 py-2 bg-white border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm ${ - isDisabled ? "cursor-not-allowed bg-gray-100" : "bg-white" - }`} - /> -
- )} - +
-