Installations
npm install libp2p-crypto-secp256k1
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=6.0.0
Node Version
12.16.1
NPM Version
6.14.2
Score
86.1
Supply Chain
98.5
Quality
76.2
Maintenance
100
Vulnerability
85.3
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Download Statistics
Total Downloads
4,082,137
Last Day
1,141
Last Week
9,443
Last Month
49,981
Last Year
393,136
GitHub Statistics
10 Stars
60 Commits
14 Forks
18 Watching
3 Branches
44 Contributors
Package Meta Information
Latest Version
0.4.3
Package Id
libp2p-crypto-secp256k1@0.4.3
Unpacked Size
3.05 MB
Size
1.57 MB
File Count
37
NPM Version
6.14.2
Node Version
12.16.1
Total Downloads
Cumulative downloads
Total Downloads
4,082,137
Last day
-51.7%
1,141
Compared to previous day
Last week
-21.4%
9,443
Compared to previous week
Last month
19.6%
49,981
Compared to previous month
Last year
-32.8%
393,136
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
6
js-libp2p-crypto-secp256k1
Support for secp256k1 keys in js-libp2p-crypto
This repo contains a js-libp2p-crypto-compatible implementation of cryptographic signature generation and verification using the secp256k1 elliptic curve popularized by Bitcoin and other crypto currencies.
Lead Captain
Table of Contents
Install
1npm install --save libp2p-crypto-secp256k1
Usage
This module is designed to work with js-libp2p-crypto.
Installing libp2p-crypto-secp256k1
will automatically add support for the 'secp256k1'
key type, which
can be used as an argument to the libp2p-crypto API functions
generateKeyPair
, unmarshalPublicKey
, and marshalPrivateKey
. The keys returned from those functions will be
instances of the Secp256k1PublicKey
or Secp256k1PrivateKey
classes provided by this module.
Example
1const crypto = require('libp2p-crypto') 2const msg = Buffer.from('Hello World') 3 4const key = await crypto.generateKeyPair('secp256k1', 256) 5// assuming no error, key will be an instance of Secp256k1PrivateKey 6// the public key is available as key.public 7const sig = await key.sign(msg) 8 9const valid = await key.public.verify(msg, sig) 10assert(valid, 'Something went horribly wrong')
API
The functions below are the public API of this module.
For usage within libp2p-crypto
, see the libp2p-crypto
API documentation.
generateKeyPair([bits])
bits: Number
- Optional, included for compatibility with js-libp2p-crypto. Ignored if present; private keys will always be 256 bits.
Returns Promise<Secp256k1PrivateKey>
unmarshalSecp256k1PublicKey(bytes)
bytes: Buffer
Converts a serialized secp256k1 public key into an instance of Secp256k1PublicKey
and returns it
unmarshalSecp256k1PrivateKey(bytes)
bytes: Buffer
Returns Promise<Secp256k1PrivateKey>
Converts a serialized secp256k1 private key into an instance of Secp256k1PrivateKey
.
Secp256k1PublicKey
.verify(data, sig)
data: Buffer
sig: Buffer
Returns Promise<Boolean>
Calculates the SHA-256 hash of data
, and verifies the DER-encoded signature in sig
.
Secp256k1PrivateKey
.public
Accessor for the Secp256k1PublicKey
associated with this private key.
.sign(data)
data: Buffer
Returns Promise<Buffer>
Calculates the SHA-256 hash of data
and signs it, resolves with the DER-encoded signature.
Contribute
Feel free to join in. All welcome. Open an issue!
This repository falls under the IPFS Code of Conduct.
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 9/25 approved changesets -- score normalized to 3
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 14 are checked with a SAST tool
Score
3.4
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More