Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

noble-secp256k1

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

noble-secp256k1 - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

39

index.js

@@ -368,3 +368,3 @@ "use strict";

if (typeof hex !== 'string' && !(hex instanceof Uint8Array)) {
throw new TypeError(`Invalid signature. Expected string or Uint8Array`);
throw new TypeError(`Signature.fromHex: Expected string or Uint8Array`);
}

@@ -378,14 +378,28 @@ const str = hex instanceof Uint8Array ? bytesToHex(hex) : hex;

const rEnd = 8 + rLen;
const r = hexToNumber(str.slice(8, rEnd));
const check3 = str.slice(rEnd, rEnd + 2);
if (check3 !== '02') {
throw new Error('Signature.fromHex: Invalid signature');
const rr = str.slice(8, rEnd);
if (rr.startsWith('00') && parseByte(rr.slice(2, 4)) <= 0x7f) {
throw new Error('Signature.fromHex: Invalid r with trailing length');
}
const r = hexToNumber(rr);
const separator = str.slice(rEnd, rEnd + 2);
if (separator !== '02') {
throw new Error('Signature.fromHex: Invalid r-s separator');
}
const sLen = parseByte(str.slice(rEnd + 2, rEnd + 4));
const diff = length - sLen - rLen - 10;
if (diff > 0 || diff === -4) {
throw new Error(`Signature.fromHex: Invalid total length`);
}
if (sLen > length - rLen - 4) {
throw new Error(`Signature.fromHex: Invalid s`);
}
const sStart = rEnd + 4;
const s = hexToNumber(str.slice(sStart, sStart + sLen));
const ss = str.slice(sStart, sStart + sLen);
if (ss.startsWith('00') && parseByte(ss.slice(2, 4)) <= 0x7f) {
throw new Error(`Signature.fromHex: Invalid s with trailing length`);
}
const s = hexToNumber(ss);
return new Signature(r, s);
}
assertValidity() {
const { n } = CURVE;
const { r, s } = this;

@@ -716,6 +730,9 @@ if (!isWithinCurveOrder(r))

const s1 = invert(s, n);
const Ghs1 = JacobianPoint.BASE.multiply(mod(h * s1, n));
const Prs1 = pubKey.multiplyUnsafe(mod(r * s1, n));
const res = Ghs1.add(Prs1).toAffine();
return res.x === r;
const u1 = mod(h * s1, n);
const u2 = mod(r * s1, n);
const Ghs1 = JacobianPoint.BASE.multiply(u1);
const Prs1 = pubKey.multiplyUnsafe(u2);
const R = Ghs1.add(Prs1).toAffine();
const v = mod(R.x, n);
return v === r;
}

@@ -722,0 +739,0 @@ exports.verify = verify;

{
"name": "noble-secp256k1",
"version": "1.2.2",
"version": "1.2.3",
"description": "Fastest JS implementation of secp256k1. Zero-dependency, high-security, audited ECDSA & Schnorr",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc