
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
The bip66 npm package is used for encoding and decoding Bitcoin's BIP66 DER signatures. BIP66 is a Bitcoin Improvement Proposal that enforces strict DER (Distinguished Encoding Rules) encoding for signatures, which helps in improving security and interoperability.
Encoding DER Signatures
This feature allows you to encode 'r' and 's' values into a DER-encoded signature. The 'r' and 's' values are components of an ECDSA signature.
const bip66 = require('bip66');
const r = Buffer.from('...'); // Buffer containing the 'r' value
const s = Buffer.from('...'); // Buffer containing the 's' value
const derSignature = bip66.encode(r, s);
console.log(derSignature);
Decoding DER Signatures
This feature allows you to decode a DER-encoded signature into its 'r' and 's' components. This is useful for verifying or manipulating the signature.
const bip66 = require('bip66');
const derSignature = Buffer.from('...'); // Buffer containing the DER-encoded signature
const { r, s } = bip66.decode(derSignature);
console.log(r, s);
The elliptic package is a comprehensive library for elliptic curve cryptography. It supports various elliptic curve algorithms and provides utilities for encoding and decoding signatures. Compared to bip66, elliptic offers a broader range of cryptographic functionalities beyond just DER encoding and decoding.
The secp256k1 package is a native implementation of the secp256k1 elliptic curve used in Bitcoin. It provides functions for signing, verifying, and manipulating ECDSA signatures. While it includes DER encoding and decoding, it is more focused on performance and low-level cryptographic operations compared to bip66.
The bitcoinjs-lib package is a full-featured library for Bitcoin-related operations, including transaction creation, signing, and verification. It includes utilities for handling DER-encoded signatures as part of its broader functionality. Compared to bip66, bitcoinjs-lib offers a more extensive set of tools for Bitcoin development.
Strict DER signature encoding/decoding.
See bip66.
r
or s
are fully valid.
check
/decode
doesn't check that r
or s
great than 33 bytes or that this number represent valid point on elliptic curve.encode
doesn't check that r
/s
represent valid point on elliptic curve.import * as bip66 from"bip66"
const r = Buffer.from('1ea1fdff81b3a271659df4aad19bc4ef83def389131a36358fe64b245632e777', 'hex')
const s = Buffer.from('29e164658be9ce810921bf81d6b86694785a79ea1e52dbfa5105148d1f0bc1', 'hex')
// Buffer or UInt8Array can be passed in to the encode/decode functions
const signature = bip66.encode(r, s)
// Uint8Array(69) [
// 48, 67, 2, 32, 30, 161, 253, 255, 129, 179, 162,
// 113, 101, 157, 244, 170, 209, 155, 196, 239, 131, 222,
// 243, 137, 19, 26, 54, 53, 143, 230, 75, 36, 86,
// 50, 231, 119, 2, 31, 41, 225, 100, 101, 139, 233,
// 206, 129, 9, 33, 191, 129, 214, 184, 102, 148, 120,
// 90, 121, 234, 30, 82, 219, 250, 81, 5, 20, 141,
// 31, 11, 193
// ]
bip66.decode(signature)
// => {
// r: Uint8Array(32) [
// 30, 161, 253, 255, 129, 179, 162,
// 113, 101, 157, 244, 170, 209, 155,
// 196, 239, 131, 222, 243, 137, 19,
// 26, 54, 53, 143, 230, 75, 36,
// 86, 50, 231, 119
// ],
// s: Uint8Array(31) [
// 41, 225, 100, 101, 139, 233, 206, 129,
// 9, 33, 191, 129, 214, 184, 102, 148,
// 120, 90, 121, 234, 30, 82, 219, 250,
// 81, 5, 20, 141, 31, 11, 193
// ]
// }
A catch-all exception regex:
/Expected DER (integer|sequence)|(R|S) value (excessively padded|is negative)|(R|S|DER sequence) length is (zero|too short|too long|invalid)/
FAQs
Strict DER signature encoding/decoding.
The npm package bip66 receives a total of 219,168 weekly downloads. As such, bip66 popularity was classified as popular.
We found that bip66 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.