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

@libp2p/crypto

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 to 5.0.6-0a3406a05

@@ -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) {

{
"name": "@libp2p/crypto",
"version": "5.0.5",
"version": "5.0.6-0a3406a05",
"description": "Crypto primitives for libp2p",

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

"dependencies": {
"@libp2p/interface": "^2.1.3",
"@libp2p/interface": "2.2.0-0a3406a05",
"@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