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

@libp2p/crypto

Package Overview
Dependencies
Maintainers
6
Versions
530
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/crypto - npm Package Compare versions

Comparing version 5.0.5-75301ac7d to 5.0.5-a657bbd2e

40

dist/src/keys/rsa/utils.js

@@ -21,10 +21,10 @@ import { InvalidParametersError, InvalidPublicKeyError } from '@libp2p/interface';

const key = {
n: uint8ArrayToString(bnToBuf(values[1].toBigInt()), 'base64url'),
e: uint8ArrayToString(bnToBuf(values[2].toBigInt()), 'base64url'),
d: uint8ArrayToString(bnToBuf(values[3].toBigInt()), 'base64url'),
p: uint8ArrayToString(bnToBuf(values[4].toBigInt()), 'base64url'),
q: uint8ArrayToString(bnToBuf(values[5].toBigInt()), 'base64url'),
dp: uint8ArrayToString(bnToBuf(values[6].toBigInt()), 'base64url'),
dq: uint8ArrayToString(bnToBuf(values[7].toBigInt()), 'base64url'),
qi: uint8ArrayToString(bnToBuf(values[8].toBigInt()), 'base64url'),
n: asn1jsIntegerToBase64(values[1]),
e: asn1jsIntegerToBase64(values[2]),
d: asn1jsIntegerToBase64(values[3]),
p: asn1jsIntegerToBase64(values[4]),
q: asn1jsIntegerToBase64(values[5]),
dp: asn1jsIntegerToBase64(values[6]),
dq: asn1jsIntegerToBase64(values[7]),
qi: asn1jsIntegerToBase64(values[8]),
kty: 'RSA',

@@ -68,4 +68,4 @@ alg: 'RS256'

kty: 'RSA',
n: uint8ArrayToString(bnToBuf(values[0].toBigInt()), 'base64url'),
e: uint8ArrayToString(bnToBuf(values[1].toBigInt()), 'base64url')
n: asn1jsIntegerToBase64(values[0]),
e: asn1jsIntegerToBase64(values[1])
};

@@ -106,17 +106,9 @@ }

}
function bnToBuf(bn) {
let hex = bn.toString(16);
if (hex.length % 2 > 0) {
hex = `0${hex}`;
function asn1jsIntegerToBase64(int) {
let buf = int.valueBlock.valueHexView;
// chrome rejects values with leading 0s
while (buf[0] === 0) {
buf = buf.subarray(1);
}
const len = hex.length / 2;
const u8 = new Uint8Array(len);
let i = 0;
let j = 0;
while (i < len) {
u8[i] = parseInt(hex.slice(j, j + 2), 16);
i += 1;
j += 2;
}
return u8;
return uint8ArrayToString(buf, 'base64url');
}

@@ -123,0 +115,0 @@ function bufToBn(u8) {

4

package.json
{
"name": "@libp2p/crypto",
"version": "5.0.5-75301ac7d",
"version": "5.0.5-a657bbd2e",
"description": "Crypto primitives for libp2p",

@@ -95,3 +95,3 @@ "license": "Apache-2.0 OR MIT",

"dependencies": {
"@libp2p/interface": "2.1.3-75301ac7d",
"@libp2p/interface": "2.1.3-a657bbd2e",
"@noble/curves": "^1.4.0",

@@ -98,0 +98,0 @@ "@noble/hashes": "^1.4.0",

@@ -27,10 +27,10 @@ import { InvalidParametersError, InvalidPublicKeyError } from '@libp2p/interface'

const key = {
n: uint8ArrayToString(bnToBuf(values[1].toBigInt()), 'base64url'),
e: uint8ArrayToString(bnToBuf(values[2].toBigInt()), 'base64url'),
d: uint8ArrayToString(bnToBuf(values[3].toBigInt()), 'base64url'),
p: uint8ArrayToString(bnToBuf(values[4].toBigInt()), 'base64url'),
q: uint8ArrayToString(bnToBuf(values[5].toBigInt()), 'base64url'),
dp: uint8ArrayToString(bnToBuf(values[6].toBigInt()), 'base64url'),
dq: uint8ArrayToString(bnToBuf(values[7].toBigInt()), 'base64url'),
qi: uint8ArrayToString(bnToBuf(values[8].toBigInt()), 'base64url'),
n: asn1jsIntegerToBase64(values[1]),
e: asn1jsIntegerToBase64(values[2]),
d: asn1jsIntegerToBase64(values[3]),
p: asn1jsIntegerToBase64(values[4]),
q: asn1jsIntegerToBase64(values[5]),
dp: asn1jsIntegerToBase64(values[6]),
dq: asn1jsIntegerToBase64(values[7]),
qi: asn1jsIntegerToBase64(values[8]),
kty: 'RSA',

@@ -82,4 +82,4 @@ alg: 'RS256'

kty: 'RSA',
n: uint8ArrayToString(bnToBuf(values[0].toBigInt()), 'base64url'),
e: uint8ArrayToString(bnToBuf(values[1].toBigInt()), 'base64url')
n: asn1jsIntegerToBase64(values[0]),
e: asn1jsIntegerToBase64(values[1])
}

@@ -125,22 +125,11 @@ }

function bnToBuf (bn: bigint): Uint8Array {
let hex = bn.toString(16)
function asn1jsIntegerToBase64 (int: asn1js.Integer): string {
let buf = int.valueBlock.valueHexView
if (hex.length % 2 > 0) {
hex = `0${hex}`
// chrome rejects values with leading 0s
while (buf[0] === 0) {
buf = buf.subarray(1)
}
const len = hex.length / 2
const u8 = new Uint8Array(len)
let i = 0
let j = 0
while (i < len) {
u8[i] = parseInt(hex.slice(j, j + 2), 16)
i += 1
j += 2
}
return u8
return uint8ArrayToString(buf, 'base64url')
}

@@ -147,0 +136,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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