{"_id":"@aggregion/agrjs-ecc","_rev":"6-d9e06b75b6f6eedb04b02f39b14b1776","name":"@aggregion/agrjs-ecc","dist-tags":{"latest":"4.0.5"},"versions":{"4.0.5":{"name":"@aggregion/agrjs-ecc","version":"4.0.5","description":"Elliptic curve cryptography functions","keywords":["ECC","Private Key","Public Key","Signature","AES","Encryption","Decryption"],"main":"lib/index.js","scripts":{"test":"mocha --use_strict src/*.test.js","test_lib":"mocha --use_strict lib/*.test.js","coverage":"nyc --reporter=html npm test","coveralls":"npm run coverage && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls","build":"npm run build_lib && npm run build_browser","build_lib":"rm -f lib/* && babel src --out-dir lib","build_browser":"mkdir -p lib && browserify -o lib/agrjs-ecc.js -s agrjs_ecc lib/index.js","build_browser_test":"npm run build && browserify -o dist/test.js lib/*.test.js","documentation":"node_modules/documentation/bin/documentation.js","minimize":"uglifyjs lib/agrjs-ecc.js -o lib/agrjs-ecc.min.js --source-map --compress --mangle","docs":"npm run documentation -- readme src/api_common.js --section \"Common API\" --shallow","srisum":"npx srisum lib/agrjs-ecc.*","prepublishOnly":"npm run build && npm run test_lib && npm run minimize && npm run docs && npm run srisum"},"repository":{"type":"git","url":"git://github.com/aggregion/agrjs-ecc.git"},"dependencies":{"bigi":"^1.4.2","browserify-aes":"^1.0.6","bs58":"^4.0.1","bytebuffer":"^5.0.1","create-hash":"^1.1.3","create-hmac":"^1.1.6","ecurve":"^1.0.5","randombytes":"^2.0.5"},"license":"MIT","devDependencies":{"babel-cli":"6.26.0","babel-core":"^6.26.3","babel-preset-es2015":"6.24.1","browserify":"14.4.0","coveralls":"^3.0.0","documentation":"^8.1.1","istanbul":"^0.4.5","mocha":"^5.2.0","nyc":"^13.0.1","uglify-js":"3.4.2"},"babel":{"presets":["es2015"]},"gitHead":"8b51051513bc782ed9472ef9842739a420f26da3","bugs":{"url":"https://github.com/aggregion/agrjs-ecc/issues"},"homepage":"https://github.com/aggregion/agrjs-ecc#readme","_id":"@aggregion/agrjs-ecc@4.0.5","_npmVersion":"6.4.0","_nodeVersion":"8.3.0","_npmUser":{"name":"denisbezrukov","email":"denis.bezrukov@aggregion.com"},"dist":{"integrity":"sha512-jZ4w/A1Cp2+eiTltFZWgBUp2AtQffxXV9ji+ptuXThxo44dA7IYS7F1DpZC/twKtFkxBacY4mhmDB2Gd6V/lBA==","shasum":"5de0f58db49b63557b7a1ebc2bddcfb302db1ab4","tarball":"https://registry.npmjs.org/@aggregion/agrjs-ecc/-/agrjs-ecc-4.0.5.tgz","fileCount":20,"unpackedSize":1234125,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbiByLCRA9TVsSAnZWagAA7wQQAJJeqnkb4LB6zPcxCvWP\n7FdD1GnpVNc2UUGOXAXXGNdjy9IAD5o+Onf89nQs8zEXY2dGqVVn8bxUHzg+\nB/Xv5tKZKKSMjoeW9LPRx0cF1jhG9fLjT+Vqz74wR/LYKSRerFfezj80uqbV\nJYohlfXz42EPRYCCV4QKiai9ZkCVei6mE2NoLzUwdNFkUjyV5ZPyjBYfWkCF\nRKiNmZ0WLqqtH55ejUuQ50LzvKpgNV2wVb9sM4cYOmsX6Gsrx2woGTr6iT+q\nT874MqwYoMo7Axinqlw9NjZ79xBqvfVJW6xLw2u0x54Iv0CK1Vjm24I29UaD\nkQ++iFbHQVtfInsobGKsSRV2DrGdyOvjd+UXXWTF+K2dCx2F7xfNkOY5JreY\nSUMcxInPWazllBW8+wTzxoMFMEAymJEO3ZSRXVkeoUNDsfy/aT6KMrg/R7wh\nVR/y200Y+UXKDJdrf9rYn/mZD83kdu1EnQf+2oy28m9PIGpYeIl0DguB4D2g\nIIKNMAwd3kCW88k1PfHMXxXC/loqMz5NVgSJpQNgsjOZlXcGtFBVcgGgvnqy\no5AcxU0kpwWy3ukrELrcIIViFK360Um+DAixCNnXG+1DBXOaJ/NZdEDnFWmO\nz9N81BVKS8dbvQbSSLNroAMGfnmDwNuvoA94bzEXxedR1QqFLUOS2Ykv3MFt\nIEnG\r\n=XAaa\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICjWt+giNP/+wAt/C1WniJWl2x8IHixZPEAw6bDcZ7SHAiAhAHcNvgZecLCCLoBxQ7fjFUy1o6loq7xk9vxtHi0YaA=="}]},"maintainers":[{"name":"denisbezrukov","email":"denis.bezrukov@aggregion.com"},{"name":"plasticut","email":"plasticut@gmail.com"},{"name":"zbit","email":"i@zbit.name"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/agrjs-ecc_4.0.5_1535646858317_0.10925107272580514"},"_hasShrinkwrap":false}},"time":{"created":"2018-08-30T16:34:18.262Z","4.0.5":"2018-08-30T16:34:18.535Z","modified":"2022-04-04T11:57:03.169Z"},"maintainers":[{"email":"smv.dmitry@gmail.com","name":"dmitry_smv"},{"email":"denis.bezrukov@aggregion.com","name":"denisbezrukov"},{"email":"i@zbit.name","name":"zbit"},{"email":"alexander.sedelnikov@ymail.com","name":"alekns"},{"email":"d.n.voropaev@gmail.com","name":"takatan"},{"email":"vasilii.kuznetsov@aggregion.com","name":"vasiliykuznetsov"}],"description":"Elliptic curve cryptography functions","homepage":"https://github.com/aggregion/agrjs-ecc#readme","keywords":["ECC","Private Key","Public Key","Signature","AES","Encryption","Decryption"],"repository":{"type":"git","url":"git://github.com/aggregion/agrjs-ecc.git"},"bugs":{"url":"https://github.com/aggregion/agrjs-ecc/issues"},"license":"MIT","readme":"# Elliptic curve cryptography functions (ECC)\n\nPrivate Key, Public Key, Signature, AES, Encryption / Decryption\n\n# Import\n\n```js\nimport ecc from 'agrjs-ecc'\n// or\nconst ecc = require('agrjs-ecc')\n```\n\n# Include\n\n-   Install with: `npm install agrjs-ecc`\n-   Html script tag, see [releases](https://github.com/AGRIO/agrjs-ecc/releases) for the correct **version** and its matching script **integrity** hash.\n\n```html\n<html>\n<head>\n  <meta charset=\"utf-8\">\n  <!--\n  sha512-cL+IQQaQ586s9DrXfGtDheRpj5iDKh2M+xlpfwbhNjRIp4BGQ1fkM/vB4Ta8mc+f51YBW9sJiPcyMDIreJe6gQ== lib/agrjs-ecc.js\n  sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ== lib/agrjs-ecc.min.js\n  sha512-eq1SCoSe38uR1UVuQMwR73VgY8qKTBDc87n2nIiC5WLhn1o2y1U6c5wY8lrigVX7INM8fM0PxDlMX5WvpghKig== lib/agrjs-ecc.min.js.map\n  -->\n  <script src=\"https://cdn.jsdelivr.net/npm/agrjs-ecc@4.0.4/lib/agrjs-ecc.min.js\"\n    integrity=\"sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ==\"\n    crossorigin=\"anonymous\"></script>\n\n</head>\n<body>\n  See console object: agrjs_ecc\n</body>\n</html>\n```\n\n# Common API\n\n<!-- Generated by documentation.js. Update this documentation by updating the source code. -->\n\n### Table of Contents\n\n-   [wif](#wif)\n-   [ecc](#ecc)\n    -   [initialize](#initialize)\n    -   [unsafeRandomKey](#unsaferandomkey)\n    -   [randomKey](#randomkey)\n        -   [Parameters](#parameters)\n        -   [Examples](#examples)\n    -   [seedPrivate](#seedprivate)\n        -   [Parameters](#parameters-1)\n        -   [Examples](#examples-1)\n    -   [privateToPublic](#privatetopublic)\n        -   [Parameters](#parameters-2)\n        -   [Examples](#examples-2)\n    -   [isValidPublic](#isvalidpublic)\n        -   [Parameters](#parameters-3)\n        -   [Examples](#examples-3)\n    -   [isValidPrivate](#isvalidprivate)\n        -   [Parameters](#parameters-4)\n        -   [Examples](#examples-4)\n    -   [sign](#sign)\n        -   [Parameters](#parameters-5)\n        -   [Examples](#examples-5)\n    -   [signHash](#signhash)\n        -   [Parameters](#parameters-6)\n    -   [verify](#verify)\n        -   [Parameters](#parameters-7)\n        -   [Examples](#examples-6)\n    -   [recover](#recover)\n        -   [Parameters](#parameters-8)\n        -   [Examples](#examples-7)\n    -   [recoverHash](#recoverhash)\n        -   [Parameters](#parameters-9)\n    -   [sha256](#sha256)\n        -   [Parameters](#parameters-10)\n        -   [Examples](#examples-8)\n-   [pubkey](#pubkey)\n\n## wif\n\n[Wallet Import Format](https://en.bitcoin.it/wiki/Wallet_import_format)\n\nType: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\n\n## ecc\n\n### initialize\n\nInitialize by running some self-checking code.  This should take a\nsecond to gather additional CPU entropy used during private key\ngeneration.\n\nInitialization happens once even if called multiple times.\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** \n\n### unsafeRandomKey\n\nDoes not pause to gather CPU entropy.\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;PrivateKey>** test key\n\n### randomKey\n\n#### Parameters\n\n-   `cpuEntropyBits` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** gather additional entropy\n    from a CPU mining algorithm.  This will already happen once by\n    default. (optional, default `0`)\n\n#### Examples\n\n```javascript\necc.randomKey().then(privateKey => {\nconsole.log('Private Key:\\t', privateKey) // wif\nconsole.log('Public Key:\\t', ecc.privateToPublic(privateKey)) // AGRkey...\n})\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[wif](#wif)>** \n\n### seedPrivate\n\n#### Parameters\n\n-   `seed` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** any length string.  This is private.  The same\n    seed produces the same private key every time.  At least 128 random\n    bits should be used to produce a good private key.\n\n#### Examples\n\n```javascript\necc.seedPrivate('secret') === wif\n```\n\nReturns **[wif](#wif)** \n\n### privateToPublic\n\n#### Parameters\n\n-   `wif` **[wif](#wif)** \n-   `pubkey_prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** public key prefix (optional, default `'AGR'`)\n\n#### Examples\n\n```javascript\necc.privateToPublic(wif) === pubkey\n```\n\nReturns **[pubkey](#pubkey)** \n\n### isValidPublic\n\n#### Parameters\n\n-   `pubkey` **[pubkey](#pubkey)** like AGRKey..\n-   `pubkey_prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**  (optional, default `'AGR'`)\n\n#### Examples\n\n```javascript\necc.isValidPublic(pubkey) === true\n```\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** valid\n\n### isValidPrivate\n\n#### Parameters\n\n-   `wif` **[wif](#wif)** \n\n#### Examples\n\n```javascript\necc.isValidPrivate(wif) === true\n```\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** valid\n\n### sign\n\nCreate a signature using data or a hash.\n\n#### Parameters\n\n-   `data` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** \n-   `privateKey` **([wif](#wif) | PrivateKey)** \n-   `encoding` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data encoding (if string) (optional, default `'utf8'`)\n\n#### Examples\n\n```javascript\necc.sign('I am alive', wif)\n```\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** string signature\n\n### signHash\n\n#### Parameters\n\n-   `dataSha256` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** sha256 hash 32 byte buffer or string\n-   `privateKey` **([wif](#wif) | PrivateKey)** \n-   `encoding` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** dataSha256 encoding (if string) (optional, default `'hex'`)\n\nReturns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** string signature\n\n### verify\n\nVerify signed data.\n\n#### Parameters\n\n-   `signature` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** buffer or hex string\n-   `data` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** \n-   `pubkey` **([pubkey](#pubkey) | PublicKey)** \n-   `encoding`   (optional, default `'utf8'`)\n-   `hashData` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** sha256 hash data before verify (optional, default `true`)\n\n#### Examples\n\n```javascript\necc.verify(signature, 'I am alive', pubkey) === true\n```\n\nReturns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \n\n### recover\n\nRecover the public key used to create the signature.\n\n#### Parameters\n\n-   `signature` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** (AGRbase58sig.., Hex, Buffer)\n-   `data` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** full data\n-   `encoding` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** data encoding (if data is a string) (optional, default `'utf8'`)\n\n#### Examples\n\n```javascript\necc.recover(signature, 'I am alive') === pubkey\n```\n\nReturns **[pubkey](#pubkey)** \n\n### recoverHash\n\n#### Parameters\n\n-   `signature` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** (AGRbase58sig.., Hex, Buffer)\n-   `dataSha256` **([String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** sha256 hash 32 byte buffer or hex string\n-   `encoding` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** dataSha256 encoding (if dataSha256 is a string) (optional, default `'hex'`)\n\nReturns **PublicKey** \n\n### sha256\n\n#### Parameters\n\n-   `data` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** always binary, you may need Buffer.from(data, 'hex')\n-   `resultEncoding`   (optional, default `'hex'`)\n-   `encoding` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** result encoding 'hex', 'binary' or 'base64' (optional, default `'hex'`)\n\n#### Examples\n\n```javascript\necc.sha256('hashme') === '02208b..'\n```\n\n```javascript\necc.sha256(Buffer.from('02208b', 'hex')) === '29a23..'\n```\n\nReturns **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Buffer](https://nodejs.org/api/buffer.html))** Buffer when encoding is null, or string\n\n## pubkey\n\nAGRKey..\n\nType: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)\n\n# Usage (Object API)\n\n```js\nlet {PrivateKey, PublicKey, Signature, Aes, key_utils, config} = require('agrjs-ecc')\n\n// Create a new random private key\nlet privateWif\nPrivateKey.randomKey().then(privateKey => privateWif = privateKey.toWif())\n\n// Convert to a public key\npubkey = PrivateKey.fromString(privateWif).toPublic().toString()\n```\n\n-   [PrivateKey](./src/key_private.js)\n-   [PublicKey](./src/key_public.js)\n-   [Signature](./src/signature.js)\n-   [Aes](./src/aes.js)\n-   [key_utils](./src/key_utils.js)\n-   [config](./src/config.js)\n\n# Browser\n\n```bash\ngit clone https://github.com/AGRIO/agrjs-ecc.git\ncd agrjs-ecc\nnpm install\nnpm run build_browser\n# builds: ./dist/agrjs-ecc.js\n# Verify release hash\n```\n\n```html\n<script src=agrjs-ecc.js></script>\n```\n\n```js\nvar ecc = agrjs_ecc\n\necc.randomKey().then(privateWif =>  {\n  var pubkey = ecc.privateToPublic(privateWif)\n  console.log(pubkey)\n})\n```\n","readmeFilename":"README.md"}