Closed kasperisager closed 2 years ago
This looks GREAT! Good job @kasperisager
Some minor things:
.core.tree.fork
(it's actually much smaller than 8 bytes, but it should have fixed size, so 8 is def more than enough, we can discuss if 4 bytes is fine also). With the stored fork id a valid nonce is fork-id + block-seq + zero-padding.Summoning @chm-diederichs in case I'm saying silly things
Looking really good, added some comments and will review the encryption itself next.
@kasperisager i think we should subarray the padding out also when blocks are emitted in the download event (also in index.js), wdyt?
10.0.0-alpha.7
This PR introduces optional encryption of Hypercores by means of a new
encryptionKey
option in theHypercore
constructor. When an encryption key is supplied, every block written to the Hypercore is encrypted using the XSalsa20 cipher (https://doc.libsodium.org/advanced/stream_ciphers/xsalsa20) with a ~random~ 192 bit nonce ~that~ of which 64 bits is prepended to the block and the remaining bits inferred from the core. To account for the additional bytes prepended to every block, theByteSeeker
class can now be supplied with apadding
argument so that Merkle tree seeks work as expected.