{"_id":"@arisensdk/ecc","_rev":"1-0599a416f76126de4d2d1db1de26cf4d","name":"@arisensdk/ecc","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@arisensdk/ecc","version":"1.0.0","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=lcov --reporter=text npm test","coveralls":"yarn coverage && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls","build":"yarn build_lib && yarn build_browser","build_lib":"rm -f lib/* && babel src --out-dir lib","build_browser":"mkdir -p lib && browserify -o lib/arisensdk-ecc.js -s arisensdk_ecc lib/index.js","build_browser_test":"yarn build && browserify -o dist/test.js lib/*.test.js","documentation":"node_modules/documentation/bin/documentation.js","minimize":"terser lib/arisensdk-ecc.js -o lib/arisensdk-ecc.min.js --source-map --compress --mangle","docs":"yarn documentation -- readme src/api_common.js --section \"Common API\" --shallow","srisum":"npx srisum lib/arisensdk-ecc*","prepublishOnly":"yarn build && yarn minimize && yarn test_lib && yarn docs"},"repository":{"type":"git","url":"git+https://github.com/arisensdk/ecc.git"},"dependencies":{"@babel/runtime":"7.6.0","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":"^7.6.0","@babel/core":"^7.6.0","@babel/plugin-transform-runtime":"^7.6.0","@babel/preset-env":"^7.6.0","browserify":"^16.2.3","coveralls":"^3.0.3","documentation":"^12.1.4","mocha":"^5.2.0","nyc":"^14.1.0","terser":"^3.17.0"},"nyc":{"temp-directory":"./coverage/.nyc_output"},"babel":{"presets":["@babel/preset-env"],"plugins":["@babel/plugin-transform-runtime"]},"gitHead":"24a4c5c24fc3a7b15d5673d025a00e0f1430a31c","bugs":{"url":"https://github.com/arisensdk/ecc/issues"},"homepage":"https://github.com/arisensdk/ecc#readme","_id":"@arisensdk/ecc@1.0.0","_nodeVersion":"11.0.0","_npmVersion":"7.6.1","dist":{"integrity":"sha512-o0V71D5Sf/ULcxGKWmarlvKTSYwe5j2M0vavNMKexUzeLw6wTFoxKlU9wu6xQYD/74IShMh7nAjFLH1eSUqpUg==","shasum":"a8554dc737f117a4b4aead69818d2b78bb88840a","tarball":"https://registry.npmjs.org/@arisensdk/ecc/-/ecc-1.0.0.tgz","fileCount":20,"unpackedSize":1246618,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgVgIQCRA9TVsSAnZWagAA4MwP/RqqnQAUrf3KCEja8qGA\n86yalJsUHdaTjihTynhT38xWEvpsv/uy6Ete6J71m6ZFpWmlPAYa8vFDvGox\nZMICVMaTCkAdmZ2AtvFgFd1n26PMTSBPZu3iiDLmBRgJQFt+I3vsiJJNGFBf\ngySEMe5YR3zBu6HDaC3nkfGXIYEzJy3vQecL3xgdGmvjBr9Q2Qbx3ty0bXNE\n+EF35+I8z/PweSyKjfUBeTosoiFKByNXplq///gUwFr68NWq11CMFNtTJawt\nsffjek/PXjeZ4C0b0AtlwwsdGqG+J7MufQBO8lp8uitfJ5UkzSESppxglnFb\n6R4k0ge0KghritkiUo2I5NCcf8t80fn8JjfyOsg34FXMcI0kjNiX5+6RmJ8A\n+is6uJaOfQOi6XlXrIH7aBlYym9TTOtKkKqoAe/akYhU4PRjAyCze+OhlvXT\nt0cwJtVKDPfR+LCApPlhHNAzC3Uy+2xPS/dN69oQfOejWY8mB72vIGXhVOUm\n69Sc6KSTlyBqiKakitzsFdTOl/L2V6hLc3u3PBxzIY6nrD0OYB9+4KEveNHR\nvwgA9//TSW3LvWIs6KMWoJbU8o9sSyJIe1dD0u8SwwrcTHETNYoNOU0Jx5K7\nC6AvVWqO3IGRYMoK+SMQDj+6I3Us2YIBgFomShGHiie+RktIi1TfPw0Fux7C\n90P1\r\n=+i/k\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXrt6vbZH5sSq2dRHy1Zngt0/TPT/Aualr8lSLbU5FNgIgYUVpLuIre7gtHZNLSv4nTL6kV9yVUu44JDQNSYgt04A="}]},"_npmUser":{"name":"dwebprotocol","email":"shikhar@arisen.network"},"directories":{},"maintainers":[{"name":"dwebprotocol","email":"shikhar@arisen.network"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ecc_1.0.0_1616249360132_0.1816456918755227"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-20T14:09:19.873Z","1.0.0":"2021-03-20T14:09:20.324Z","modified":"2022-04-04T15:27:48.914Z"},"maintainers":[{"name":"dwebprotocol","email":"shikhar@arisen.network"}],"description":"Elliptic curve cryptography functions","homepage":"https://github.com/arisensdk/ecc#readme","keywords":["ECC","Private Key","Public Key","Signature","AES","Encryption","Decryption"],"repository":{"type":"git","url":"git+https://github.com/arisensdk/ecc.git"},"bugs":{"url":"https://github.com/arisensdk/ecc/issues"},"license":"MIT","readme":"[![NPM](https://img.shields.io/npm/v/@arisensdk/ecc.svg)](https://www.npmjs.org/package/@arisensdk/ecc)\n[![Build Status](https://travis-ci.org/arisensdk/ecc.svg?branch=master)](https://travis-ci.org/arisensdk/ecc)\n\n# Elliptic curve cryptography functions (ECC)\n\nPrivate Key, Public Key, Signature, AES, Encryption / Decryption\n\n# Import\n\n```js\nimport ecc from '@arisensdk/ecc'\n// or\nconst ecc = require('@arisensdk/ecc')\n```\n\n# Include\n\n-   Install with: `yarn add @arisensdk/ecc`\n-   Html script tag, see [releases](https://github.com/arisensdk/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/arisensdk-ecc.js\n  sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ== lib/arisensdk-ecc.min.js\n  sha512-eq1SCoSe38uR1UVuQMwR73VgY8qKTBDc87n2nIiC5WLhn1o2y1U6c5wY8lrigVX7INM8fM0PxDlMX5WvpghKig== lib/arisensdk-ecc.min.js.map\n  -->\n  <script src=\"https://cdn.jsdelivr.net/npm/@arisensdk/ecc@1.0.0/lib/arisensdk-ecc.min.js\"\n    integrity=\"sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ==\"\n    crossorigin=\"anonymous\"></script>\n\n</head>\n<body>\n  See console object: arisensdk_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-   [pubkey](#pubkey)\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\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## pubkey\n\nRSNKey..\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)) // RSNKey...\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 `'RSN'`)\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 RSNKey..\n-   `pubkey_prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**  (optional, default `'RSN'`)\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))** (RSNbase58sig.., 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))** (RSNbase58sig.., 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# Usage (Object API)\n\n```js\nlet {PrivateKey, PublicKey, Signature, Aes, key_utils, config} = require('@arisensdk/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/arisensdk/ecc.git\ncd @arisensdk/ecc\nyarn\nyarn build_browser\n# builds: ./dist/arisensdk-ecc.js\n# Verify release hash\n```\n\n```html\n<script src=arisensdk-ecc.js></script>\n```\n\n```js\nvar ecc = arisensdk_ecc\n\necc.randomKey().then(privateWif =>  {\n  var pubkey = ecc.privateToPublic(privateWif)\n  console.log(pubkey)\n})\n```\n","readmeFilename":"README.md"}