You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constHypercoreEncryption=require('hypercore-encryption')constencryption=newHypercoreEncryption({
blindingKey,getBlockKey(id,contexxt){// get key info corresponding to id and context...return{
version,// encryption scheme
padding,// padding byte length
key // block key}}})constcore=newHypercore(storage,{ encryption })awaitcore.ready()awaitcore.append('encrypt with key 1')awaitencryption.load(99)awaitcore.append('encrypt with key 99')
API
const enc = new HypercoreEncryption({ blindingKey, getBlockKey, getBlindingKey })
Instantiate a new encryption provider. Optionally pass a preopen promise that resolves to a key id to be loaded initially.
Provide a hooks with the signature:
functiongetBlockKey(id,context){// context provides information about the core, eg:// context.key// context.manifest// id id is passed as -1, the module expects the key to be updatedreturn{
version,// encryption scheme
padding,// padding byte length
key // block key}}functiongetBlockKey(context){returnblindingKey// 32 byte blinding key}
const padding = enc.padding(context)
The number of padding bytes.
enc.seekable
Boolean on whether the current scheme allows for seeks.
enc.version
The version of the currently loaded scheme.
await enc.load(id, context)
Load the key under id and set to be the current encryption info.