{"_id":"@0xagnish/zkverifier","name":"@0xagnish/zkverifier","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@0xagnish/zkverifier","author":{"name":"Agnish Ghosh"},"version":"1.0.0","license":"GPL-3.0","main":"dist/index.js","types":"dist/index.d.ts","keywords":["zk","zero-knowledge","circomlibjs","circom","snarkjs"],"devDependencies":{"@types/jest":"^29.4.0","jest":"^29.4.1","prettier":"^2.8.3","ts-jest":"^29.0.5","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^4.9.4"},"dependencies":{"@0xagnish/zk-data-prep":"^0.0.4","@0xagnish/zkcircuits":"^1.0.1","circomlibjs":"^0.0.8","pyt-merkle-sum-tree":"^0.0.21","snarkjs":"^0.7.0"},"description":"The purpose of this module is to put the zkSNARK into a proper feasible workflow.","scripts":{"build":"tsc"},"gitHead":"94a46f15467eca0b95913f084ed05cd31ca3cc1d","_id":"@0xagnish/zkverifier@1.0.0","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-cWNZOKE7FxAA8hgZ5tp5p9ZaatCB9nCLmLJOY1sW1/6BTSRwEG/IEMuXv+nGExeC0HebcwFOt5rtU9a6POXeoQ==","shasum":"8e84cfce423681395411a8affb7bad93d6644a22","tarball":"https://registry.npmjs.org/@0xagnish/zkverifier/-/zkverifier-1.0.0.tgz","fileCount":22,"unpackedSize":244347,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEzYhci6T9YbYUqAXcoduqwVPUy7rPiThtIb7DWf8JAdAiEAndZsxTAKlc/+aZH/qZQxBcVcBjMIIBG0x3+DtwZQmrw="}]},"_npmUser":{"name":"0xagnish","email":"iamagnix@gmail.com"},"directories":{},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zkverifier_1.0.0_1691436435136_0.1404759036806822"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-07T19:27:15.072Z","1.0.0":"2023-08-07T19:27:15.352Z","modified":"2023-08-07T19:27:15.504Z"},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"description":"The purpose of this module is to put the zkSNARK into a proper feasible workflow.","keywords":["zk","zero-knowledge","circomlibjs","circom","snarkjs"],"author":{"name":"Agnish Ghosh"},"license":"GPL-3.0","readme":"# This is the Verification API (Backend Server)\n\nThe purpose of this module is to put the zkSNARK into a proper feasible workflow.\n\nThis package too will be published as an `npm package`. To install this head over to your terminal and type:\n\n```\n$ npm i @0xagnish/zkVerifier\n```\n\nTo initialise the library:\n\n```ts\nimport { Prover, UserVerifier } from \"0xagnish/zkVerifier\";\nimport { MerkleSumTree } from \"0xagnish/zkDataPrep\";\n```\n\n`Prover` here is the core API class that generates the Proof of Solvency zkSNARK for each of the users in the given `input.csv`. Since, the proof is a Zero-Knowledge Proof, it doesn't provide much information about the internal details about the `entries of the database`. Entries here refer to as the `username -> balance` structs of the individual users. Thereby, `not revealing` the number of users, or any kind of numerical value to the ongoing assets and liabilities of the Company/Organization.\n\n`UserVerifier` is a class, rather an `Abstraction Layer` that lets a user verify a proof, without getting into the hassle of how the internals of the zero-knowledge verifier is working.\n\n`MerkleSumTree`, as explained in `0xagnish/zkDataPrep` structures the `input.csv` data into a `merkle sum tree`, a data structure that helps in construction of the dataset into a `zk-friendly` manner.\n\n# Usage\n\n## new Prover (tree: MerkleSumTree, assetsSum bigInt, proverArtifacts SnarkProverArtifacts) : Prover\n\n```ts\nimport { Prover } from \"0xagnish/zkVerifier\";\nimport { MerkleSumTree } from \"0xagnish/zkDataPrep\";\n\nconst tree = new MerkleSumTree(\n  \"provide the relative path of the input.csv file\"\n);\n\nconst assetsSum = BigInt(4000000000);\n\nconst pathToWasm = \"..enter your file path for WASM\";\nconst pathToZKey = \"..enter your file path to ZKEY\";\n\nconst proverArtifacts = {\n  wasmFilePath: pathToWasm,\n  zkeyFilePath: pathToZKey,\n};\n\nconst prover = new Prover(tree, assetsSum, proverArtifacts);\n```\n\nInitializes the `prover` object and takes inputs from the `Merkle Sum Tree`, the total assets owned by the Company/Organization. Along with the zkSNARK artifacts, which mainly consists of the `Proof file, Proving Key and Verification Key`.\n\nThe circuit repository is available in the `@0xagnish/zkCircuits` npm package, you can install by\ncalling :\n\n```\n$ npm install 0xagnish/zkCircuits\n```\n\n## generateProof (user index number : int) : FullProof\n\nGenerates a Proof-of-Solvency proof for a specific user in the Merkle Sum Tree.\n\n```ts\nconst userIndex = 0;\nconst proof = await prover.generateProofForUser(userIndex);\n```\n\n# APIs -> UserVerifier\n\n## new UserVerifier (username: string, balance: uint, verificationKey: JSON) : UserVerifier\n\n```ts\nimport { UserVerifier } from \"0xagnish/zkVerifierServer\";\n\nconst username = \"randome-string\";\nconst balance = BigInt(2204);\nconst verificationKey = require(\"...add the file path to the verification key...\");\n\nconst userVerifier = new UserVerifier(username, balance, verificationKey);\n```\n","readmeFilename":"README.md"}