New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ed25519-keygen

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ed25519-keygen - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

1

esm/ssh.js

@@ -50,2 +50,3 @@ import * as ed25519 from '@noble/ed25519';

return {
publicKeyBytes: pubKey,
publicKey: formatPublicKey(pubKey, comment),

@@ -52,0 +53,0 @@ fingerprint: getFingerprint(pubKey),

26

esm/tor.js

@@ -6,24 +6,26 @@ import * as ed25519 from '@noble/ed25519';

const ADDRESS_VERSION = new Uint8Array([0x03]);
export async function formatPublicKey(pubBytes) {
export function formatPublicKey(pubBytes) {
const checksum = sha3_256(concatBytes(utf8.decode('.onion checksum'), pubBytes, ADDRESS_VERSION));
return `${base32
.encode(concatBytes(pubBytes, checksum.slice(0, 2), ADDRESS_VERSION))
.toLowerCase()}.onion`;
const addr = concatBytes(pubBytes, checksum.slice(0, 2), ADDRESS_VERSION);
return `${base32.encode(addr).toLowerCase()}.onion`;
}
export async function parseAddress(address) {
let addr = base32.decode(address.replace('.onion', '').toUpperCase());
addr = addr.slice(0, addr.length - 3);
const key = await formatPublicKey(addr);
export function parseAddress(address) {
if (!address.endsWith('.onion'))
throw new Error('Address must end with .onion');
const addr = base32.decode(address.replace(/\.onion$/, '').toUpperCase());
const skip = addr.slice(0, addr.length - 3);
const key = formatPublicKey(skip);
if (key !== address)
throw new Error('Invalid checksum');
return addr;
return skip;
}
export async function getKeys(seed) {
const { head, prefix, pointBytes } = await ed25519.utils.getExtendedPublicKey(seed);
const bytes = concatBytes(head, prefix);
const added = concatBytes(head, prefix);
return {
publicKey: await formatPublicKey(pointBytes),
privateKey: `ED25519-V3:${base64.encode(bytes)}`,
publicKeyBytes: pointBytes,
publicKey: formatPublicKey(pointBytes),
privateKey: `ED25519-V3:${base64.encode(added)}`,
};
}
export default getKeys;
{
"name": "ed25519-keygen",
"version": "0.1.2",
"version": "0.2.0",
"description": "Generate ed25519 keys deterministically for SSH, PGP (GPG) and TOR",

@@ -20,3 +20,3 @@ "files": [

"scripts": {
"build": "tsc -d && tsc -p tsconfig.esm.json",
"build": "tsc && tsc -p tsconfig.esm.json",
"lint": "prettier --check index.ts",

@@ -33,3 +33,3 @@ "test": "node test/index.js"

"dependencies": {
"@noble/ed25519": "~1.5.2",
"@noble/ed25519": "^1.6.1",
"@noble/hashes": "^1.1.2",

@@ -36,0 +36,0 @@ "@scure/base": "~1.1.0",

@@ -31,3 +31,3 @@ # ed25519-keygen

- `username: string`
- Returns `{ fingerprint: string, privateKey: string, publicKey: string }`
- Returns `{ fingerprint: string, privateKey: string, publicKey: string, publicKeyBytes: Uint8Array }`

@@ -63,3 +63,3 @@ ```js

- `createdAt: number` - (default: 0) timestamp corresponding to key creation time
- Returns `{ keyId: string, privateKey: string, publicKey: string }`
- Returns `{ keyId: string, privateKey: string, publicKey: string, publicKeyBytes: Uint8Array }`

@@ -133,3 +133,3 @@ Creates keys compatible with GPG. GPG is a commonly known utility that supports PGP protocol. Quirks:

- `seed: Uint8Array`
- Returns `{ privateKey: string, publicKey: string }`
- Returns `{ privateKey: string, publicKey: string, publicKeyBytes: Uint8Array }`

@@ -136,0 +136,0 @@ ```js

@@ -37,2 +37,3 @@ import * as P from 'micro-packed';

export declare function getKeys(privateKey: Uint8Array, comment?: string, checkBytes?: Uint8Array): Promise<{
publicKeyBytes: Uint8Array;
publicKey: string;

@@ -39,0 +40,0 @@ fingerprint: string;

@@ -55,2 +55,3 @@ "use strict";

return {
publicKeyBytes: pubKey,
publicKey: formatPublicKey(pubKey, comment),

@@ -57,0 +58,0 @@ fingerprint: getFingerprint(pubKey),

@@ -1,4 +0,5 @@

export declare function formatPublicKey(pubBytes: Uint8Array): Promise<string>;
export declare function parseAddress(address: string): Promise<Uint8Array>;
export declare function formatPublicKey(pubBytes: Uint8Array): string;
export declare function parseAddress(address: string): Uint8Array;
export declare function getKeys(seed: Uint8Array): Promise<{
publicKeyBytes: Uint8Array;
publicKey: string;

@@ -5,0 +6,0 @@ privateKey: string;

@@ -9,16 +9,17 @@ "use strict";

const ADDRESS_VERSION = new Uint8Array([0x03]);
async function formatPublicKey(pubBytes) {
function formatPublicKey(pubBytes) {
const checksum = (0, sha3_1.sha3_256)((0, micro_packed_1.concatBytes)(base_1.utf8.decode('.onion checksum'), pubBytes, ADDRESS_VERSION));
return `${base_1.base32
.encode((0, micro_packed_1.concatBytes)(pubBytes, checksum.slice(0, 2), ADDRESS_VERSION))
.toLowerCase()}.onion`;
const addr = (0, micro_packed_1.concatBytes)(pubBytes, checksum.slice(0, 2), ADDRESS_VERSION);
return `${base_1.base32.encode(addr).toLowerCase()}.onion`;
}
exports.formatPublicKey = formatPublicKey;
async function parseAddress(address) {
let addr = base_1.base32.decode(address.replace('.onion', '').toUpperCase());
addr = addr.slice(0, addr.length - 3);
const key = await formatPublicKey(addr);
function parseAddress(address) {
if (!address.endsWith('.onion'))
throw new Error('Address must end with .onion');
const addr = base_1.base32.decode(address.replace(/\.onion$/, '').toUpperCase());
const skip = addr.slice(0, addr.length - 3);
const key = formatPublicKey(skip);
if (key !== address)
throw new Error('Invalid checksum');
return addr;
return skip;
}

@@ -28,6 +29,7 @@ exports.parseAddress = parseAddress;

const { head, prefix, pointBytes } = await ed25519.utils.getExtendedPublicKey(seed);
const bytes = (0, micro_packed_1.concatBytes)(head, prefix);
const added = (0, micro_packed_1.concatBytes)(head, prefix);
return {
publicKey: await formatPublicKey(pointBytes),
privateKey: `ED25519-V3:${base_1.base64.encode(bytes)}`,
publicKeyBytes: pointBytes,
publicKey: formatPublicKey(pointBytes),
privateKey: `ED25519-V3:${base_1.base64.encode(added)}`,
};

@@ -34,0 +36,0 @@ }

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