oblivlib 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. oblivlib-0.1.0/LICENSE +191 -0
  2. oblivlib-0.1.0/PKG-INFO +139 -0
  3. oblivlib-0.1.0/README.md +109 -0
  4. oblivlib-0.1.0/pyproject.toml +95 -0
  5. oblivlib-0.1.0/setup.cfg +4 -0
  6. oblivlib-0.1.0/src/oblivlib/__init__.py +127 -0
  7. oblivlib-0.1.0/src/oblivlib/dependency/__init__.py +96 -0
  8. oblivlib-0.1.0/src/oblivlib/dependency/avl_tree.py +14 -0
  9. oblivlib-0.1.0/src/oblivlib/dependency/balls_into_bins.py +25 -0
  10. oblivlib-0.1.0/src/oblivlib/dependency/bplus_tree.py +20 -0
  11. oblivlib-0.1.0/src/oblivlib/dependency/client.py +442 -0
  12. oblivlib-0.1.0/src/oblivlib/dependency/config.py +386 -0
  13. oblivlib-0.1.0/src/oblivlib/dependency/contract.py +87 -0
  14. oblivlib-0.1.0/src/oblivlib/dependency/crypto.py +101 -0
  15. oblivlib-0.1.0/src/oblivlib/dependency/errors.py +46 -0
  16. oblivlib-0.1.0/src/oblivlib/dependency/heap_index.py +62 -0
  17. oblivlib-0.1.0/src/oblivlib/dependency/keyed_store.py +49 -0
  18. oblivlib-0.1.0/src/oblivlib/dependency/layout.py +328 -0
  19. oblivlib-0.1.0/src/oblivlib/dependency/metrics.py +119 -0
  20. oblivlib-0.1.0/src/oblivlib/dependency/path_cipher.py +124 -0
  21. oblivlib-0.1.0/src/oblivlib/dependency/protocol.py +151 -0
  22. oblivlib-0.1.0/src/oblivlib/dependency/server_stores.py +161 -0
  23. oblivlib-0.1.0/src/oblivlib/dependency/storage_server.py +214 -0
  24. oblivlib-0.1.0/src/oblivlib/dependency/transport.py +144 -0
  25. oblivlib-0.1.0/src/oblivlib/dependency/tree_builder.py +138 -0
  26. oblivlib-0.1.0/src/oblivlib/dependency/tree_storage_base.py +186 -0
  27. oblivlib-0.1.0/src/oblivlib/dependency/types.py +41 -0
  28. oblivlib-0.1.0/src/oblivlib/graph/__init__.py +4 -0
  29. oblivlib-0.1.0/src/oblivlib/graph/graphos.py +388 -0
  30. oblivlib-0.1.0/src/oblivlib/graph/grove.py +577 -0
  31. oblivlib-0.1.0/src/oblivlib/graph/meta.py +73 -0
  32. oblivlib-0.1.0/src/oblivlib/omap/__init__.py +6 -0
  33. oblivlib-0.1.0/src/oblivlib/omap/avl_omap.py +492 -0
  34. oblivlib-0.1.0/src/oblivlib/omap/base_omap.py +21 -0
  35. oblivlib-0.1.0/src/oblivlib/omap/bplus_omap.py +430 -0
  36. oblivlib-0.1.0/src/oblivlib/omap/group_omap.py +194 -0
  37. oblivlib-0.1.0/src/oblivlib/omap/oram_ost_omap.py +96 -0
  38. oblivlib-0.1.0/src/oblivlib/omap/ost_base_omap.py +334 -0
  39. oblivlib-0.1.0/src/oblivlib/oram/__init__.py +15 -0
  40. oblivlib-0.1.0/src/oblivlib/oram/counter_oram.py +132 -0
  41. oblivlib-0.1.0/src/oblivlib/oram/da_oram.py +96 -0
  42. oblivlib-0.1.0/src/oblivlib/oram/freecursive_oram.py +153 -0
  43. oblivlib-0.1.0/src/oblivlib/oram/mul_path_oram.py +28 -0
  44. oblivlib-0.1.0/src/oblivlib/oram/path_oram.py +23 -0
  45. oblivlib-0.1.0/src/oblivlib/oram/recursive_path_oram.py +129 -0
  46. oblivlib-0.1.0/src/oblivlib/oram/static_oram.py +24 -0
  47. oblivlib-0.1.0/src/oblivlib/oram/tree_base_oram.py +156 -0
  48. oblivlib-0.1.0/src/oblivlib/py.typed +0 -0
  49. oblivlib-0.1.0/src/oblivlib.egg-info/PKG-INFO +139 -0
  50. oblivlib-0.1.0/src/oblivlib.egg-info/SOURCES.txt +51 -0
  51. oblivlib-0.1.0/src/oblivlib.egg-info/dependency_links.txt +1 -0
  52. oblivlib-0.1.0/src/oblivlib.egg-info/requires.txt +3 -0
  53. oblivlib-0.1.0/src/oblivlib.egg-info/top_level.txt +1 -0
oblivlib-0.1.0/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 Weiqi Feng
179
+ Copyright 2024 Xinle Cao
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: oblivlib
3
+ Version: 0.1.0
4
+ Summary: A Python library of oblivious data structures and algorithms.
5
+ Author-email: Weiqi Feng <weltch1997@gmail.com>, Xinle Cao <xinlecao72@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/WeiqiNs/OblivLib
8
+ Project-URL: Repository, https://github.com/WeiqiNs/OblivLib
9
+ Project-URL: Issues, https://github.com/WeiqiNs/OblivLib/issues
10
+ Keywords: oram,omap,oblivious,oblivious-ram,oblivious-map,oblivious-data-structures,cryptography,privacy,security
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
20
+ Classifier: Topic :: Security :: Cryptography
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.12
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: cryptography>=45.0.0
27
+ Requires-Dist: msgspec>=0.22.0
28
+ Requires-Dist: pyzmq>=26.0.0
29
+ Dynamic: license-file
30
+
31
+ # OblivLib
32
+
33
+ [![OblivLib CI](https://github.com/WeiqiNs/OblivLib/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/WeiqiNs/OblivLib/actions/workflows/ci.yml)
34
+ [![codecov](https://codecov.io/gh/WeiqiNs/OblivLib/graph/badge.svg)](https://codecov.io/gh/WeiqiNs/OblivLib)
35
+
36
+ OblivLib implements oblivious RAM, oblivious maps and oblivious graphs for a client/server setting: the
37
+ client holds the keys and runs the algorithm, and the server only stores encrypted data.
38
+
39
+ ## Schemes
40
+
41
+ | Kind | Scheme | Class |
42
+ |---|---|---|
43
+ | ORAM | [Path ORAM](https://doi.org/10.1145/2508859.2516660) | `PathOram` |
44
+ | | [Recursive Path ORAM](https://doi.org/10.1007/978-3-642-25385-0_11) | `RecursivePathOram` |
45
+ | | [Freecursive ORAM](https://doi.org/10.1145/2694344.2694353), with [probabilistic resets](https://eprint.iacr.org/2016/1084) by default | `FreecursiveOram` |
46
+ | | [DAORAM](https://doi.org/10.14778/3712221.3712235) | `DAOram` |
47
+ | | Multi-path Path ORAM | `MulPathOram` |
48
+ | | Static Path ORAM (PRF-positioned; reveals repeated accesses, a building block) | `StaticOram` |
49
+ | OMAP | [AVL-tree OMAP](https://doi.org/10.1145/2660267.2660314) | `AVLOmap` |
50
+ | | [B+-tree OMAP](https://doi.org/10.14778/3364324.3364331) | `BPlusOmap` |
51
+ | | [ORAM + search tree](https://doi.org/10.14778/3712221.3712235) | `OramOstOmap` |
52
+ | | Group-by-hash OMAP | `GroupOmap` |
53
+ | Graph | [GraphOS](https://www.vldb.org/pvldb/vol16/p4324-chamani.pdf) | `GraphOS` |
54
+ | | [Grove](https://www.vldb.org/pvldb/vol19/p1826-cao.pdf) | `Grove` |
55
+
56
+ ## Installation
57
+
58
+ Requires Python 3.12 or later.
59
+
60
+ ```bash
61
+ pip install oblivlib
62
+ ```
63
+
64
+ For development: `pip install -e . --group dev`, then `pytest --cov` (the suite requires 100% line and
65
+ branch coverage).
66
+
67
+ ## Usage
68
+
69
+ Everything is imported from `oblivlib`. Every scheme is built from its config (`PathOramConfig`,
70
+ `AvlOmapConfig`, `GroveConfig`, ...). A config sets the size (`num_data`, `data_size`, and `key_size` for maps), the
71
+ `client` that reaches the server, and optionally an `encryptor` and tuning options. Invalid settings raise
72
+ when the config is created.
73
+
74
+ ```python
75
+ from oblivlib import AesGcm, AVLOmap, AvlOmapConfig, Client, PathOram, PathOramConfig
76
+
77
+ with Client.local() as client:
78
+ oram = PathOram(PathOramConfig(num_data=1024, data_size=16, client=client, encryptor=AesGcm()))
79
+ oram.init_server_storage()
80
+ oram.operate_on_key(3, b"hello")
81
+ assert oram.operate_on_key(3) == b"hello"
82
+
83
+ omap = AVLOmap(AvlOmapConfig(num_data=1024, key_size=16, data_size=16, client=client, encryptor=AesGcm()))
84
+ omap.init_server_storage()
85
+ omap.insert(b"alice", b"42")
86
+ assert omap.search(b"alice") == b"42"
87
+ ```
88
+
89
+ Keys and values are bytes (ORAM keys are ints in `[0, num_data)`, graph vertices are ints); anything outside
90
+ a scheme's limits raises `ContractError` before the server is touched.
91
+
92
+ `Client.local()` runs the server in the same process. For a real deployment, run a server and connect to it.
93
+ The server has no authentication, so bind it to a trusted network or put it behind an authenticated tunnel:
94
+
95
+ ```python
96
+ from oblivlib import StorageServer, ZmqListener, serve
97
+
98
+ serve(ZmqListener("tcp://*:5555"), StorageServer(storage_dir="/var/lib/oblivlib"))
99
+ ```
100
+
101
+ ```python
102
+ client = Client.connect("tcp://server-host:5555")
103
+ ```
104
+
105
+ Runnable versions are in [`demo/`](demo): `python demo/server.py`, then `python demo/client.py`.
106
+
107
+ ### Metrics
108
+
109
+ `client.metrics` counts rounds, bytes and time (server, network, encryption) across every scheme on that
110
+ client, and `with client.measure() as m:` gives the same numbers for one span of work in `m.result`.
111
+
112
+ ## Citation
113
+
114
+ If OblivLib is useful in your work, please cite our papers:
115
+
116
+ ```bibtex
117
+ @article{cao2024oblivious,
118
+ title = {Towards Practical Oblivious Map},
119
+ author = {Cao, Xinle and Feng, Weiqi and Liu, Jian and Zhou, Jinjin and Fang, Wenjing and Wang, Lei and
120
+ Xu, Quanqing and Yang, Chuanhui and Ren, Kui},
121
+ journal = {Proceedings of the VLDB Endowment},
122
+ volume = {18},
123
+ number = {3},
124
+ pages = {688--701},
125
+ year = {2024},
126
+ doi = {10.14778/3712221.3712235}
127
+ }
128
+
129
+ @article{feng2026grove,
130
+ title = {Enabling Index-free Adjacency in Oblivious Graph Processing with Delayed Duplications},
131
+ author = {Feng, Weiqi and Cao, Xinle and O'Neill, Adam and Yang, Chuanhui},
132
+ journal = {Proceedings of the VLDB Endowment},
133
+ volume = {19},
134
+ number = {8},
135
+ pages = {1826--1839},
136
+ year = {2026},
137
+ url = {https://www.vldb.org/pvldb/vol19/p1826-cao.pdf}
138
+ }
139
+ ```
@@ -0,0 +1,109 @@
1
+ # OblivLib
2
+
3
+ [![OblivLib CI](https://github.com/WeiqiNs/OblivLib/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/WeiqiNs/OblivLib/actions/workflows/ci.yml)
4
+ [![codecov](https://codecov.io/gh/WeiqiNs/OblivLib/graph/badge.svg)](https://codecov.io/gh/WeiqiNs/OblivLib)
5
+
6
+ OblivLib implements oblivious RAM, oblivious maps and oblivious graphs for a client/server setting: the
7
+ client holds the keys and runs the algorithm, and the server only stores encrypted data.
8
+
9
+ ## Schemes
10
+
11
+ | Kind | Scheme | Class |
12
+ |---|---|---|
13
+ | ORAM | [Path ORAM](https://doi.org/10.1145/2508859.2516660) | `PathOram` |
14
+ | | [Recursive Path ORAM](https://doi.org/10.1007/978-3-642-25385-0_11) | `RecursivePathOram` |
15
+ | | [Freecursive ORAM](https://doi.org/10.1145/2694344.2694353), with [probabilistic resets](https://eprint.iacr.org/2016/1084) by default | `FreecursiveOram` |
16
+ | | [DAORAM](https://doi.org/10.14778/3712221.3712235) | `DAOram` |
17
+ | | Multi-path Path ORAM | `MulPathOram` |
18
+ | | Static Path ORAM (PRF-positioned; reveals repeated accesses, a building block) | `StaticOram` |
19
+ | OMAP | [AVL-tree OMAP](https://doi.org/10.1145/2660267.2660314) | `AVLOmap` |
20
+ | | [B+-tree OMAP](https://doi.org/10.14778/3364324.3364331) | `BPlusOmap` |
21
+ | | [ORAM + search tree](https://doi.org/10.14778/3712221.3712235) | `OramOstOmap` |
22
+ | | Group-by-hash OMAP | `GroupOmap` |
23
+ | Graph | [GraphOS](https://www.vldb.org/pvldb/vol16/p4324-chamani.pdf) | `GraphOS` |
24
+ | | [Grove](https://www.vldb.org/pvldb/vol19/p1826-cao.pdf) | `Grove` |
25
+
26
+ ## Installation
27
+
28
+ Requires Python 3.12 or later.
29
+
30
+ ```bash
31
+ pip install oblivlib
32
+ ```
33
+
34
+ For development: `pip install -e . --group dev`, then `pytest --cov` (the suite requires 100% line and
35
+ branch coverage).
36
+
37
+ ## Usage
38
+
39
+ Everything is imported from `oblivlib`. Every scheme is built from its config (`PathOramConfig`,
40
+ `AvlOmapConfig`, `GroveConfig`, ...). A config sets the size (`num_data`, `data_size`, and `key_size` for maps), the
41
+ `client` that reaches the server, and optionally an `encryptor` and tuning options. Invalid settings raise
42
+ when the config is created.
43
+
44
+ ```python
45
+ from oblivlib import AesGcm, AVLOmap, AvlOmapConfig, Client, PathOram, PathOramConfig
46
+
47
+ with Client.local() as client:
48
+ oram = PathOram(PathOramConfig(num_data=1024, data_size=16, client=client, encryptor=AesGcm()))
49
+ oram.init_server_storage()
50
+ oram.operate_on_key(3, b"hello")
51
+ assert oram.operate_on_key(3) == b"hello"
52
+
53
+ omap = AVLOmap(AvlOmapConfig(num_data=1024, key_size=16, data_size=16, client=client, encryptor=AesGcm()))
54
+ omap.init_server_storage()
55
+ omap.insert(b"alice", b"42")
56
+ assert omap.search(b"alice") == b"42"
57
+ ```
58
+
59
+ Keys and values are bytes (ORAM keys are ints in `[0, num_data)`, graph vertices are ints); anything outside
60
+ a scheme's limits raises `ContractError` before the server is touched.
61
+
62
+ `Client.local()` runs the server in the same process. For a real deployment, run a server and connect to it.
63
+ The server has no authentication, so bind it to a trusted network or put it behind an authenticated tunnel:
64
+
65
+ ```python
66
+ from oblivlib import StorageServer, ZmqListener, serve
67
+
68
+ serve(ZmqListener("tcp://*:5555"), StorageServer(storage_dir="/var/lib/oblivlib"))
69
+ ```
70
+
71
+ ```python
72
+ client = Client.connect("tcp://server-host:5555")
73
+ ```
74
+
75
+ Runnable versions are in [`demo/`](demo): `python demo/server.py`, then `python demo/client.py`.
76
+
77
+ ### Metrics
78
+
79
+ `client.metrics` counts rounds, bytes and time (server, network, encryption) across every scheme on that
80
+ client, and `with client.measure() as m:` gives the same numbers for one span of work in `m.result`.
81
+
82
+ ## Citation
83
+
84
+ If OblivLib is useful in your work, please cite our papers:
85
+
86
+ ```bibtex
87
+ @article{cao2024oblivious,
88
+ title = {Towards Practical Oblivious Map},
89
+ author = {Cao, Xinle and Feng, Weiqi and Liu, Jian and Zhou, Jinjin and Fang, Wenjing and Wang, Lei and
90
+ Xu, Quanqing and Yang, Chuanhui and Ren, Kui},
91
+ journal = {Proceedings of the VLDB Endowment},
92
+ volume = {18},
93
+ number = {3},
94
+ pages = {688--701},
95
+ year = {2024},
96
+ doi = {10.14778/3712221.3712235}
97
+ }
98
+
99
+ @article{feng2026grove,
100
+ title = {Enabling Index-free Adjacency in Oblivious Graph Processing with Delayed Duplications},
101
+ author = {Feng, Weiqi and Cao, Xinle and O'Neill, Adam and Yang, Chuanhui},
102
+ journal = {Proceedings of the VLDB Endowment},
103
+ volume = {19},
104
+ number = {8},
105
+ pages = {1826--1839},
106
+ year = {2026},
107
+ url = {https://www.vldb.org/pvldb/vol19/p1826-cao.pdf}
108
+ }
109
+ ```
@@ -0,0 +1,95 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "oblivlib"
7
+ version = "0.1.0"
8
+ description = "A Python library of oblivious data structures and algorithms."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ authors = [
14
+ { name = "Weiqi Feng", email = "weltch1997@gmail.com" },
15
+ { name = "Xinle Cao", email = "xinlecao72@gmail.com" },
16
+ ]
17
+ keywords = [
18
+ "oram",
19
+ "omap",
20
+ "oblivious",
21
+ "oblivious-ram",
22
+ "oblivious-map",
23
+ "oblivious-data-structures",
24
+ "cryptography",
25
+ "privacy",
26
+ "security",
27
+ ]
28
+ classifiers = [
29
+ "Development Status :: 3 - Alpha",
30
+ "Intended Audience :: Developers",
31
+ "Intended Audience :: Science/Research",
32
+ "Operating System :: OS Independent",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Programming Language :: Python :: 3.14",
37
+ "Programming Language :: Python :: 3.15",
38
+ "Topic :: Security :: Cryptography",
39
+ "Topic :: Scientific/Engineering",
40
+ "Typing :: Typed",
41
+ ]
42
+ dependencies = [
43
+ "cryptography>=45.0.0",
44
+ "msgspec>=0.22.0",
45
+ "pyzmq>=26.0.0",
46
+ ]
47
+
48
+ [dependency-groups]
49
+ dev = [
50
+ "pytest>=9.0.0",
51
+ "pytest-cov>=7.0.0",
52
+ "basedpyright>=1.39.0",
53
+ "ruff>=0.15.0",
54
+ ]
55
+
56
+ [project.urls]
57
+ Homepage = "https://github.com/WeiqiNs/OblivLib"
58
+ Repository = "https://github.com/WeiqiNs/OblivLib"
59
+ Issues = "https://github.com/WeiqiNs/OblivLib/issues"
60
+
61
+ [tool.pytest.ini_options]
62
+ testpaths = ["tests"]
63
+
64
+ [tool.coverage.run]
65
+ source = ["oblivlib"]
66
+ branch = true
67
+
68
+ [tool.coverage.report]
69
+ exclude_also = ["raise NotImplementedError", "@abstractmethod", "\\.\\.\\.$"]
70
+ fail_under = 100
71
+ show_missing = true
72
+ skip_covered = true
73
+
74
+ [tool.ruff]
75
+ target-version = "py312"
76
+ line-length = 120
77
+
78
+ [tool.ruff.lint]
79
+ select = [
80
+ "E", # pycodestyle errors
81
+ "F", # pyflakes
82
+ "I", # import sorting (isort)
83
+ "UP", # pyupgrade — modern typing/syntax
84
+ "B", # flake8-bugbear — likely-bug patterns
85
+ ]
86
+ ignore = [
87
+ "E501", # line length is handled by `ruff format`
88
+ ]
89
+
90
+ [tool.setuptools.packages.find]
91
+ where = ["src"]
92
+ include = ["oblivlib*"]
93
+
94
+ [tool.setuptools.package-data]
95
+ oblivlib = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,127 @@
1
+ from oblivlib.dependency import (
2
+ AccessBudget,
3
+ AesGcm,
4
+ AvlOmapConfig,
5
+ Backend,
6
+ BPlusOmapConfig,
7
+ CapacityError,
8
+ Client,
9
+ ContractError,
10
+ CounterOramConfig,
11
+ DaOramConfig,
12
+ DuplicateLabelError,
13
+ Encryptor,
14
+ FreecursiveOramConfig,
15
+ GraphConfig,
16
+ GraphOsConfig,
17
+ GroupOmapConfig,
18
+ GroveConfig,
19
+ InitData,
20
+ LocalBackend,
21
+ LoopbackTransport,
22
+ Measurement,
23
+ Metrics,
24
+ MissingResultError,
25
+ MulPathOramConfig,
26
+ OblivlibError,
27
+ OmapConfig,
28
+ OramConfig,
29
+ PathOramConfig,
30
+ PosMapOramConfig,
31
+ ProtocolError,
32
+ RecursiveOramConfig,
33
+ RowSizeError,
34
+ ServerError,
35
+ SimulatedNetwork,
36
+ StashOverflowError,
37
+ StaticOramConfig,
38
+ StorageError,
39
+ StorageServer,
40
+ Transport,
41
+ TransportBackend,
42
+ TransportError,
43
+ TreeOmapConfig,
44
+ UnknownLabelError,
45
+ ZmqListener,
46
+ ZmqTransport,
47
+ serve,
48
+ )
49
+ from oblivlib.graph import (
50
+ GraphOS,
51
+ Grove,
52
+ )
53
+ from oblivlib.omap import (
54
+ AVLOmap,
55
+ BPlusOmap,
56
+ GroupOmap,
57
+ OramOstOmap,
58
+ )
59
+ from oblivlib.oram import (
60
+ DAOram,
61
+ FreecursiveOram,
62
+ MulPathOram,
63
+ PathOram,
64
+ RecursivePathOram,
65
+ StaticOram,
66
+ )
67
+
68
+ __all__ = [
69
+ "AVLOmap",
70
+ "AccessBudget",
71
+ "AesGcm",
72
+ "AvlOmapConfig",
73
+ "BPlusOmap",
74
+ "BPlusOmapConfig",
75
+ "Backend",
76
+ "CapacityError",
77
+ "Client",
78
+ "ContractError",
79
+ "CounterOramConfig",
80
+ "DAOram",
81
+ "DaOramConfig",
82
+ "DuplicateLabelError",
83
+ "Encryptor",
84
+ "FreecursiveOram",
85
+ "FreecursiveOramConfig",
86
+ "GraphConfig",
87
+ "GraphOS",
88
+ "GraphOsConfig",
89
+ "GroupOmap",
90
+ "GroupOmapConfig",
91
+ "Grove",
92
+ "GroveConfig",
93
+ "InitData",
94
+ "LocalBackend",
95
+ "LoopbackTransport",
96
+ "Measurement",
97
+ "Metrics",
98
+ "MissingResultError",
99
+ "MulPathOram",
100
+ "MulPathOramConfig",
101
+ "OblivlibError",
102
+ "OmapConfig",
103
+ "OramConfig",
104
+ "OramOstOmap",
105
+ "PathOram",
106
+ "PathOramConfig",
107
+ "PosMapOramConfig",
108
+ "ProtocolError",
109
+ "RecursiveOramConfig",
110
+ "RecursivePathOram",
111
+ "RowSizeError",
112
+ "ServerError",
113
+ "SimulatedNetwork",
114
+ "StashOverflowError",
115
+ "StaticOram",
116
+ "StaticOramConfig",
117
+ "StorageError",
118
+ "StorageServer",
119
+ "Transport",
120
+ "TransportBackend",
121
+ "TransportError",
122
+ "TreeOmapConfig",
123
+ "UnknownLabelError",
124
+ "ZmqListener",
125
+ "ZmqTransport",
126
+ "serve",
127
+ ]