{"id":13453425,"url":"https://github.com/EOSIO/eosjs-ecc","last_synced_at":"2025-03-24T01:31:25.178Z","repository":{"id":37821146,"uuid":"99262462","full_name":"EOSIO/eosjs-ecc","owner":"EOSIO","description":"Elliptic curve cryptography functions: Private Key, Public Key, Signature, AES, Encryption, Decryption","archived":false,"fork":false,"pushed_at":"2023-07-11T00:59:18.000Z","size":928,"stargazers_count":289,"open_issues_count":46,"forks_count":120,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-03-18T10:09:01.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EOSIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-08-03T18:18:41.000Z","updated_at":"2025-01-08T15:46:24.000Z","dependencies_parsed_at":"2024-01-03T05:13:50.884Z","dependency_job_id":"277a95ab-6aeb-41c1-af40-f7408287e644","html_url":"https://github.com/EOSIO/eosjs-ecc","commit_stats":{"total_commits":119,"total_committers":11,"mean_commits":"10.818181818181818","dds":0.2857142857142857,"last_synced_commit":"a806b93fbbccec8d38c0c02998d204ff2040a6ae"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-ecc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-ecc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-ecc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs-ecc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EOSIO","download_url":"https://codeload.github.com/EOSIO/eosjs-ecc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245194225,"owners_count":20575725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:39.827Z","updated_at":"2025-03-24T01:31:24.808Z","avatar_url":"https://github.com/EOSIO.png","language":"JavaScript","funding_links":[],"categories":["Language Support","EOS Libraries","Developers"],"sub_categories":["JavaScript","Developer Tools"],"readme":"[![NPM](https://img.shields.io/npm/v/eosjs-ecc.svg)](https://www.npmjs.org/package/eosjs-ecc)\n[![Build Status](https://travis-ci.org/EOSIO/eosjs-ecc.svg?branch=master)](https://travis-ci.org/EOSIO/eosjs-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 'eosjs-ecc'\n// or\nconst ecc = require('eosjs-ecc')\n```\n\n# Include\n\n-   Install with: `yarn add eosjs-ecc`\n-   Html script tag, see [releases](https://github.com/EOSIO/eosjs-ecc/releases) for the correct **version** and its matching script **integrity** hash.\n\n```html\n\u003chtml\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003c!--\n  sha512-cL+IQQaQ586s9DrXfGtDheRpj5iDKh2M+xlpfwbhNjRIp4BGQ1fkM/vB4Ta8mc+f51YBW9sJiPcyMDIreJe6gQ== lib/eosjs-ecc.js\n  sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ== lib/eosjs-ecc.min.js\n  sha512-eq1SCoSe38uR1UVuQMwR73VgY8qKTBDc87n2nIiC5WLhn1o2y1U6c5wY8lrigVX7INM8fM0PxDlMX5WvpghKig== lib/eosjs-ecc.min.js.map\n  --\u003e\n  \u003cscript src=\"https://cdn.jsdelivr.net/npm/eosjs-ecc@4.0.4/lib/eosjs-ecc.min.js\"\n    integrity=\"sha512-dYFDmK/d9r3/NCp6toLtfkwOjSMRBaEzaGAx1tfRItC0nsI0hVLERk05iNBQR7uDNI7ludYhcBI4vUiFHdjsTQ==\"\n    crossorigin=\"anonymous\"\u003e\u003c/script\u003e\n\n\u003c/head\u003e\n\u003cbody\u003e\n  See console object: eosjs_ecc\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n# Common API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\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)\u0026lt;PrivateKey\u003e** 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 =\u003e {\nconsole.log('Private Key:\\t', privateKey) // wif\nconsole.log('Public Key:\\t', ecc.privateToPublic(privateKey)) // EOSkey...\n})\n```\n\nReturns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\u0026lt;[wif](#wif)\u003e** \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 `'EOS'`)\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 EOSKey..\n-   `pubkey_prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**  (optional, default `'EOS'`)\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))** (EOSbase58sig.., 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))** (EOSbase58sig.., 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\nEOSKey..\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('eosjs-ecc')\n\n// Create a new random private key\nlet privateWif\nPrivateKey.randomKey().then(privateKey =\u003e 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/EOSIO/eosjs-ecc.git\ncd eosjs-ecc\nyarn\nyarn build_browser\n# builds: ./dist/eosjs-ecc.js\n# Verify release hash\n```\n\n```html\n\u003cscript src=eosjs-ecc.js\u003e\u003c/script\u003e\n```\n\n```js\nvar ecc = eosjs_ecc\n\necc.randomKey().then(privateWif =\u003e  {\n  var pubkey = ecc.privateToPublic(privateWif)\n  console.log(pubkey)\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEOSIO%2Feosjs-ecc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEOSIO%2Feosjs-ecc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEOSIO%2Feosjs-ecc/lists"}