diff --git a/README.md b/README.md index 3d04944..606a585 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ You can find more advanced topics in our [docs](https://github.com/orbitdb/orbit - [Connecting Peers](https://github.com/orbitdb/orbitdb/blob/main/docs/CONNECTING_PEERS.md) - [Replication](https://github.com/orbitdb/orbitdb/blob/main/docs/REPLICATION.md) - [Oplog](https://github.com/orbitdb/orbitdb/blob/main/docs/OPLOG.md) +- [Encryption](https://github.com/orbitdb/orbitdb/blob/main/docs/ENCRYPTION.md) ### API diff --git a/docs/ENCRYPTION.md b/docs/ENCRYPTION.md index f83d610..179289d 100644 --- a/docs/ENCRYPTION.md +++ b/docs/ENCRYPTION.md @@ -2,9 +2,41 @@ OrbitDB features a modular architecture for database encryption. By passing a module to an OrbitDB database, different encryption methods can be employed. +## How it works + +OrbitDB encrypts records two ways; encrypting the payload and encrypting the log entry. + +Log entry encryption only encrypts the value of the payload. Payload encryption encrypts the entire payload, which includes the value, codec and hasher. + +## Configuring encryption + +You can configure OrbitDB to encrypt either the entry being stored or the entire block being replicated. + +To encrypt data only, specify an encryption module and pass it to the encryption object using the `data` variable: + +``` +const data = await EncryptionModule() +const encryption = { data } +``` + +To encrypt data only, specify an encryption module and pass it to the encryption object using the `replication` variable: + +``` +const replication = await EncryptionModule() +const encryption = { replication } +``` + ## Encrypting Databases -OrbitDB provides a simple password-based encryption module called SimpleEncryption. To implement encryption, initiate SimpleEncryption and pass it when opening your database: +OrbitDB provides an simple password-based encryption module called SimpleEncryption. + +To install SimpleEncryption: + +``` +npm i @orbitdb/simple-encryption +``` + +To implement encryption, initiate SimpleEncryption and pass it when opening your database: ```js import { SimpleEncryption } from '@orbitdb/simple-encryption'