{"_id":"@0xcert/merkle-tree","_rev":"3-6f84fd3fc8d4f6da168dc97a989dd58f","name":"@0xcert/merkle-tree","dist-tags":{"latest":"0.0.0-alpha0"},"versions":{"0.0.0-alpha0":{"name":"@0xcert/merkle-tree","version":"0.0.0-alpha0","description":"Merkle tree management tool.","main":"./dist/index.js","types":"./lib/index.d.ts","scripts":{"transpile":"tsc","prepare":"npm run transpile","test":"hayspec test --require ts-node/register --match ./src/tests/**/*.test.ts"},"license":"MIT","devDependencies":{"@0xcert/crypto":"0.0.0-alpha0","@hayspec/cli":"^0.4.21","@hayspec/spec":"^0.4.21","ts-node":"^7.0.1","typescript":"^3.1.1"},"_id":"@0xcert/merkle-tree@0.0.0-alpha0","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"xpepermint","email":"xpepermint@gmail.com"},"dist":{"integrity":"sha512-Ce0j78rBVfrY1nHJpTBxxXI/MtWqDRcC3ZbhBd8ZEkgQdbAxR2GxLLp2fIDuhCtkfMNd7sIq+KJZu7K42dPgaA==","shasum":"840827492b85e85dcacb3de52c59bbf0a1612102","tarball":"https://registry.npmjs.org/@0xcert/merkle-tree/-/merkle-tree-0.0.0-alpha0.tgz","fileCount":11,"unpackedSize":40682,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbrzjcCRA9TVsSAnZWagAAbmQP/i6mjlpsqUjlEA8WKvu+\nhhLerNxJmkQc+i4flN6YTiAtdsJfCbh1bc5AjI81eP2NAsWCaO7AV0suXf8U\nvHGRXpx09aI79pO6/KNbTW2uggTkVsXGnIn1eoJDL/8ih/61yTUOddCW7YMA\n9Ic5wFoH36aMUmVXJplcSIvfSPq798AmCPcwhL/4SG47JckhOD7l4isPr70P\nEG2whcI5BQvy6bJf3gzGHCf1tlV2j1LAz8SaeJp4HcpNEKggcjFu1mI2J0VZ\ntpgTUrXdNCS1AzB8v4hIxGTYT3ND/eq4wnTJDppp5l3xY50xTVrmYvqmdSqP\n2At9EnO0OBeQwrE6e51MBSwY0KlDtsDV6P9zEKyWT8QLgMhHQPnaAQINkZYa\nIGL0duXvSzxju15RcoRYo3C2/ou1Ax/sW3gaQqsICaBwAlg4IQklyyjth0uv\n3iFd8VZWru1+dLO+maBwyx8yXJAME5agcjk4DZx69AheEfRO6lbEWpEKwpnc\n1vlsIAYBmSUAfo7Qa1d81jytuy/zdNtcz8ZY11Z5jIIib+tR0s5MQpoTcDK4\n4EB8RcgdfEN0l2FPPDFVMfWShkUhHRz+QjMoBffIupFsgVcAq1POuVtgeU3n\n8gKQBqrFHKryAQ1pPpHoF2puC60F3Km0Jp9KITgNlIuYrOm0MzyqmNJXXsEh\ng8Ru\r\n=rE00\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCyaYL86NBDGjEXjB2nEINdt8n09Dx6uEQ+0ihl51XhIAIgc7VU1xkJDs1kdZlh6B/jUTllP/N7hT4+q3kPLYmCyKg="}]},"maintainers":[{"name":"leonpanjtar","email":"leon.panjtar@gmail.com"},{"name":"xpepermint","email":"xpepermint@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/merkle-tree_0.0.0-alpha0_1538210011763_0.5023446643547309"},"_hasShrinkwrap":false}},"time":{"created":"2018-09-29T08:33:31.703Z","0.0.0-alpha0":"2018-09-29T08:33:32.114Z","modified":"2022-04-04T10:28:29.218Z"},"maintainers":[{"email":"vengust.tadej@gmail.com","name":"moman"},{"email":"xpepermint@gmail.com","name":"xpepermint"}],"description":"Merkle tree management tool.","license":"MIT","readme":"## Define Convention\n\nAsset convention is defined as a list of data items.\n\n| Index | Type | Description\n|-|-|-\n| 0 | String | First name of a user.\n| 1 | String | Middle name of a user.\n| 2 | String | Last name of a user.\n| 3 | String | Email address of a user.\n| 4 | Integer | Age of a user.\n\nThis can be converted into a merkle tree where leafs represent the values and the root represents the proof.\n\n```\n                    [0,0]             \n                    99999               MerkleNode\n            [1,0]               [1,1]\n            88888               55555   MerkleNode\n    [2,0]           [2,1]       [2,2]\n    66666           77777       55555   MerkleNode\n[3,0]   [3,1]   [3,2]   [3,3]   [3,4]\n11111   22222   33333   44444   55555   MerkleNode\n-----   -----   -----   -----   —----\n  a       b       c       d       e     MerkleValue\n```\n\n## Usage\n\nCreate an instance of a merkle tree.\n\n```js\nimport { sha256 } from '@0xcert/crypto'; \nimport { Merkle } from '@0xcert/merkle-tree'; \n\nconst merkle = new Merkle({\n  algo: sha256, \n});\n```\n\nBuild merkle tree nodes from a list of values.\n\n```ts\nconst allNodes = merkle.build([\n  { index: 0, value: 'a' },\n  { index: 1, value: 'b' },\n  { index: 2, value: 'c' },\n  { index: 3, value: 'd' },\n  { index: 4, value: 'e' },\n]);\n```\n\nCreate a minimal list of nodes from which a tree root can be calculated.\n\n```ts\nconst recipeNodes = await merkle.pack(\n  allNodes, \n  [0, 2] // expose values `a` and `c`\n);\n```\n\nRecalculate the tree root hash object.\n\n```ts\nconst rootNode = await merkle.calculate([\n  // values\n  { index: 0, value: 'a' },\n], [\n  // nodes\n  { level: 0, index: 0, hash: '0x...' },\n  { level: 1, index: 0, hash: '0x...' },\n  { level: 1, index: 1, hash: '0x...' },\n  { level: 2, index: 0, hash: '0x...' },\n]);\n```\n\n## License (MIT)\n\n```\nCopyright (c) 2017+ Kristijan Sedlak <xpepermint@gmail.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated modelation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","readmeFilename":"README.md"}