hypercore 10.26.3 → 10.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,7 +16,11 @@ module.exports = class BlockEncryption {
16
16
  this.compat = compat
17
17
  this.isBlockKey = isBlockKey
18
18
 
19
- if (!isBlockKey) sodium.crypto_generichash_batch(this.blockKey, compat ? [encryptionKey] : [BLOCK_ENCRYPTION, encryptionKey], hypercoreKey)
19
+ if (!isBlockKey) {
20
+ if (compat) sodium.crypto_generichash_batch(this.blockKey, [encryptionKey], hypercoreKey)
21
+ else sodium.crypto_generichash_batch(this.blockKey, [BLOCK_ENCRYPTION, hypercoreKey, encryptionKey])
22
+ }
23
+
20
24
  sodium.crypto_generichash(this.blindingKey, this.blockKey)
21
25
  }
22
26
 
package/lib/manifest.js CHANGED
@@ -144,6 +144,7 @@ function createManifest (inp) {
144
144
  if (!inp) return null
145
145
 
146
146
  const manifest = {
147
+ encrypted: !!inp.encrypted,
147
148
  hash: 'blake2b',
148
149
  static: null,
149
150
  signer: null,
@@ -197,6 +198,7 @@ function validateSigner (signer) {
197
198
 
198
199
  function defaultSignerManifest (publicKey) {
199
200
  return {
201
+ encrypted: false,
200
202
  hash: 'blake2b',
201
203
  static: null,
202
204
  signer: {
package/lib/messages.js CHANGED
@@ -89,6 +89,7 @@ const multipleSigners = {
89
89
  const manifest = exports.manifest = {
90
90
  preencode (state, m) {
91
91
  c.uint.preencode(state, 0) // version
92
+ c.uint.preencode(state, 0) // flags
92
93
  hashes.preencode(state, m.hash)
93
94
  c.uint.preencode(state, 2) // type
94
95
 
@@ -106,6 +107,7 @@ const manifest = exports.manifest = {
106
107
  },
107
108
  encode (state, m) {
108
109
  c.uint.encode(state, 0) // version
110
+ c.uint.encode(state, m.encrypted ? 1 : 0)
109
111
  hashes.encode(state, m.hash)
110
112
  c.uint.encode(state, m.signer ? 1 : m.multipleSigners ? 2 : 0)
111
113
 
@@ -125,12 +127,14 @@ const manifest = exports.manifest = {
125
127
  const version = c.uint.decode(state)
126
128
  if (version !== 0) throw new Error('Invalid version: ' + version)
127
129
 
130
+ const flags = c.uint.decode(state)
128
131
  const hash = hashes.decode(state)
129
132
  const type = c.uint.decode(state)
130
133
 
131
134
  if (type > 2) throw new Error('Unknown type: ' + type)
132
135
 
133
136
  return {
137
+ encrypted: (flags & 1) !== 0,
134
138
  hash,
135
139
  static: type === 0 ? c.fixed32.decode(state) : null,
136
140
  signer: type === 1 ? signer.decode(state) : null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.26.3",
3
+ "version": "10.27.0",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {