$ npm install blind-encryption-sodiumImplemention of encryption encoding for Autobase blind encryption using sodium easy box
const BlindEncryptionSodium = require('blind-encryption-sodium')
const b4a = require('b4a')
const key = b4a.alloc(32) // 32-byte key
const encryption = new BlindEncryptionSodium(key)
const encrypted = await encryption.encrypt(plaintext)
// { value: <Buffer>, type: 1 }
const { value, rotated } = await encryption.decrypt(encrypted)
// if rotated, it was decrypted with a newer type, and you should encrypt and store
Multiple values can be passed in. This enables you to "rotate" entropies.
const base = new Autobase(store, {
apply,
open,
encryptionKey,
blindEncryption: new BlindEncryptionSodium(newKey, oldKey)
})
Internally, Autobase uses this with encryption-encoding
const { encrypt, decrypt } = require('encryption-encoding')
const BlindEncryptionSodium = require('blind-encryption-sodium')
const encryptedAndEncoded = await encrypt(encryptionKey, bes.encrypt.bind(bes))
const decrypted = await decrypt(encryptedAndEncoded, bes.decrypt.bind(bes))
Apache-2.0