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
574
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 2.0.1 to 2.0.2-123ded59

6

dist/src/keys/ed25519-browser.js

@@ -1,2 +0,2 @@

import * as ed from '@noble/ed25519';
import { ed25519 as ed } from '@noble/curves/ed25519';
const PUBLIC_KEY_BYTE_LENGTH = 32;

@@ -10,3 +10,3 @@ const PRIVATE_KEY_BYTE_LENGTH = 64; // private key is actually 32 bytes but for historical reasons we concat private and public keys

const privateKeyRaw = ed.utils.randomPrivateKey();
const publicKey = await ed.getPublicKey(privateKeyRaw);
const publicKey = ed.getPublicKey(privateKeyRaw);
// concatenated the public key to the private key

@@ -31,3 +31,3 @@ const privateKey = concatKeys(privateKeyRaw, publicKey);

const privateKeyRaw = seed;
const publicKey = await ed.getPublicKey(privateKeyRaw);
const publicKey = ed.getPublicKey(privateKeyRaw);
const privateKey = concatKeys(privateKeyRaw, publicKey);

@@ -34,0 +34,0 @@ return {

import { CodeError } from '@libp2p/interface/errors';
import * as secp from '@noble/secp256k1';
import { secp256k1 as secp } from '@noble/curves/secp256k1';
import { sha256 } from 'multiformats/hashes/sha2';

@@ -15,3 +15,4 @@ const PRIVATE_KEY_BYTE_LENGTH = 32;

try {
return await secp.sign(digest, key);
const signature = secp.sign(digest, key);
return signature.toDERRawBytes();
}

@@ -35,7 +36,7 @@ catch (err) {

export function compressPublicKey(key) {
const point = secp.Point.fromHex(key).toRawBytes(true);
const point = secp.ProjectivePoint.fromHex(key).toRawBytes(true);
return point;
}
export function decompressPublicKey(key) {
const point = secp.Point.fromHex(key).toRawBytes(false);
const point = secp.ProjectivePoint.fromHex(key).toRawBytes(false);
return point;

@@ -53,3 +54,3 @@ }

try {
secp.Point.fromHex(key);
secp.ProjectivePoint.fromHex(key);
}

@@ -56,0 +57,0 @@ catch (err) {

import { CodeError } from '@libp2p/interface/errors';
import { utils } from '@noble/secp256k1';
import { randomBytes as randB } from '@noble/hashes/utils';
export default function randomBytes(length) {

@@ -7,4 +7,4 @@ if (isNaN(length) || length <= 0) {

}
return utils.randomBytes(length);
return randB(length);
}
//# sourceMappingURL=random-bytes.js.map
{
"name": "@libp2p/crypto",
"version": "2.0.1",
"version": "2.0.2-123ded59",
"description": "Crypto primitives for libp2p",

@@ -88,5 +88,5 @@ "license": "Apache-2.0 OR MIT",

"dependencies": {
"@libp2p/interface": "^0.1.0",
"@noble/ed25519": "^1.6.0",
"@noble/secp256k1": "^1.5.4",
"@libp2p/interface": "0.1.1-123ded59",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",
"multiformats": "^12.0.1",

@@ -93,0 +93,0 @@ "node-forge": "^1.1.0",

@@ -1,2 +0,2 @@

import * as ed from '@noble/ed25519'
import { ed25519 as ed } from '@noble/curves/ed25519'
import type { Uint8ArrayKeyPair } from './interface'

@@ -14,3 +14,3 @@

const privateKeyRaw = ed.utils.randomPrivateKey()
const publicKey = await ed.getPublicKey(privateKeyRaw)
const publicKey = ed.getPublicKey(privateKeyRaw)

@@ -38,3 +38,3 @@ // concatenated the public key to the private key

const privateKeyRaw = seed
const publicKey = await ed.getPublicKey(privateKeyRaw)
const publicKey = ed.getPublicKey(privateKeyRaw)

@@ -41,0 +41,0 @@ const privateKey = concatKeys(privateKeyRaw, publicKey)

import { CodeError } from '@libp2p/interface/errors'
import * as secp from '@noble/secp256k1'
import { secp256k1 as secp } from '@noble/curves/secp256k1'
import { sha256 } from 'multiformats/hashes/sha2'

@@ -19,3 +19,4 @@

try {
return await secp.sign(digest, key)
const signature = secp.sign(digest, key)
return signature.toDERRawBytes()
} catch (err) {

@@ -39,3 +40,3 @@ throw new CodeError(String(err), 'ERR_INVALID_INPUT')

export function compressPublicKey (key: Uint8Array): Uint8Array {
const point = secp.Point.fromHex(key).toRawBytes(true)
const point = secp.ProjectivePoint.fromHex(key).toRawBytes(true)
return point

@@ -45,3 +46,3 @@ }

export function decompressPublicKey (key: Uint8Array): Uint8Array {
const point = secp.Point.fromHex(key).toRawBytes(false)
const point = secp.ProjectivePoint.fromHex(key).toRawBytes(false)
return point

@@ -60,3 +61,3 @@ }

try {
secp.Point.fromHex(key)
secp.ProjectivePoint.fromHex(key)
} catch (err) {

@@ -63,0 +64,0 @@ throw new CodeError(String(err), 'ERR_INVALID_PUBLIC_KEY')

import { CodeError } from '@libp2p/interface/errors'
import { utils } from '@noble/secp256k1'
import { randomBytes as randB } from '@noble/hashes/utils'

@@ -8,3 +8,3 @@ export default function randomBytes (length: number): Uint8Array {

}
return utils.randomBytes(length)
return randB(length)
}

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

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