🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

hyperkeys

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperkeys

Node.js library for ed25519 keys management

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

hyperkeys

Node.js library for ed25519 keys management.

npm i hyperkeys

By default it saves the files in ~/.hyperkeys.

Usage

const Hyperkeys = require('hyperkeys')

const hyperkeys = new Hyperkeys()

const seed = hyperkeys.create(name)
const { publicKey, secretKey, seedKey } = hyperkeys.get(name)

hyperkeys.set(name, { publicKey, secretKey, seedKey })

const paths = hyperkeys.exists(name)

hyperkeys.remove(name)

const { keyPairs, knownKeys } = hyperkeys.list()

Hyperkeys.keyTriad() // => { publicKey, secretKey, seedKey }

Dir

const hyperkeys = new Hyperkeys({ dir: '/home/user/.another-folder' })

Global dir

Hyperkeys.dir = '/home/user/.global-folder'

// Now all instances uses that global directory
const hyperkeys1 = new Hyperkeys()

// Setting a specific dir overrides the global
const hyperkeys2 = new Hyperkeys({ dir: '/home/user/.override-folder' })

Create

// Writes the file to disk: ~/.hyperkeys/crst
const seedKey = hyperkeys.create('crst')

If you try to create twice with the same name it will throw an error.

Get

If you have the seedKey then it will return all the keys.
That's because you can derivate the public and secret keys from the seed.

const keys = hyperkeys.get('crst')
// => { publicKey, secretKey, seedKey }

If you only have the publicKey then that's what you'll get.

const keys = hyperkeys.get('friend')
// => { publicKey, secretKey: null, seedKey: null }

Set

You can force to save any key to a specific name.

hyperkeys.set('friend', { publicKey: Buffer<newer public key> })

Another example:

// As previously said, this will save only the seedKey to disk
hyperkeys.create('vm1')

// You can use "get" to retrieve and generate all the corresponding keys
const keys = hyperkeys.get('vm1')

// And force save them
hyperkeys.set('vm1', keys)

// Now you have those files saved:
// publicKey: ~/.hyperkeys/vm1.pub
// secretKey: ~/.hyperkeys/vm1.sec
// seedKey: ~/.hyperkeys/vm1

Exists

It will return the keys filepath linked to the name.

hyperkeys.create('vm2')
const exists = hyperkeys.exists('vm2')
// => { publicKey: null, secretKey: null, seedKey: '/home/user/...' }
// Again, with this we have explicitly all the keys in disk
hyperkeys.create('vm3')
hyperkeys.set('vm3', hyperkeys.get('vm3'))

const exists = hyperkeys.exists('vm3')
// => { publicKey: '/home/user/...', secretKey: '/home/user/...', seedKey: '/home/user/...' }
const exists = hyperkeys.exists('non-existent')
// => { publicKey: null, secretKey: null, seedKey: null }

Remove

It will remove all the keys, be it publicKey, secretKey and/or seedKey.

hyperkeys.remove('vm1')

List

keyPairs are the keys where you have the seedKey or the combination of publicKey and secretKey.
knownKeys are the keys where you don't have either the secretKey and seedKey.\

const { keyPairs, knownKeys } = hyperkeys.list()
// keyPairs => [{ name, publicKey, secretKey, seedKey }, ...]
// knownKeys => [{ name, publicKey, secretKey: null, seedKey: null }, ...]

Note: If you only have the secretKey file (.sec) it will not show up on the list.
It may be possible to derive the publicKey from the secretKey but not done for now.

keyTriad (static)

const keyTriad = Hyperkeys.keyTriad()
// => { publicKey, secretKey, seedKey }

keyPair (static)

const keyPair = Hyperkeys.keyPair()
// => { publicKey, secretKey }

seed (static)

const seed = Hyperkeys.seed()
// => Buffer<32 random bytes>

License

MIT

FAQs

Package last updated on 27 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts