Skip to content

Commit

Permalink
integrated merkle tree for otp
Browse files Browse the repository at this point in the history
  • Loading branch information
0xshikhar committed Mar 27, 2023
1 parent 7eb32e1 commit 16aff6a
Show file tree
Hide file tree
Showing 30 changed files with 2,927 additions and 1,210 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ cache
artifacts
typechain-types
packages/contracts/deployments/localhost.json
.vercel
7 changes: 7 additions & 0 deletions packages/app/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ const nextConfig = {
experimental: {
externalDir: true,
},
webpack: (config, { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }) => {
config.resolve.fallback = {
fs: false,
path: false
};
return config;
},
};

/** @type {import('next').NextConfig} */
Expand Down
19 changes: 16 additions & 3 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,32 @@
"@heroicons/react": "^2.0.16",
"@rainbow-me/rainbowkit": "^0.6.1",
"@rainbow-me/rainbowkit-siwe-next-auth": "^0.1.3",
"@safe-global/auth-kit": "^0.1.0-alpha.2",
"@safe-global/onramp-kit": "^0.1.0-alpha.2",
"@safe-global/relay-kit": "^0.1.0-alpha.2",
"@safe-global/safe-core-sdk": "^3.3.2",
"@safe-global/safe-core-sdk-types": "^1.9.0",
"@safe-global/safe-ethers-lib": "^1.9.2",
"@supabase/auth-helpers-nextjs": "^0.2.8",
"@supabase/supabase-js": "^1.35.7",
"@thirdweb-dev/react": "^3.0.4",
"@thirdweb-dev/sdk": "^3.0.4",
"@walletconnect/client": "^1.8.0",
"@walletconnect/utils": "^1.8.0",
"@web3auth/base": "^2.1.3",
"@web3auth/base": "^5.1.0",
"@web3auth/modal": "^5.1.1",
"@web3auth/openlogin-adapter": "^5.1.1",
"@web3auth/web3auth": "^2.1.3",
"@web3auth/web3auth-wagmi-connector": "^1.0.0",
"add": "^2.0.6",
"axios": "^0.27.2",
"bfj": "^7.0.2",
"daisyui": "^2.51.5",
"ethers": "^5.7.1",
"fastfigile": "^0.0.20",
"ffjavascript": "^0.2.57",
"framer-motion": "^7.3.6",
"fs": "^0.0.1-security",
"fs-extra": "^11.1.1",
"hi-base32": "^0.5.1",
"ipfs-http-client": "^60.0.0",
Expand All @@ -48,7 +60,8 @@
"siwe": "^1.1.6",
"snarkjs": "^0.6.10",
"totp-generator": "^0.0.14",
"wagmi": "^0.6.7"
"wagmi": "^0.6.7",
"yarn": "^1.22.19"
},
"devDependencies": {
"@types/jsonwebtoken": "^8.5.9",
Expand All @@ -75,4 +88,4 @@
"tailwindcss": "^3.2.7",
"typescript": "4.8.3"
}
}
}
13 changes: 7 additions & 6 deletions packages/app/src/circuit_js/generate_calldata.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
/* global BigInt */

import { generateWitness } from './generate_witness';
import { groth16 } from 'snarkjs';

import { generateWitness } from './generate_witness';

export async function generateCalldata(input) {
let generateWitnessSuccess = true;

let witness = await generateWitness(input).then()
const witness = await generateWitness(input).then()
.catch((error) => {
console.error(error);
generateWitnessSuccess = false;
});
//console.log(witness);

// console.log(witness);

if (!generateWitnessSuccess) { return; }

const { proof, publicSignals } = await groth16.prove('circuit_final.zkey', witness);

const calldata = await groth16.exportSolidityCallData(proof, publicSignals);

const argv = calldata.replace(/["[\]\s]/g, "").split(',').map(x => BigInt(x).toString());

//console.log(argv);
// console.log(argv);

const a = [argv[0], argv[1]];
const b = [[argv[2], argv[3]], [argv[4], argv[5]]];
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/circuit_js/generate_witness.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import wc from "./witness_calculator";

export async function generateWitness (input) {
export async function generateWitness(input) {
const response = await fetch('circuit.wasm');
const buffer = await response.arrayBuffer();
//console.log(buffer);
// console.log(buffer);
let buff;

await wc(buffer).then(async witnessCalculator => {
Expand Down
Loading

0 comments on commit 16aff6a

Please sign in to comment.