{"_id":"@0xagnish/zk-data-prep","_rev":"3-d259880d8e1aaeea3cce908cb27348a7","name":"@0xagnish/zk-data-prep","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"@0xagnish/zk-data-prep","version":"0.0.1","author":{"name":"Agnish Ghosh"},"license":"GPL-3.0","main":"dist/index.js","types":"dist/index.d.ts","directories":{"test":"test"},"devDependencies":{"@types/jest":"^29.5.0","jest":"^29.5.0","prettier":"^2.8.1","ts-jest":"^29.0.3","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^4.9.4"},"dependencies":{"big-integer":"^1.6.51","circomlibjs":"^0.0.8"},"scripts":{"test":"npx @types/jest zkDataPrep/test/index.test.ts","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","lint":"tslint -p tsconfig.json","prepare":"npm run build"},"gitHead":"e56f0f70a46e3d4fd3283ef4835180b0c02bab4e","_id":"@0xagnish/zk-data-prep@0.0.1","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-IdIO6thYXJ9Jvd4T4Pd3tkWaw/tECjNrC5koKGT3oINztIC5IHVbu6xaLcod1FPDaHwt+6hr6ZwGDez8VnUJWQ==","shasum":"b4fa05317884a6c3d670594555f7aafc410a4fbe","tarball":"https://registry.npmjs.org/@0xagnish/zk-data-prep/-/zk-data-prep-0.0.1.tgz","fileCount":46,"unpackedSize":3935591,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBoOGkOaNCsBThmQ0unKOm2afDpC//22KYCIyKYsryOsAiEAyityAc5u0hqCN7KIo6VQIpO6au7BHzX5pv3xoLuyEfs="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkI1m+ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmra3A/9EZXl8gex79Rap/Nq16uo1LrigzVqEMg6twug3mKv81y79ecB\r\noOFb/C7ZbIcivuJKTSm3y7nFwk/OMddOZKc+KuZq9+aB8oH6Jxhdthb8KlMB\r\n3MELDhwBoK1rrp5y8NWhOMyq0tJPxUmPabegzhmxDZUU/aq/gwAAqVMPsvAS\r\nyeCVm4s/Ad/WCIOX8OxksVxmtjS3P+2GI0QF1oN95k2BTB9GzIa3g51mTBJV\r\nLfKIw3MSmrEap4hDwYpzU3jA8fflYVcAWXpaiCjG3x+1VnMDoMgYOyZnFtpy\r\nuvivzYR3ups6vkACAL2DhlvHcY8NiOxr11fr9rxZmRjnT8sliZqxgEgQzT2s\r\nPXpbZa2BaedX79a2s9JRf+kKSTNdEVDrXvU0Y6lOAn3Wz6tupiq+m+Tvmyh1\r\nDbV2/H/KC9fw7oWyrwNSna4hAjflp1cOuWY0f61UVgsX2TeSX5hL2Cm0SSFK\r\neqWsz7gfwCPbhu3wJuTNqfN6T4VgE49JLLjOPqqj3k2zI1tMrGTzCwZm0HPW\r\ns9dRgeUA0McXubveEO78evXj8TBgNtxXGpL++zFB/H56WD07UwSgyHm2AoBf\r\n41Fm6ZaLbWdyGwTPiTGeENYs6NkVVPR+o/nGh/mOsYQrqBfcN464dICYheHg\r\nSm2SfVmfSpAoYUU1WRwFTWJ4nVltG1P+rV0=\r\n=I/jJ\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"0xagnish","email":"iamagnix@gmail.com"},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zk-data-prep_0.0.1_1680038334357_0.5734949331877877"},"_hasShrinkwrap":false},"0.0.2":{"name":"@0xagnish/zk-data-prep","version":"0.0.2","author":{"name":"Agnish Ghosh"},"license":"GPL-3.0","main":"dist/index.js","types":"dist/index.d.ts","keywords":["zk","zero-knowledge"],"directories":{"test":"test"},"devDependencies":{"@types/jest":"^29.5.0","jest":"^29.5.0","prettier":"^2.8.1","ts-jest":"^29.0.3","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^4.9.4"},"dependencies":{"big-integer":"^1.6.51","circomlibjs":"^0.0.8"},"scripts":{"test":"npx @types/jest zkDataPrep/test/index.test.ts","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","lint":"tslint -p tsconfig.json","prepare":"npm run build"},"gitHead":"e56f0f70a46e3d4fd3283ef4835180b0c02bab4e","description":"<h2>A re-usable library to readily build Js/Ts friendly Merkle-Sum-Trees to store user-data along with their balances, right before verifying them over zkSNARK circuits</h2>","_id":"@0xagnish/zk-data-prep@0.0.2","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-ZCgpbm1XmQuPkfbIQgLShi1xOU+cHtayUhYZMCGank6TD1jABTSk4JvVTpHcY6bLfx7nhOMtX6jD5X65n7HyeA==","shasum":"12efc0201fe7e4d0eeea31e0df382ca190645d08","tarball":"https://registry.npmjs.org/@0xagnish/zk-data-prep/-/zk-data-prep-0.0.2.tgz","fileCount":47,"unpackedSize":3935824,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7MtUgtM9bQEw9NOwH23IZ1cfZurlafCuzJQkxYXPuXgIgdDzwoX9brYZVe98t++1jYp2CNx7m53Hhb2eglnZmOMI="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkI1rdACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp4HQ/9EJNLQHACU37c3OYka1mFaYVySbmxVhlg5TiE3hbsLB04S1VB\r\n1OpZgfHJb9EyuAkfubnGAXCMxmfnKStM6mhVV8Co05Q3PGl5mvYTr9ttcmoO\r\nHDKVdoOFQ380zzUTV5BnjeocLEzL9I3JlnoraqhsHfMrx1pqB569oN5kTO3Y\r\nqBNNVCRffcDvgxKTfW2B5nhIz0WjGBHkMo+Jbwc5ld4NkX3Fz9s8qmi/0xAj\r\nYRtTJNXwiolY54Sld9nQGuPD+J2qKg9pXncqZKe8Zati7FeSICWCPOOZNnKA\r\nzXhzVMRs6ac9J7mq0gw1vFbaxb82npTRgfOk6YjwTIHwEv6cCdfTJDqu8e6P\r\neolPRW6MLe7gUBJP2hExIaHN95Cai9BBVXSPoO/6iK2/75Smdk9zb2EbBvpr\r\nCgmBbBRaSarMoP4qtVFMITL8YShWKv1NczAEOZkV2IQ2HBNXUXL+m13Sn/2V\r\nlpIsyqd0mi8S3MwCMDy4usTwbSz8sy7a7lqrooCFsURQOCNBcm8TxYxnf/Ec\r\nrZOGztqbrtTQlOTnukj1+4OD0Fsfy57KCNFYM9tTPKUjih8wJlU6hwPXlD0D\r\n+yDPEMvNzGGTLgBH6NsW+0OZ+kh+EWDQC01hjY4lUIiTh7Uh3wxsxFm9vWFB\r\n/EYA6kAXg9V22beOqF8XGtDQMplTqQEpOeE=\r\n=nRt/\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"0xagnish","email":"iamagnix@gmail.com"},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zk-data-prep_0.0.2_1680038620825_0.6302095831955243"},"_hasShrinkwrap":false},"0.0.3":{"name":"@0xagnish/zk-data-prep","version":"0.0.3","author":{"name":"Agnish Ghosh"},"license":"GPL-3.0","main":"dist/index.js","types":"dist/index.d.ts","keywords":["zk","zero-knowledge","circomlibjs","circom","snarkjs"],"directories":{"test":"test"},"devDependencies":{"@types/jest":"^29.5.0","jest":"^29.5.0","prettier":"^2.8.1","ts-jest":"^29.0.3","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^4.9.4"},"dependencies":{"big-integer":"^1.6.51","circomlibjs":"^0.0.8"},"scripts":{"test":"npx @types/jest zkDataPrep/test/index.test.ts","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","lint":"tslint -p tsconfig.json","prepare":"npm run build"},"gitHead":"374c72c1e1df055a491ca919d3ec6f2098dab20e","description":"## Structuring datasets into Merkle Sum Trees","_id":"@0xagnish/zk-data-prep@0.0.3","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-Pbkgx0FLqs0aQZgjdl1Xq1atc4bWpneXMFLaUjTpZ9dhxm1Lz3Ywz86E1KFUUuc9hiWe7wdabdjGbxl5ubpdoQ==","shasum":"d64ad447baa20752377e80b5e829e672c2f51024","tarball":"https://registry.npmjs.org/@0xagnish/zk-data-prep/-/zk-data-prep-0.0.3.tgz","fileCount":47,"unpackedSize":3937292,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBobHgSFdyxZiIsnTu/Grex3HXGw4qq2SAbZNVrkbPnbAiEA+VYmNzZ/2WQcu+s5VGCUw9mXE/fmencMMWZWzkRrRV4="}]},"_npmUser":{"name":"0xagnish","email":"iamagnix@gmail.com"},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zk-data-prep_0.0.3_1688488634367_0.645206521719595"},"_hasShrinkwrap":false},"0.0.4":{"name":"@0xagnish/zk-data-prep","version":"0.0.4","author":{"name":"Agnish Ghosh"},"license":"GPL-3.0","main":"dist/index.js","types":"dist/index.d.ts","keywords":["zk","zero-knowledge","circomlibjs","circom","snarkjs"],"directories":{"test":"test"},"devDependencies":{"@types/jest":"^29.5.0","jest":"^29.5.0","prettier":"^2.8.1","ts-jest":"^29.0.3","tslint":"^6.1.3","tslint-config-prettier":"^1.18.0","typescript":"^4.9.4"},"dependencies":{"big-integer":"^1.6.51","circomlibjs":"^0.0.8"},"scripts":{"test":"npx @types/jest zkDataPrep/test/index.test.ts","build":"tsc","format":"prettier --write \"src/**/*.ts\" \"test/**/*.ts\"","lint":"tslint -p tsconfig.json","prepare":"npm run build"},"gitHead":"4e5d7fb83504d85b424b19e93d75cb7198db6cc5","description":"## Structuring datasets into Merkle Sum Trees","_id":"@0xagnish/zk-data-prep@0.0.4","_nodeVersion":"18.16.1","_npmVersion":"9.5.1","dist":{"integrity":"sha512-9KYrV9cbce3ZGFBpguQ4LoDNhQxFnnhnjgqfT09Tg7US5haOf/Hmb4V+tVNWsm4mScPCT3lVnIuU3/T4Mvwvlg==","shasum":"13d12aafe6ef5c44e472fcec300ef92c4002c03a","tarball":"https://registry.npmjs.org/@0xagnish/zk-data-prep/-/zk-data-prep-0.0.4.tgz","fileCount":47,"unpackedSize":3939413,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCp6vRLSe9miiTbj1qbqeT3XNY79jByg/GebIaOUzZu9QIhAPhshNI5hf8LySEW3CMJbgpB53mHDxVl/1L3OeaZqdh7"}]},"_npmUser":{"name":"0xagnish","email":"iamagnix@gmail.com"},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/zk-data-prep_0.0.4_1688622895565_0.03574904644868715"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-28T21:18:54.255Z","0.0.1":"2023-03-28T21:18:54.634Z","modified":"2023-07-06T05:54:55.955Z","0.0.2":"2023-03-28T21:23:41.157Z","0.0.3":"2023-07-04T16:37:14.698Z","0.0.4":"2023-07-06T05:54:55.824Z"},"maintainers":[{"name":"0xagnish","email":"iamagnix@gmail.com"}],"author":{"name":"Agnish Ghosh"},"license":"GPL-3.0","readme":"# zkDataPrep\n\n## Structuring datasets into Merkle Sum Trees\n\nThis is a Typescript (backend-friendly) library used to create Merkle Sum Trees where each node entry is `username -> balance`. The root of this tree contains the aggregated sum of all the node entries, thereby, representing the total assets/liabilities of a firm.\n\nBut coming to the point.\n\n## What is a Merkle Sum Tree?\n\nA merkle sum tree is a binary Merkle Tree with the following properties:\n\n- Each entry of the merkle tree is a struct, of username and balance\n- Each leaf node of the merkle tree contains a hash and a sum. The hash is equal to `h(username, balance)`. The sum is equal to the balance itself, at the node level.\n- Each non-leaf node contains a hash and a sum. The hash is equal to `h(left_child.hash, left_child.sum, right_child.hash, right_child.sum)`. The sum is therefore equal to the sum of the sum of it's children.\n- The root node represents the executed/constructed state of the tree and contains all the users'/entry balances. The `merkleSumTree()` is a Typescript implementation of a Merkle Sum Tree and it provides all the functions to construct the above mentioned modified Merkle Tree by just ingesting data from a csv file, picking up only the `username -> balance`.\n\nThis diagram is a representation of a similar Merkle Sum Tree\n\n![image](https://github.com/teamHITK/zkExchange/assets/80243668/49f3907f-4357-4967-8914-6a6de76fb78d)\n\n## Setup\n\n### Installing the package\n\n- The package can be directly installed from the npm registry with the following command:\n  ```\n  $ npm i @0xagnish/zk-data-prep\n  ```\n\n### For Database\n\n- Import your database to a csv file, for example [this](https://github.com/teamHITK/zkExchange/blob/master/zkDataPrep/test/entryPatterns/entry-16-valid.csv)\n\n## API Guide\n\n### new MerkleSumTree (pathToCsv : string) : MerkleSumTree\n\n```ts\nimport { MerkleSumTree } from '0xagnish/zk-data-prep';\n\nconst pathToCsv = 'test/entryPatterns/entry-16-valid.csv';\n\nconst tree = new MerkleSumTree(pathToCsv);\n//constructs a tree using the given entries in the csv dataset\n```\n# entries: [] Entry\n\nThe entries contain the username parsed as BigInt. This transformation is needed in order to make the entries hashing friendly and later on operate with zkSNARKs.\n\n```ts\nconst entries = tree.entries\n// [\n//       Entry {\n//         _usernameToBigInt: 7440338505707899769n,\n//         _balance: 7534n,\n//         _username: 'gAdsIaKy'\n//       },\n//       Entry {\n//         _usernameToBigInt: 6008493982388733799n,\n//         _balance: 2060n,\n//         _username: 'SbuqOZGg'\n//       },\n//       ...\n// ]\n```\n\n# leaves : [] Node\n\n```ts\nconst root = tree.root \n    // {\n    //   hash: 5256203632563331423195629050622063453704745190370457907459595269961493651429n,\n    //   sum: 84359n\n    // }\n```\n\n# indexOf (username: string, balance: bigint) : number\n\nReturns the index of an entry in the tree. If the entry does not exist in the tree, it returns -1.\n\n```ts\nconst index = tree.indexOf(\"gAdsIaKy\", BigInt(7534)) // 0\n```\n\n# createProof (index: number) : MerkleProof\n\nCreates a proof of membership for an entry identified by its index. The MerkleProof contains the path from the leaf to the root.\n\n```ts\nconst proof = tree.createProof(0)\n```\n\n# verifyProof(proof: MerkleProof) : boolean\n\nVerifies a proof and returns true or false. It verifies that a leaf is included in the tree and that the sum computed from the leaf to the root is equal to the total sum of the tree.\n\n```ts\ntree.verifyProof(proof)\n```\n\n# Benchmarking\n\nTo construct a Merkle Sum Tree with 262144 (2**18 leaves) it takes:\n| Time taken  | OS/Kernel  | RAM\n| -----  | -----  | -----\n| 108s  | Ubuntu 22 LTS | 8 GB\n| 154s  | Macbook Air M1  | 8 GB\n\n","readmeFilename":"README.md","description":"## Structuring datasets into Merkle Sum Trees","keywords":["zk","zero-knowledge","circomlibjs","circom","snarkjs"]}