Implemention of encryption encoding for Autobase blind encryption using sodium easy box
npm install blind-encryption-sodiumImplemention of encryption encoding for Autobase blind encryption using sodium easy box
``js
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:
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.
- Value encrypted with an entropy will be decoded with the old entropy automatically
- Old types are no longer needed after upgrade
- Returns if rotated when decrypting. Note: if it was decrypted with a newer entropy, you should encrypt and store to ensure it uses your latest entropy
`js`
const base = new Autobase(store, {
apply,
open,
encryptionKey,
blindEncryption: new BlindEncryptionSodium(newKey, oldKey)
})
Internally, Autobase uses this with encryption-encoding
`js
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