@libp2p/crypto
Advanced tools
Comparing version 0.22.10 to 0.22.11
@@ -9,2 +9,3 @@ import * as keysPBM from './keys.js'; | ||
import * as Secp256k1 from './secp256k1-class.js'; | ||
import type { PrivateKey, PublicKey } from '@libp2p/interfaces/keys'; | ||
export { keyStretcher }; | ||
@@ -18,9 +19,9 @@ export { generateEphemeralKeyPair }; | ||
}; | ||
export declare function generateKeyPair(type: 'RSA' | 'Ed25519' | 'secp256k1', bits?: number): Promise<RSA.RsaPrivateKey | Ed25519.Ed25519PrivateKey | Secp256k1.Secp256k1PrivateKey>; | ||
export declare function generateKeyPairFromSeed(type: 'RSA' | 'Ed25519' | 'secp256k1', seed: Uint8Array, bits?: number): Promise<Ed25519.Ed25519PrivateKey>; | ||
export declare function unmarshalPublicKey(buf: Uint8Array): RSA.RsaPublicKey | Ed25519.Ed25519PublicKey | Secp256k1.Secp256k1PublicKey; | ||
export declare function generateKeyPair(type: 'RSA' | 'Ed25519' | 'secp256k1', bits?: number): Promise<PrivateKey>; | ||
export declare function generateKeyPairFromSeed(type: 'RSA' | 'Ed25519' | 'secp256k1', seed: Uint8Array, bits?: number): Promise<PrivateKey>; | ||
export declare function unmarshalPublicKey(buf: Uint8Array): PublicKey; | ||
export declare function marshalPublicKey(key: { | ||
bytes: Uint8Array; | ||
}, type?: string): Uint8Array; | ||
export declare function unmarshalPrivateKey(buf: Uint8Array): Promise<RSA.RsaPrivateKey | Ed25519.Ed25519PrivateKey | Secp256k1.Secp256k1PrivateKey>; | ||
export declare function unmarshalPrivateKey(buf: Uint8Array): Promise<PrivateKey>; | ||
export declare function marshalPrivateKey(key: { | ||
@@ -34,3 +35,3 @@ bytes: Uint8Array; | ||
*/ | ||
export declare function importKey(encryptedKey: string, password: string): Promise<RSA.RsaPrivateKey | Ed25519.Ed25519PrivateKey | Secp256k1.Secp256k1PrivateKey>; | ||
export declare function importKey(encryptedKey: string, password: string): Promise<PrivateKey>; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@libp2p/crypto", | ||
"version": "0.22.10", | ||
"version": "0.22.11", | ||
"description": "Crypto primitives for libp2p", | ||
@@ -172,2 +172,3 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"@libp2p/interfaces": "^1.3.20", | ||
"@noble/ed25519": "^1.6.0", | ||
@@ -174,0 +175,0 @@ "@noble/secp256k1": "^1.5.4", |
@@ -14,2 +14,3 @@ import * as keysPBM from './keys.js' | ||
import * as Secp256k1 from './secp256k1-class.js' | ||
import type { PrivateKey, PublicKey } from '@libp2p/interfaces/keys' | ||
@@ -42,3 +43,3 @@ export { keyStretcher } | ||
// Generates a keypair of the given type and bitsize | ||
export async function generateKeyPair (type: 'RSA' | 'Ed25519' | 'secp256k1', bits?: number) { // eslint-disable-line require-await | ||
export async function generateKeyPair (type: 'RSA' | 'Ed25519' | 'secp256k1', bits?: number): Promise<PrivateKey> { // eslint-disable-line require-await | ||
return await typeToKey(type).generateKeyPair(bits ?? 2048) | ||
@@ -49,3 +50,3 @@ } | ||
// seed is a 32 byte uint8array | ||
export async function generateKeyPairFromSeed (type: 'RSA' | 'Ed25519' | 'secp256k1', seed: Uint8Array, bits?: number) { // eslint-disable-line require-await | ||
export async function generateKeyPairFromSeed (type: 'RSA' | 'Ed25519' | 'secp256k1', seed: Uint8Array, bits?: number): Promise<PrivateKey> { // eslint-disable-line require-await | ||
if (type.toLowerCase() !== 'ed25519') { | ||
@@ -60,3 +61,3 @@ throw errcode(new Error('Seed key derivation is unimplemented for RSA or secp256k1'), 'ERR_UNSUPPORTED_KEY_DERIVATION_TYPE') | ||
// representative object | ||
export function unmarshalPublicKey (buf: Uint8Array) { | ||
export function unmarshalPublicKey (buf: Uint8Array): PublicKey { | ||
const decoded = keysPBM.PublicKey.decode(buf) | ||
@@ -78,3 +79,3 @@ const data = decoded.Data | ||
// Converts a public key object into a protobuf serialized public key | ||
export function marshalPublicKey (key: { bytes: Uint8Array }, type?: string) { | ||
export function marshalPublicKey (key: { bytes: Uint8Array }, type?: string): Uint8Array { | ||
type = (type ?? 'rsa').toLowerCase() | ||
@@ -87,3 +88,3 @@ typeToKey(type) // check type | ||
// representative object | ||
export async function unmarshalPrivateKey (buf: Uint8Array) { // eslint-disable-line require-await | ||
export async function unmarshalPrivateKey (buf: Uint8Array): Promise<PrivateKey> { // eslint-disable-line require-await | ||
const decoded = keysPBM.PrivateKey.decode(buf) | ||
@@ -105,3 +106,3 @@ const data = decoded.Data | ||
// Converts a private key object into a protobuf serialized private key | ||
export function marshalPrivateKey (key: { bytes: Uint8Array }, type?: string) { | ||
export function marshalPrivateKey (key: { bytes: Uint8Array }, type?: string): Uint8Array { | ||
type = (type ?? 'rsa').toLowerCase() | ||
@@ -117,3 +118,3 @@ typeToKey(type) // check type | ||
*/ | ||
export async function importKey (encryptedKey: string, password: string) { // eslint-disable-line require-await | ||
export async function importKey (encryptedKey: string, password: string): Promise<PrivateKey> { // eslint-disable-line require-await | ||
try { | ||
@@ -120,0 +121,0 @@ const key = await importer(encryptedKey, password) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
203242
3269
9
+ Added@libp2p/interfaces@^1.3.20
+ Added@fastify/busboy@2.1.1(transitive)
+ Added@libp2p/interfaces@1.3.32(transitive)
+ Added@multiformats/multiaddr@10.5.0(transitive)
+ Addedclone-regexp@3.0.0(transitive)
+ Addedconvert-hrtime@5.0.0(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addeddns-over-http-resolver@2.1.3(transitive)
+ Addedfunction-timeout@0.1.1(transitive)
+ Addedinterface-datastore@6.1.1(transitive)
+ Addedinterface-store@2.0.2(transitive)
+ Addedip-regex@5.0.0(transitive)
+ Addedis-ip@5.0.1(transitive)
+ Addedis-regexp@3.1.0(transitive)
+ Addedms@2.1.3(transitive)
+ Addednanoid@3.3.7(transitive)
+ Addednative-fetch@4.0.2(transitive)
+ Addedreceptacle@1.3.2(transitive)
+ Addedsuper-regex@0.2.0(transitive)
+ Addedtime-span@5.1.0(transitive)
+ Addedundici@5.28.4(transitive)
+ Addedvarint@6.0.0(transitive)