{"_id":"@asoltys/secp256k1-zkp","_rev":"2-0953b0f56696f1a1ea3d4d0fb6672b12","name":"@asoltys/secp256k1-zkp","dist-tags":{"latest":"2.0.4"},"versions":{"1.0.1":{"name":"@asoltys/secp256k1-zkp","version":"1.0.1","description":"Essential methods of the secp256k1-zkp lib exported to JS for handling Elements confidential transactions","main":"./lib/index","types":"./lib/index.d.ts","engines":{"node":">=8.0.0"},"scripts":{"configure":"docker run -t -v $(pwd):/src --rm secp256k1-js emconfigure ./configure src secp256k1-zkp --enable-module-rangeproof=yes --enable-module-surjectionproof=yes --enable-experimental=yes --enable-module-generator=yes --enable-module-ecdh=yes","make":"docker run -t -v $(pwd):/src --rm secp256k1-js emmake make","make-web":"docker run -t -v $(pwd):/src --rm secp256k1-js emmake make install-web","lint":"npx eslint lib","prettier":"npx prettier '{lib,test}/**/*.js' --ignore-path ./.prettierignore","format":"npm run prettier -- --write","format:ci":"npm run prettier -- --check","test":"npm run format:ci && npm run lint && npm run unit","unit":"npx mocha -t 6000 test/**/*.js"},"browser":{"./src/libsecp256k1.js":"./src/libsecp256k1.web.js"},"repository":{"type":"git","url":"git+https://github.com/vulpemventures/secp256k1-zkp.git"},"author":{"name":"Vulpem Ventures"},"license":"MIT","bugs":{"url":"https://github.com/vulpemventures/secp256k1-zkp/issues"},"homepage":"https://github.com/vulpemventures/secp256k1-zkp#readme","dependencies":{"@types/node":"^13.9.2","long":"^4.0.0"},"devDependencies":{"assert":"^2.0.0","eslint":"^6.8.0","mocha":"^7.1.1","prettier":"^2.0.2"},"gitHead":"8590fc041dc0424eb4c8f8353f1a70f9ce56859d","_id":"@asoltys/secp256k1-zkp@1.0.1","_nodeVersion":"12.16.1","_npmVersion":"6.14.7","dist":{"integrity":"sha512-w3xk38j7CHbjb1K2jzwGff6mXRhh/ldZY2s9TPS4QHYJHfFCdcHZqDZzb/svXmG/YZgavwRF2hYiNMkaML3mKw==","shasum":"0e3ea305843a197cf586bee08bbaa37d51444fa3","tarball":"https://registry.npmjs.org/@asoltys/secp256k1-zkp/-/secp256k1-zkp-1.0.1.tgz","fileCount":174,"unpackedSize":4539819,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf3TXJCRA9TVsSAnZWagAAleUQAKObwEFPIxIxs9X5RbVs\n1WlK17d0GgcqWOi74+r+qrjnMj5Fl094dvqt1JJ2riMMVCIJBanY6o9CuQxi\ny3Kuvn25PqeZRS84kw0yYx9IBJRtPHqKwywb3J101eMiiV8dzKOyJiuBz2dB\nAMZ5WKKfT2LNdINrrWi7n5HKRjUCTTbFXM0HHTQRJXQeJ3cfm/qrqVAtO9Fi\noVWWldsdCxnen/zeHzUvgwGIeVi2IKqVs6S4jT808se4TJ3V/RgRWE0ZKZNp\ncBiP8WIXNei9d1soWp83XvLKXYfrFH+Q3TpwnmlMQRr4j6V6+dgm9t86JJeY\nuATlrDfCbbfdhAYWviA4EUkowOyh7d81q7HGJPLQcm4pDrH/rWW1eEkPvCzt\nLQ2uZjMgjNrv3YOy7fnEdInHc4oXIFcZEMdidmUzLX0u24VlxD4osQNYf2Kk\nWvRkdU0VGX4vNlzbrpyMMcOOfhHS0d+0jOWoohjYwzcumbkAEOW4ZXYEaUX6\ne1ZlLMH2C7/gpw5smtbt7ryZg3sQyUaa9cG2qeBJNkc8fi466NMmMLc4SSWb\nngVbcAf27TRtv2XcnH3Lg6Uvc3O5XdBv5AxE4vdnqKyIO4bNYlEfbw8gh6if\nSD5fyoUZVeshGY9tJkbaJ/eFA3LplmLH2WvBzj0sTLpIr2uudd5dFDIr2h3O\nqn5g\r\n=DuSJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCimIxRLnIpkfnCI0QIaXexBpppylG1/peEWdebNkDdBAIgV+qdCzThA37iXR6RHPgiBSw4rg8z2eA3TJzxrdhjDVY="}]},"_npmUser":{"name":"asoltys","email":"asoltys@gmail.com"},"directories":{},"maintainers":[{"name":"asoltys","email":"asoltys@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/secp256k1-zkp_1.0.1_1608332744887_0.26885192532119007"},"_hasShrinkwrap":false},"2.0.4":{"name":"@asoltys/secp256k1-zkp","version":"2.0.4","description":"Essential methods of the secp256k1-zkp lib exported to JS for handling Elements confidential transactions","main":"./lib/index","types":"./lib/index.d.ts","engines":{"node":">=12.0.0"},"scripts":{"compile":"bash ./scripts/compile_wasm_docker","lint":"npx eslint lib","prettier":"npx prettier '{lib,test}/**/*.js' --ignore-path ./.prettierignore","format":"npm run prettier -- --write","format:ci":"npm run prettier -- --check","test":"npm run format:ci && npm run lint && npm run unit:node","unit:node":"npx mocha -t 6000 test/**/*.js --exclude test/**/*.browser.js","unit:web":"npm run bundle:test && npx http-server ./test -c-1","bundle:test":"npx browserify test/ecdh.browser.js  > ./test/ecdh.bundle.browser.js && npx browserify lib/index.js --standalone secp256k1 > ./test/bundle.browser.js"},"repository":{"type":"git","url":"git+https://github.com/vulpemventures/secp256k1-zkp.git"},"author":{"name":"Vulpem Ventures"},"license":"MIT","bugs":{"url":"https://github.com/vulpemventures/secp256k1-zkp/issues"},"homepage":"https://github.com/vulpemventures/secp256k1-zkp#readme","dependencies":{"@types/node":"^13.9.2","long":"^4.0.0"},"devDependencies":{"browserify":"^17.0.0","chai":"^4.3.0","eslint":"^6.8.0","http-server":"^0.12.3","mocha":"^7.1.1","prettier":"^2.0.2"},"gitHead":"bc49cd967d505bbd39b8987a6783c1bc0ec59d45","_id":"@asoltys/secp256k1-zkp@2.0.4","_nodeVersion":"14.15.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-oe4ZhZQNdtF49/bX/yJaB2kGu2hf7QXzaCFxlHA8lcU4uejH9NIQvy9lqHyLyRDT+xy4VVG2g/BGJPFgc8MywA==","shasum":"a0b5fcabd92a089fdbb0e47750d3f43d66b24d94","tarball":"https://registry.npmjs.org/@asoltys/secp256k1-zkp/-/secp256k1-zkp-2.0.4.tgz","fileCount":6,"unpackedSize":431082,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgXr1MCRA9TVsSAnZWagAAWPgQAIrIKmbZxHZbHm+LAHuY\nlgtxgg/9j+tWiC2+6kngRzRwpgGZUEzmpTnd5bt3x1NUOKBycqWYAmlNPK6m\no9GiyQp4xUGLp50edTKcmA4xXQsxra8589gElrXWAQ5hVPGHJ7M1ONkwIhLC\nUb5C9NHbqYMdaYHHFyDee81A8GUTLVRBoPIxMkSJsvNRHbf0v+b0Clf8+fq3\nX/IyLAQBFNXk0AU6lt5163NOawNB0aUbYG9jqqcH+h8oDWdUwGYspEUhh2nO\nYPL/qP2B4H1M7Ugw/D+e00nYC4lGq7JjkuieCLRD5wD2sX/rE8Q1qQdUmX9s\n5KJDq11wkpgAzUhh9d2aTFYjxqEdQSHr8vH+B8B5E+/c7aNZBsnspfqKrRun\nJIJj/CJZO1mCe6B5S8SDkuqjpjEVd/tq51oxkJUl2fzVYWfePmrU18PAi4ZK\nV3iJOwnWH0Q0kYpfc5SJ/EdynU42fs11FQ9ecEma4vMdlptsHo+MmrTkxBIz\ntwDMyVYWHdvKShBNj1k59yswB/ktU3FJgGU18xTdWXGCqUrZOVYAyqqPJIVE\n1BJzIeXAPXoq3m4ewbPVG7VG1bmqQPFsVj6xMfyRyEw2Un25FBQMsagP6KaN\nJPc2vKlL+w9MUak20nwgyUyYFQVvaHHRtOfAQMZ8IuDczVDyGD9QrcpiYc53\nUMuh\r\n=AO0O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD9WUi+AGmVD1azW6iZN4LurAEqvTAgJy2Flt9393W+nwIgXoxiTo3uIQCWSOXz6v3ycVTiKMjH0Hwr75VwfZzWIug="}]},"_npmUser":{"name":"asoltys","email":"asoltys@gmail.com"},"directories":{},"maintainers":[{"name":"asoltys","email":"asoltys@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/secp256k1-zkp_2.0.4_1616821580341_0.3602822915823176"},"_hasShrinkwrap":false}},"time":{"created":"2020-12-18T23:05:44.848Z","1.0.1":"2020-12-18T23:05:45.092Z","modified":"2022-04-04T15:48:09.395Z","2.0.4":"2021-03-27T05:06:20.523Z"},"maintainers":[{"name":"asoltys","email":"asoltys@gmail.com"}],"description":"Essential methods of the secp256k1-zkp lib exported to JS for handling Elements confidential transactions","homepage":"https://github.com/vulpemventures/secp256k1-zkp#readme","repository":{"type":"git","url":"git+https://github.com/vulpemventures/secp256k1-zkp.git"},"author":{"name":"Vulpem Ventures"},"bugs":{"url":"https://github.com/vulpemventures/secp256k1-zkp/issues"},"license":"MIT","readme":"# Secp256k1-zkp\n\n[![Build Status](https://travis-ci.org/vulpemventures/secp256k1-zkp.png?branch=master)](https://travis-ci.org/vulpemventures/secp256k1-zkp)\n[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\nThis library is under development, and, like the [secp256k1-zkp](https://github.com/ElementsProject/secp256k1-zkp) C library it depends on, this is a research effort to determine an optimal API for end-users of the liquidjs ecosystem.\n\n## Installation\n\n### Build steps (with Docker)\n\n```sh\n# Install node dependencies\n$ npm install\n\n# Pull the latest secp256k1-zkp as a git submodule\n$ git submodule update --init\n\n# This will copy secp256k1-zkp folder along with the main.c wrapper and build with emscripten inside the docker container\n$ ./bash scripts/compile_wasm_docker\n```\n\n## Bundle for browsers\n\n```sh\n$ npx browserify lib/index.js --standalone secp256k1 > bundle.browser.js\n```\n\n## Test\n\n```sh\n# lint & prettier & node\n$ npm run test\n# Only node\n$ npm run unit:node\n# Only browser\n$ npm run unit:web\n```\n\n## Usage\n\n\n### Install\n\n```sh\n$ npm install vulpemventures/secp256k1-zkp\n# or with yarn\n$ yarn add vulpemventures/secp256k1-zkp\n```\n\n### Import\n\n```js\nconst secp256k1 = require('secp256k1-zkp');\n\n// secp256k1 returns a Promise that must be resolved before using the exported methods\nconst { rangeproof, surjectionproof } = await secp256k1(); \n\nrangeproof.rewind(...)\nsurjectionproof.verify(...)\n```\n\n## Documentation\n\n\n\n### Ecdh\n\n#### ecdh(pubkey, scalar)\n\n```haskell\necdh :: Buffer -> Buffer -> Buffer\n```\n\nCompute an EC Diffie-Hellman secret in constant time.\n\n- `pubkey` 33-byte representation of a point.\n- `scalar` 32-byte arrayscalar with which to multiply the point.\n\n### Generator\n\n#### generateBlinded(key, blind)\n\n```haskel\ngenerateBlinded :: Buffer -> Buffer -> Buffer\n```\n\nGenerate a blinded generator for the curve.\n\n- `key` 32-byte seed.\n- `blind` 32-byte secret value to blind the generator with.\n\n#### parse(input)\n\n```haskell\nparse :: Buffer -> Buffer\n```\n\nParse a 33-byte generator byte sequence into a 64-byte raw generator.\n\n- `input` 33-byte serialized generator.\n\n#### serialzie(generator)\n\n```haskell\nserialize :: Buffer -> Buffer\n```\n\nSerialize a raw generator into a serialized byte sequence.\n\n- `generator` 64-byte raw generator to serialize.\n\n### Pedersen\n\n#### commit(blindFactor, value)\n\n```haskell\ncommit :: Buffer -> String -> Buffer\n```\n\nGenerate a pedersen commitment.\n\n- `blindFactor` 32-byte blinding factor.\n- `value` uint64 value to commit to as string.\n\n#### commitSerialize(commitment)\n\n```haskel\ncommitSerialize :: Buffer -> Buffer\n```\n\nSerialize a raw commitment into a 33-byte serialized byte sequence.\n\n- `commitment` raw commitment to serialize.\n\n#### commitParse(input)\n\n```haskell\ncommitParse :: Buffer -> Buffer\n```\n\nParse a 33-byte commitment into a raw commitment.\n\n- `input` 33-byte serialized commitment key\n\n#### blindGeneratorBlindSum(values, nInputs, blindGenerators, blindFactors)\n\n```haskell\nblindGeneratorBlindSum :: Array -> Number -> Array -> Array -> Buffer\n```\n\nSet the final Pedersen blinding factor correctly when the generators themselves have blinding factors.\n\n- `values` array of string asset values.\n- `nInputs` How many of the initial array elements represent commitments that will be negated in the final sum.\n- `blindGenerators` array of asset blinding factors.\n- `blindFactors` array of commitment blinding factors.\n\n#### blindSum(blinds[, nneg=0])\n\n```haskell\nblindSum :: Array [-> Number] -> Buffer\n```\n\nCompute the sum of multiple positive and negative blinding factors.\n\n- `blinds` array of 32-byte blinding factors.\n- `nneg` how many of the initial factors should be treated with a negative sign.\n\n#### verifySum(commits, negativeCommits)\n\n```haskell\nverifySum :: Array -> Array -> Bool\n```\n\nVerify a tally of pedersen commitments.\n\n- `commits` array of 33-byte pedersen commitments\n- `negativeCommits` array of 33-byte pedersen negative commitments\n\n### Rangeproof\n\n#### sign(commit, blind, nonce, value[, minValue=\"0\", base10Exp=0, minBits=0, message=[], extraCommit=[]])\n\n```haskell\nsign :: Buffer -> Buffer -> Buffer -> String [-> String -> Number -> Number -> Buffer -> Buffer] -> Buffer\n```\n\nAuthor a proof that a committed value is within a range.\n\n- `commit` 33-byte commitment to being proved.\n- `blind` 32-byte blinding factor used by commit.\n- `nonce` 32-byte secret nonce used to initialize the proof.\n- `value` actual value of the commitment as string.\n- `minValue` constructs a proof where the verifer can tell the minimum value is at least the specified amount (passed as string).\n- `base10Exp` base-10 exponent. Digits below above will be made public, but the proof will be made smaller. Allowed range is -1 to 18.\n- `minBits` number of bits of the value to keep private. (0 = auto/minimal, - 64).\n- `message` data to be embedded in the rangeproof that can be recovered by rewinding the proof.\n- `extraCommit` additional data to be covered in rangeproof signature.\n\n#### info(proof)\n\n```haskell\ninfo :: Object -> Object\n```\n\nExtract some basic information from a range-proof.\n\n- `proof` rangeproof to extract information to.\n\n#### verify(commit, proof[, extraCommit=[]])\n\n```haskell\nverify :: Buffer -> Object [-> Buffer] -> Bool\n```\n\nVerify a proof that a committed value is within a range.\n\n- `commit` 33-byte commitments being proved.\n- `proof` rangeproof used to verify commitment.\n- `extraCommit` additional data covered in rangeproof signature.\n\n#### rewind(commit, proof, nonce[, extraCommit = []])\n\n```haskell\nrewind :: Buffer -> Object -> Buffer [-> Buffer] -> Object\n```\n\nVerify a range proof and rewind the proof to recover information sent by its author.\n\n- `commit` 33-byte commitment being proved.\n- `proof` rangeproof.\n- `nonce` 32-byte secret nonce used by the prover.\n- `extraCommit` additional data covered in rangeproof signature.\n\nReturns wether the value is within the range [0..2^64), the specifically proven range is in the min/max value outputs, and the value and blinding were recovered.\n\n- `value` uint64 which has the exact value of the commitment.\n- `minValue` uint64 which will be updated with the minimum value that commit could have.\n- `maxValue` uint64 which will be updated with the maximum value that commit could have.\n- `blindFactor` 32-byte blinding factor used for the commitment.\n- `message` message data from the proof author.\n\n### Surjectionproof\n\n#### serialize(proof)\n\n```haskell\nserialize :: Object -> Buffer\n```\n\nSerialize a surjection proof.\n\n- `proof` initialized surjection proof.\n\n#### initialize(inputTags, inputTagsToUse, outputTag, maxIterations, seed)\n\n```haskell\ninitialize :: Array -> Number -> Buffer -> Number -> Object\n```\n\nInitialize a surjection proof.\n\n- `inputTags` fixed input tags `A_i` for all inputs.\n- `inputTagsToUse` the number of inputs to select randomly to put in the anonymity set.\n- `outputTag` fixed output tag.\n- `maxIterations` the maximum number of iterations to do before giving up.\n- `seed` a random seed to be used for input selection.\n\n#### generate(proof, inputTags, outputTag, inputIndex, inputBlindingKey, outputBlindingKey)\n\n```haskell\ngenerate :: Object -> Array -> Buffer -> Number -> Buffer -> Buffer -> Object\n```\n\nGenerate an initialized surjection proof.\n\n- `proof` initialized surjection proof\n- `inputTags` the ephemeral asset tag of all inputs.\n- `outputTag` the ephemeral asset tag of the output.\n- `inputIndex` the index of the input that actually maps to the output.\n- `inputBlindingKey` the blinding key of the input.\n- `outputBlindingKey` the blinding key of the output.\n\n#### verify(proof, inputTags, outputTag)\n\n```haskell\nverify :: Object -> Array -> Buffer -> Bool\n```\n\nVerify a surjection proof.\n\n- `proof` surjection proof to be verified.\n- `inputTags` the ephemeral asset tag of all inputs.\n- `outputTag` the ephemeral asset tag of the output.\n\n---\n\n## Credit\n\nThis library uses the native library [secp256k1-zkp](https://github.com/ElementsProject/secp256k1-zkp) by the Elements Project developers, including derivatives of its tests and test vectors.\n\n# LICENSE [MIT](LICENSE)\n","readmeFilename":"README.md"}