{"id":13513565,"url":"https://github.com/ankane/morph","last_synced_at":"2025-11-17T14:22:47.927Z","repository":{"id":66166545,"uuid":"319790648","full_name":"ankane/morph","owner":"ankane","description":"An encrypted, in-memory, key-value store","archived":false,"fork":false,"pushed_at":"2024-01-11T00:17:09.000Z","size":45,"stargazers_count":65,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T15:36:48.745Z","etag":null,"topics":["homomorphic-encryption"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankane.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-12-08T23:49:59.000Z","updated_at":"2025-03-02T22:20:51.000Z","dependencies_parsed_at":"2024-01-13T19:23:36.367Z","dependency_job_id":"93058100-6638-4c13-968b-84441955f80a","html_url":"https://github.com/ankane/morph","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fmorph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fmorph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fmorph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankane%2Fmorph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankane","download_url":"https://codeload.github.com/ankane/morph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251687661,"owners_count":21627612,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["homomorphic-encryption"],"created_at":"2024-08-01T05:00:31.522Z","updated_at":"2025-11-17T14:22:47.915Z","avatar_url":"https://github.com/ankane.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# Morph\n\n:fire: An encrypted, in-memory, key-value store\n\nUses homomorphic encryption, so the server can’t read data or queries. Powered by [HElib](https://github.com/homenc/HElib) and follows the [Redis protocol](https://redis.io/topics/protocol).\n\nLearn [how it works](https://github.com/homenc/HElib/tree/master/examples/BGV_country_db_lookup#country-lookup-example).\n\n*Designed for research and education, and should not be considered secure. For a more practical approach to key-value store encryption, check out [Cloak](https://github.com/ankane/cloak).*\n\n[![Build Status](https://github.com/ankane/morph/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/morph/actions)\n\n## Installation\n\nOn Mac, run:\n\n```sh\nbrew install ankane/brew/morph --head\n```\n\nOn other platforms, [build from source](#building-from-source).\n\n## Getting Started\n\nGenerate a key pair\n\n```sh\nmorph-cli keygen\n```\n\nStart the server (in another window)\n\n```sh\nmorph-server\n```\n\nSet a key\n\n```sh\nmorph-cli set hello world\n```\n\n**Note:** Each key should only be set once, or the value will not be recoverable\n\nGet a key\n\n```sh\nmorph-cli get hello\n```\n\nSet multiple keys\n\n```sh\nmorph-cli mset key1 hello key2 world\n```\n\nGet multiple keys\n\n```sh\nmorph-cli mget key1 key2\n```\n\nDelete all keys\n\n```sh\nmorph-cli flushall\n```\n\nGet the number of keys\n\n```sh\nmorph-cli dbsize\n```\n\nList keys\n\n```sh\nmorph-cli keys \"*\"\n```\n\nGet info\n\n```sh\nmorph-cli info\n```\n\n## Time Complexity\n\n- set - O(1)\n- get - O(N) where N is the number of keys in the store\n- mset - O(N) where N is the number of keys to set\n- mget - O(N*M) where N is the number of keys to get and M is the number of keys in the store\n- keys - O(N) where N is the number of keys in the store\n\n## Clients\n\n- [C++](#c)\n- [Ruby](https://github.com/ankane/morph-ruby)\n\n### C++\n\nCreate `hello.cpp`:\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cmorph/client.h\u003e\n\nint main() {\n  auto morph = morph::Client();\n  morph.flushall();\n  morph.set(\"hello\", \"world\");\n  auto value = morph.get(\"hello\");\n  std::cout \u003c\u003c value.value_or(\"(nil)\") \u003c\u003c std::endl;\n}\n```\n\nCompile:\n\n```sh\ng++ -std=c++17 hello.cpp -lmorph -lpthread -lhelib -lntl -o hello\n```\n\nAnd run:\n\n```sh\n./hello\n```\n\n## Building from Source\n\nFirst, install HElib.\n\nOn Ubuntu, use:\n\n```sh\nsudo apt-get install libntl-dev\ngit clone --branch v2.3.0 https://github.com/homenc/HElib.git\ncd HElib\ncmake -S . -B build\ncmake --build build\nsudo cmake --install build\nsudo ldconfig\n```\n\nOn Mac, use:\n\n```sh\nbrew install helib\n```\n\nThen run:\n\n```sh\ngit clone https://github.com/ankane/morph.git\ncd morph\ncmake -S . -B build\ncmake --build build\ncmake --install build # optional, may need sudo\n```\n\n## Credits\n\nThanks to IBM for HElib and Redis for the protocol/commands. Based on [this example](https://github.com/homenc/HElib/tree/master/examples/BGV_country_db_lookup).\n\n## History\n\nView the [changelog](https://github.com/ankane/morph/blob/master/CHANGELOG.md)\n\n## Contributing\n\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/ankane/morph/issues)\n- Fix bugs and [submit pull requests](https://github.com/ankane/morph/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fmorph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankane%2Fmorph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankane%2Fmorph/lists"}