{"id":17175871,"url":"https://github.com/sc0vu/js-secp256k1","last_synced_at":"2025-04-13T16:42:16.777Z","repository":{"id":35783973,"uuid":"218507279","full_name":"sc0Vu/js-secp256k1","owner":"sc0Vu","description":"Compiled webassembly of bitcoin secp256k1","archived":false,"fork":false,"pushed_at":"2023-01-07T21:55:35.000Z","size":4214,"stargazers_count":4,"open_issues_count":14,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T07:35:55.204Z","etag":null,"topics":["bitcoin","cryptography","elliptic","secp256k1","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sc0Vu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-30T11:01:41.000Z","updated_at":"2021-05-25T01:18:41.000Z","dependencies_parsed_at":"2023-01-16T06:30:23.656Z","dependency_job_id":null,"html_url":"https://github.com/sc0Vu/js-secp256k1","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0Vu%2Fjs-secp256k1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0Vu%2Fjs-secp256k1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0Vu%2Fjs-secp256k1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sc0Vu%2Fjs-secp256k1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sc0Vu","download_url":"https://codeload.github.com/sc0Vu/js-secp256k1/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248747417,"owners_count":21155447,"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":["bitcoin","cryptography","elliptic","secp256k1","wasm","webassembly"],"created_at":"2024-10-14T23:57:59.095Z","updated_at":"2025-04-13T16:42:16.757Z","avatar_url":"https://github.com/sc0Vu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-secp256k1\n[![CI](https://github.com/sc0Vu/js-secp256k1/actions/workflows/ci.yml/badge.svg)](https://github.com/sc0Vu/js-secp256k1/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/sc0Vu/js-secp256k1/branch/master/graph/badge.svg)](https://codecov.io/gh/sc0Vu/js-secp256k1)\n\nCompiled webassembly of bitcoin secp256k1\n\n# Install\n\n* install library\n\n```BASH\n$ npm install js-secp256k1\n```\n\n# Build with emscripten\n\nYou can build secp256k1 wasm yourself with emscripten. We build two version of secp256k1 - node and web. The only difference is that there is no file system in web version.\n\n```BASH\n$ sh build.sh\n```\n\nAfter build wasm files, you should build javascript library again.\n\n```BASH\n$ npm run build\n```\n\n# Usage\n\n* Hash message\n```JS\n// for nodejs\nconst secp256k1Async = require('js-secp256k1/dist/node-bundle')\n\n// for browser\nconst secp256k1Async = require('js-secp256k1/dist/bundle')\n\n// initialize the library\nsecp256k1 = await secp256k1Async()\n\n// generate public key from private key\nconst privKey = Buffer.from([......])\n// browser\nconst privKey = new Uint8Array([......])\n\nlet pubkey = secp256k1.privkeyToPubkey(privkey)\n\n// serialize public key\nlet compressed = true\nlet cpubkey = secp256k1.serializePubkey(pubkey, compressed)\n\n// sign\n// signature {\n//   signature: \u003cBuffer/Uint8Array\u003e,\n//   recovery: \u003cint\u003e\n// }\nlet sig = secp256k1.sign(msg, privkey)\n\n// verify\nlet isVerified secp256k1.verify(msg, sig.signature, pubkey)\n\n// recover\nlet rpubkey = secp256k1.recover(msg, sig.signature, sig.recovery)\n```\n\n# Benchmark\n\nComputer: 2.2 GHz 6-Core Intel Core i7\n\n```\n$ node -v\nv12.18.1\n\n\u003e secp256k1-benchmark@0.0.0 start /Users/peterlai/Desktop/Projects/js-secp256k1/benchmarks\n\u003e node index.js\n\nSecp256k1 WASM (current) x 3,979 ops/sec ±0.22% (94 runs sampled)\nSecp256k1 0.2.1 WASM (current) x 3,865 ops/sec ±1.08% (96 runs sampled)\nGYP Binding (secp256k1) x 1,156 ops/sec ±1.17% (93 runs sampled)\nPure JS (elliptic) x 1,249 ops/sec ±0.57% (96 runs sampled)\nSign: fastest is Secp256k1 WASM (current)\nSecp256k1 WASM (current) x 2,275 ops/sec ±0.55% (98 runs sampled)\nSecp256k1 0.2.1 WASM (current) x 1,734 ops/sec ±0.07% (97 runs sampled)\nGYP Binding (secp256k1): \nPure JS (elliptic) x 460 ops/sec ±0.32% (93 runs sampled)\nRecover: fastest is Secp256k1 WASM (current)\nSecp256k1 WASM (current) x 2,757 ops/sec ±0.08% (96 runs sampled)\nGYP Binding (secp256k1): \nPure JS (elliptic) x 548 ops/sec ±0.34% (95 runs sampled)\nVerify: fastest is Secp256k1 WASM (current)\n```\n\n# License\n\nMIT\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsc0vu%2Fjs-secp256k1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsc0vu%2Fjs-secp256k1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsc0vu%2Fjs-secp256k1/lists"}