Skip to content

Hypercore encrypt enables block encryption for Hypercore v10 with authenticated encryption keys.

License

Notifications You must be signed in to change notification settings

Telios-org/hypercore-encrypt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hypercore-encrypt

Hypercore encrypt enables block encryption for Hypercore v10 with authenticated encryption keys.

npm i hypercore-encrypt

Build Status

Usage

const Hypercore = require('hypercore-encrypt')

const feed = new Hypercore('./my-encrypted-dataset', null, { 
  encryptionKey: key, 
  valueEncoding: 'json',
  skipFirstBlock: false // remove this option if the feed is being used in something like Hyperbee
})

await feed.ready()

feed.append('hello world')
feed.get(0, console.log) // decrypts block 0 and prints hello world

API

const feed = new Hypercore(storage, [key], [options])

Hypercore-encrypt mimics Hypercore v10's API except an encryption key can be passed into the options to encrypt and decipher blocks.

{
  encryptionKey: key, // All blocks will be encrypted and deciphered with this AEAD key
  skipFirstBlock: true // Skip encrypting the header block when using this in conjunction with something like Hyperbee
}
// Initializing a new feed without an encryption key will automatically generate a new one
const feed = new Hypercore('./my-encrypted-dataset', null, { valueEncoding: 'json' })

const key = feed.encryptionKey.tostring('hex')

// Initialize a new feed with an existing key
const feed = new Hypercore('./cloned-encrypted-dataset', feed.key, { encryptionKey: key, valueEncoding: 'json' })

License

MIT

About

Hypercore encrypt enables block encryption for Hypercore v10 with authenticated encryption keys.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published