github.com/status-im/status-go@v1.1.0/protocol/encryption/README.md (about) 1 # protocol/encryption package 2 3 ## Hash ratchet encryption 4 `encryptor.GenerateHashRatchetKey()` generates a hash ratchet key and stores it in in the DB. 5 There, 2 new tables are created: `hash_ratchet_encryption` and `hash_ratchet_encryption_cache`. 6 Each hash ratchet key is uniquely identified by the `(groupId, keyId)` pair, where `keyId` is derived from a clock value. 7 8 `protocol.BuildHashRatchetKeyExchangeMessage` builds an 1-on-1 message containing the hash ratchet key, given it's ID. 9 10 `protocol.BuildHashRatchetMessage` builds a hash ratchet message with arbitrary payload, given `groupId`. It will use the latest hash ratchet key available. `encryptor.encryptWithHR` encrypts the payload using Hash Ratchet algorithms. Intermediate hashes are stored in `hash_ratchet_encryption_cache` table. 11 12 `protocol.HandleMessage` uses `encryptor.decryptWithHR` fn for decryption.