🔥 An encrypted, in-memory, key-value store
Uses homomorphic encryption, so the server can’t read data or queries. Powered by HElib and follows the Redis protocol.
Learn how it works.
Designed for research and education, and should not be considered secure. For a more practical approach to key-value store encryption, check out Cloak.
On Mac, run:
brew install ankane/brew/morph --headOn other platforms, build from source.
Generate a key pair
morph-cli keygenStart the server (in another window)
morph-serverSet a key
morph-cli set hello worldNote: Each key should only be set once, or the value will not be recoverable
Get a key
morph-cli get helloSet multiple keys
morph-cli mset key1 hello key2 worldGet multiple keys
morph-cli mget key1 key2Delete all keys
morph-cli flushallGet the number of keys
morph-cli dbsizeList keys
morph-cli keys "*"Get info
morph-cli info- set - O(1)
- get - O(N) where N is the number of keys in the store
- mset - O(N) where N is the number of keys to set
- mget - O(N*M) where N is the number of keys to get and M is the number of keys in the store
- keys - O(N) where N is the number of keys in the store
Create hello.cpp:
#include <iostream>
#include <morph/client.h>
int main() {
auto morph = morph::Client();
morph.flushall();
morph.set("hello", "world");
auto value = morph.get("hello");
std::cout << value.value_or("(nil)") << std::endl;
}Compile:
g++ -std=c++17 hello.cpp -lmorph -lpthread -lhelib -lntl -o helloAnd run:
./helloFirst, install HElib.
On Ubuntu, use:
sudo apt-get install libntl-dev
git clone --branch v2.3.0 https://github.com/homenc/HElib.git
cd HElib
cmake -S . -B build
cmake --build build
sudo cmake --install build
sudo ldconfigOn Mac, use:
brew install helibThen run:
git clone https://github.com/ankane/morph.git
cd morph
cmake -S . -B build
cmake --build build
cmake --install build # optional, may need sudoThanks to IBM for HElib and Redis for the protocol/commands. Based on this example.
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features