voprf 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.
@@ -0,0 +1,186 @@
1
+ # This file is autogenerated by maturin v1.14.1
2
+ # To update, run
3
+ #
4
+ # maturin generate-ci github
5
+ #
6
+ name: CI
7
+
8
+ on:
9
+ push:
10
+ branches:
11
+ - main
12
+ - master
13
+ tags:
14
+ - '*'
15
+ pull_request:
16
+ workflow_dispatch:
17
+
18
+ permissions:
19
+ contents: read
20
+
21
+ jobs:
22
+ linux:
23
+ runs-on: ${{ matrix.platform.runner }}
24
+ strategy:
25
+ matrix:
26
+ platform:
27
+ - runner: ubuntu-22.04
28
+ target: x86_64
29
+ - runner: ubuntu-22.04
30
+ target: x86
31
+ - runner: ubuntu-22.04
32
+ target: aarch64
33
+ - runner: ubuntu-22.04
34
+ target: armv7
35
+ - runner: ubuntu-22.04
36
+ target: s390x
37
+ - runner: ubuntu-22.04
38
+ target: ppc64le
39
+ steps:
40
+ - uses: actions/checkout@v6
41
+ - uses: actions/setup-python@v6
42
+ with:
43
+ python-version: "3.x"
44
+ - name: Build wheels
45
+ uses: PyO3/maturin-action@v1
46
+ with:
47
+ target: ${{ matrix.platform.target }}
48
+ args: --release --out dist --find-interpreter
49
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50
+ manylinux: auto
51
+ - name: Upload wheels
52
+ uses: actions/upload-artifact@v6
53
+ with:
54
+ name: wheels-linux-${{ matrix.platform.target }}
55
+ path: dist
56
+
57
+ musllinux:
58
+ runs-on: ${{ matrix.platform.runner }}
59
+ strategy:
60
+ matrix:
61
+ platform:
62
+ - runner: ubuntu-22.04
63
+ target: x86_64
64
+ - runner: ubuntu-22.04
65
+ target: x86
66
+ - runner: ubuntu-22.04
67
+ target: aarch64
68
+ - runner: ubuntu-22.04
69
+ target: armv7
70
+ steps:
71
+ - uses: actions/checkout@v6
72
+ - uses: actions/setup-python@v6
73
+ with:
74
+ python-version: "3.x"
75
+ - name: Build wheels
76
+ uses: PyO3/maturin-action@v1
77
+ with:
78
+ target: ${{ matrix.platform.target }}
79
+ args: --release --out dist --find-interpreter
80
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
81
+ manylinux: musllinux_1_2
82
+ - name: Upload wheels
83
+ uses: actions/upload-artifact@v6
84
+ with:
85
+ name: wheels-musllinux-${{ matrix.platform.target }}
86
+ path: dist
87
+
88
+ windows:
89
+ runs-on: ${{ matrix.platform.runner }}
90
+ strategy:
91
+ matrix:
92
+ platform:
93
+ - runner: windows-latest
94
+ target: x64
95
+ python_arch: x64
96
+ - runner: windows-latest
97
+ target: x86
98
+ python_arch: x86
99
+ - runner: windows-11-arm
100
+ target: aarch64
101
+ python_arch: arm64
102
+ steps:
103
+ - uses: actions/checkout@v6
104
+ - uses: actions/setup-python@v6
105
+ with:
106
+ python-version: "3.13"
107
+ architecture: ${{ matrix.platform.python_arch }}
108
+ - name: Build wheels
109
+ uses: PyO3/maturin-action@v1
110
+ with:
111
+ target: ${{ matrix.platform.target }}
112
+ args: --release --out dist --find-interpreter
113
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
114
+ - name: Upload wheels
115
+ uses: actions/upload-artifact@v6
116
+ with:
117
+ name: wheels-windows-${{ matrix.platform.target }}
118
+ path: dist
119
+
120
+ macos:
121
+ runs-on: ${{ matrix.platform.runner }}
122
+ strategy:
123
+ matrix:
124
+ platform:
125
+ - runner: macos-15-intel
126
+ target: x86_64
127
+ - runner: macos-latest
128
+ target: aarch64
129
+ steps:
130
+ - uses: actions/checkout@v6
131
+ - uses: actions/setup-python@v6
132
+ with:
133
+ python-version: "3.x"
134
+ - name: Build wheels
135
+ uses: PyO3/maturin-action@v1
136
+ with:
137
+ target: ${{ matrix.platform.target }}
138
+ args: --release --out dist --find-interpreter
139
+ sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
140
+ - name: Upload wheels
141
+ uses: actions/upload-artifact@v6
142
+ with:
143
+ name: wheels-macos-${{ matrix.platform.target }}
144
+ path: dist
145
+
146
+ sdist:
147
+ runs-on: ubuntu-latest
148
+ steps:
149
+ - uses: actions/checkout@v6
150
+ - name: Build sdist
151
+ uses: PyO3/maturin-action@v1
152
+ with:
153
+ command: sdist
154
+ args: --out dist
155
+ - name: Upload sdist
156
+ uses: actions/upload-artifact@v6
157
+ with:
158
+ name: wheels-sdist
159
+ path: dist
160
+
161
+ release:
162
+ name: Release
163
+ runs-on: ubuntu-latest
164
+ if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
165
+ needs: [linux, musllinux, windows, macos, sdist]
166
+ permissions:
167
+ # Use to sign the release artifacts
168
+ id-token: write
169
+ # Used to upload release artifacts
170
+ contents: write
171
+ # Used to generate artifact attestation
172
+ attestations: write
173
+ steps:
174
+ - uses: actions/download-artifact@v7
175
+ - name: Generate artifact attestation
176
+ uses: actions/attest@v4
177
+ with:
178
+ subject-path: 'wheels-*/*'
179
+ - name: Install uv
180
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
181
+ uses: astral-sh/setup-uv@v7
182
+ - name: Publish to PyPI
183
+ if: ${{ startsWith(github.ref, 'refs/tags/') }}
184
+ run: uv publish 'wheels-*/*'
185
+ env:
186
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
voprf-0.1.0/.gitignore ADDED
@@ -0,0 +1,72 @@
1
+ /target
2
+
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ .pytest_cache/
6
+ *.py[cod]
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ .venv/
14
+ env/
15
+ bin/
16
+ build/
17
+ develop-eggs/
18
+ dist/
19
+ eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ include/
26
+ man/
27
+ venv/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+
32
+ # Installer logs
33
+ pip-log.txt
34
+ pip-delete-this-directory.txt
35
+ pip-selfcheck.json
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .coverage
41
+ .cache
42
+ nosetests.xml
43
+ coverage.xml
44
+
45
+ # Translations
46
+ *.mo
47
+
48
+ # Mr Developer
49
+ .mr.developer.cfg
50
+ .project
51
+ .pydevproject
52
+
53
+ # Rope
54
+ .ropeproject
55
+
56
+ # Django stuff:
57
+ *.log
58
+ *.pot
59
+
60
+ .DS_Store
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyCharm
66
+ .idea/
67
+
68
+ # VSCode
69
+ .vscode/
70
+
71
+ # Pyenv
72
+ .python-version
voprf-0.1.0/Cargo.lock ADDED
@@ -0,0 +1,543 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "base16ct"
7
+ version = "0.2.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
10
+
11
+ [[package]]
12
+ name = "block-buffer"
13
+ version = "0.10.4"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
16
+ dependencies = [
17
+ "generic-array 0.14.9",
18
+ ]
19
+
20
+ [[package]]
21
+ name = "cfg-if"
22
+ version = "1.0.4"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
25
+
26
+ [[package]]
27
+ name = "const-oid"
28
+ version = "0.9.6"
29
+ source = "registry+https://github.com/rust-lang/crates.io-index"
30
+ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8"
31
+
32
+ [[package]]
33
+ name = "cpufeatures"
34
+ version = "0.2.17"
35
+ source = "registry+https://github.com/rust-lang/crates.io-index"
36
+ checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
37
+ dependencies = [
38
+ "libc",
39
+ ]
40
+
41
+ [[package]]
42
+ name = "crypto-bigint"
43
+ version = "0.5.5"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
46
+ dependencies = [
47
+ "generic-array 0.14.9",
48
+ "rand_core 0.6.4",
49
+ "subtle",
50
+ "zeroize",
51
+ ]
52
+
53
+ [[package]]
54
+ name = "crypto-common"
55
+ version = "0.1.6"
56
+ source = "registry+https://github.com/rust-lang/crates.io-index"
57
+ checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
58
+ dependencies = [
59
+ "generic-array 0.14.9",
60
+ "typenum",
61
+ ]
62
+
63
+ [[package]]
64
+ name = "curve25519-dalek"
65
+ version = "4.1.3"
66
+ source = "registry+https://github.com/rust-lang/crates.io-index"
67
+ checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
68
+ dependencies = [
69
+ "cfg-if",
70
+ "cpufeatures",
71
+ "curve25519-dalek-derive",
72
+ "fiat-crypto",
73
+ "rand_core 0.6.4",
74
+ "rustc_version",
75
+ "subtle",
76
+ "zeroize",
77
+ ]
78
+
79
+ [[package]]
80
+ name = "curve25519-dalek-derive"
81
+ version = "0.1.1"
82
+ source = "registry+https://github.com/rust-lang/crates.io-index"
83
+ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
84
+ dependencies = [
85
+ "proc-macro2",
86
+ "quote",
87
+ "syn",
88
+ ]
89
+
90
+ [[package]]
91
+ name = "der"
92
+ version = "0.7.10"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb"
95
+ dependencies = [
96
+ "const-oid",
97
+ "zeroize",
98
+ ]
99
+
100
+ [[package]]
101
+ name = "derive-where"
102
+ version = "1.6.1"
103
+ source = "registry+https://github.com/rust-lang/crates.io-index"
104
+ checksum = "d08b3a0bcc0d079199cd476b2cae8435016ec11d1c0986c6901c5ac223041534"
105
+ dependencies = [
106
+ "proc-macro2",
107
+ "quote",
108
+ "syn",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "digest"
113
+ version = "0.10.7"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
116
+ dependencies = [
117
+ "block-buffer",
118
+ "crypto-common",
119
+ ]
120
+
121
+ [[package]]
122
+ name = "displaydoc"
123
+ version = "0.2.6"
124
+ source = "registry+https://github.com/rust-lang/crates.io-index"
125
+ checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f"
126
+ dependencies = [
127
+ "proc-macro2",
128
+ "quote",
129
+ "syn",
130
+ ]
131
+
132
+ [[package]]
133
+ name = "elliptic-curve"
134
+ version = "0.13.8"
135
+ source = "registry+https://github.com/rust-lang/crates.io-index"
136
+ checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
137
+ dependencies = [
138
+ "base16ct",
139
+ "crypto-bigint",
140
+ "digest",
141
+ "ff",
142
+ "generic-array 0.14.9",
143
+ "group",
144
+ "rand_core 0.6.4",
145
+ "sec1",
146
+ "subtle",
147
+ "zeroize",
148
+ ]
149
+
150
+ [[package]]
151
+ name = "ff"
152
+ version = "0.13.1"
153
+ source = "registry+https://github.com/rust-lang/crates.io-index"
154
+ checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393"
155
+ dependencies = [
156
+ "rand_core 0.6.4",
157
+ "subtle",
158
+ ]
159
+
160
+ [[package]]
161
+ name = "fiat-crypto"
162
+ version = "0.2.9"
163
+ source = "registry+https://github.com/rust-lang/crates.io-index"
164
+ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
165
+
166
+ [[package]]
167
+ name = "generic-array"
168
+ version = "0.14.9"
169
+ source = "registry+https://github.com/rust-lang/crates.io-index"
170
+ checksum = "4bb6743198531e02858aeaea5398fcc883e71851fcbcb5a2f773e2fb6cb1edf2"
171
+ dependencies = [
172
+ "typenum",
173
+ "version_check",
174
+ "zeroize",
175
+ ]
176
+
177
+ [[package]]
178
+ name = "generic-array"
179
+ version = "1.4.4"
180
+ source = "registry+https://github.com/rust-lang/crates.io-index"
181
+ checksum = "ab4e5aa225bc56696909483320f0ff9b600f1a971b52e07a17d70f3d9b43254b"
182
+ dependencies = [
183
+ "rustversion",
184
+ "typenum",
185
+ ]
186
+
187
+ [[package]]
188
+ name = "getrandom"
189
+ version = "0.3.4"
190
+ source = "registry+https://github.com/rust-lang/crates.io-index"
191
+ checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
192
+ dependencies = [
193
+ "cfg-if",
194
+ "libc",
195
+ "r-efi",
196
+ "wasip2",
197
+ ]
198
+
199
+ [[package]]
200
+ name = "group"
201
+ version = "0.13.0"
202
+ source = "registry+https://github.com/rust-lang/crates.io-index"
203
+ checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
204
+ dependencies = [
205
+ "ff",
206
+ "rand_core 0.6.4",
207
+ "subtle",
208
+ ]
209
+
210
+ [[package]]
211
+ name = "heck"
212
+ version = "0.5.0"
213
+ source = "registry+https://github.com/rust-lang/crates.io-index"
214
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
215
+
216
+ [[package]]
217
+ name = "libc"
218
+ version = "0.2.186"
219
+ source = "registry+https://github.com/rust-lang/crates.io-index"
220
+ checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
221
+
222
+ [[package]]
223
+ name = "once_cell"
224
+ version = "1.21.4"
225
+ source = "registry+https://github.com/rust-lang/crates.io-index"
226
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
227
+
228
+ [[package]]
229
+ name = "portable-atomic"
230
+ version = "1.14.0"
231
+ source = "registry+https://github.com/rust-lang/crates.io-index"
232
+ checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3"
233
+
234
+ [[package]]
235
+ name = "ppv-lite86"
236
+ version = "0.2.21"
237
+ source = "registry+https://github.com/rust-lang/crates.io-index"
238
+ checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
239
+ dependencies = [
240
+ "zerocopy",
241
+ ]
242
+
243
+ [[package]]
244
+ name = "proc-macro2"
245
+ version = "1.0.106"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
248
+ dependencies = [
249
+ "unicode-ident",
250
+ ]
251
+
252
+ [[package]]
253
+ name = "pyo3"
254
+ version = "0.29.0"
255
+ source = "registry+https://github.com/rust-lang/crates.io-index"
256
+ checksum = "cd274650b21d4bfc26a0a47587962c1edb425f69287324355cd040c3ea66071c"
257
+ dependencies = [
258
+ "libc",
259
+ "once_cell",
260
+ "portable-atomic",
261
+ "pyo3-build-config",
262
+ "pyo3-ffi",
263
+ "pyo3-macros",
264
+ ]
265
+
266
+ [[package]]
267
+ name = "pyo3-build-config"
268
+ version = "0.29.0"
269
+ source = "registry+https://github.com/rust-lang/crates.io-index"
270
+ checksum = "c5e2a7d2f0d013342f295c048ad19237add5154a55b1c5a254c0ec93d4109078"
271
+ dependencies = [
272
+ "target-lexicon",
273
+ ]
274
+
275
+ [[package]]
276
+ name = "pyo3-ffi"
277
+ version = "0.29.0"
278
+ source = "registry+https://github.com/rust-lang/crates.io-index"
279
+ checksum = "ca85c467da1bbc8d866eea5deff9cf29ea5f7785054a17da36e65bda9c05845b"
280
+ dependencies = [
281
+ "libc",
282
+ "pyo3-build-config",
283
+ ]
284
+
285
+ [[package]]
286
+ name = "pyo3-macros"
287
+ version = "0.29.0"
288
+ source = "registry+https://github.com/rust-lang/crates.io-index"
289
+ checksum = "9ac53762fd065daa3194dd09337a38bd793a188100fd1a9304c4ab312d901771"
290
+ dependencies = [
291
+ "proc-macro2",
292
+ "pyo3-macros-backend",
293
+ "quote",
294
+ "syn",
295
+ ]
296
+
297
+ [[package]]
298
+ name = "pyo3-macros-backend"
299
+ version = "0.29.0"
300
+ source = "registry+https://github.com/rust-lang/crates.io-index"
301
+ checksum = "4ca3a1557399783172dc5bf39cfca835157732532cba56b71d2292161e53b362"
302
+ dependencies = [
303
+ "heck",
304
+ "proc-macro2",
305
+ "quote",
306
+ "syn",
307
+ ]
308
+
309
+ [[package]]
310
+ name = "quote"
311
+ version = "1.0.46"
312
+ source = "registry+https://github.com/rust-lang/crates.io-index"
313
+ checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368"
314
+ dependencies = [
315
+ "proc-macro2",
316
+ ]
317
+
318
+ [[package]]
319
+ name = "r-efi"
320
+ version = "5.3.0"
321
+ source = "registry+https://github.com/rust-lang/crates.io-index"
322
+ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
323
+
324
+ [[package]]
325
+ name = "rand"
326
+ version = "0.9.5"
327
+ source = "registry+https://github.com/rust-lang/crates.io-index"
328
+ checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"
329
+ dependencies = [
330
+ "rand_chacha",
331
+ "rand_core 0.9.5",
332
+ ]
333
+
334
+ [[package]]
335
+ name = "rand_chacha"
336
+ version = "0.9.0"
337
+ source = "registry+https://github.com/rust-lang/crates.io-index"
338
+ checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
339
+ dependencies = [
340
+ "ppv-lite86",
341
+ "rand_core 0.9.5",
342
+ ]
343
+
344
+ [[package]]
345
+ name = "rand_core"
346
+ version = "0.6.4"
347
+ source = "registry+https://github.com/rust-lang/crates.io-index"
348
+ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
349
+
350
+ [[package]]
351
+ name = "rand_core"
352
+ version = "0.9.5"
353
+ source = "registry+https://github.com/rust-lang/crates.io-index"
354
+ checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
355
+ dependencies = [
356
+ "getrandom",
357
+ ]
358
+
359
+ [[package]]
360
+ name = "rustc_version"
361
+ version = "0.4.1"
362
+ source = "registry+https://github.com/rust-lang/crates.io-index"
363
+ checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
364
+ dependencies = [
365
+ "semver",
366
+ ]
367
+
368
+ [[package]]
369
+ name = "rustversion"
370
+ version = "1.0.23"
371
+ source = "registry+https://github.com/rust-lang/crates.io-index"
372
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
373
+
374
+ [[package]]
375
+ name = "sec1"
376
+ version = "0.7.3"
377
+ source = "registry+https://github.com/rust-lang/crates.io-index"
378
+ checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
379
+ dependencies = [
380
+ "base16ct",
381
+ "der",
382
+ "generic-array 0.14.9",
383
+ "subtle",
384
+ "zeroize",
385
+ ]
386
+
387
+ [[package]]
388
+ name = "semver"
389
+ version = "1.0.28"
390
+ source = "registry+https://github.com/rust-lang/crates.io-index"
391
+ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
392
+
393
+ [[package]]
394
+ name = "serde"
395
+ version = "1.0.228"
396
+ source = "registry+https://github.com/rust-lang/crates.io-index"
397
+ checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
398
+ dependencies = [
399
+ "serde_core",
400
+ "serde_derive",
401
+ ]
402
+
403
+ [[package]]
404
+ name = "serde_core"
405
+ version = "1.0.228"
406
+ source = "registry+https://github.com/rust-lang/crates.io-index"
407
+ checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
408
+ dependencies = [
409
+ "serde_derive",
410
+ ]
411
+
412
+ [[package]]
413
+ name = "serde_derive"
414
+ version = "1.0.228"
415
+ source = "registry+https://github.com/rust-lang/crates.io-index"
416
+ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
417
+ dependencies = [
418
+ "proc-macro2",
419
+ "quote",
420
+ "syn",
421
+ ]
422
+
423
+ [[package]]
424
+ name = "sha2"
425
+ version = "0.10.9"
426
+ source = "registry+https://github.com/rust-lang/crates.io-index"
427
+ checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
428
+ dependencies = [
429
+ "cfg-if",
430
+ "cpufeatures",
431
+ "digest",
432
+ ]
433
+
434
+ [[package]]
435
+ name = "subtle"
436
+ version = "2.6.1"
437
+ source = "registry+https://github.com/rust-lang/crates.io-index"
438
+ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
439
+
440
+ [[package]]
441
+ name = "syn"
442
+ version = "2.0.119"
443
+ source = "registry+https://github.com/rust-lang/crates.io-index"
444
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
445
+ dependencies = [
446
+ "proc-macro2",
447
+ "quote",
448
+ "unicode-ident",
449
+ ]
450
+
451
+ [[package]]
452
+ name = "target-lexicon"
453
+ version = "0.13.5"
454
+ source = "registry+https://github.com/rust-lang/crates.io-index"
455
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
456
+
457
+ [[package]]
458
+ name = "typenum"
459
+ version = "1.20.1"
460
+ source = "registry+https://github.com/rust-lang/crates.io-index"
461
+ checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
462
+
463
+ [[package]]
464
+ name = "unicode-ident"
465
+ version = "1.0.24"
466
+ source = "registry+https://github.com/rust-lang/crates.io-index"
467
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
468
+
469
+ [[package]]
470
+ name = "version_check"
471
+ version = "0.9.5"
472
+ source = "registry+https://github.com/rust-lang/crates.io-index"
473
+ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
474
+
475
+ [[package]]
476
+ name = "voprf"
477
+ version = "0.1.0"
478
+ dependencies = [
479
+ "generic-array 1.4.4",
480
+ "pyo3",
481
+ "rand",
482
+ "voprf 0.6.0-pre.1",
483
+ ]
484
+
485
+ [[package]]
486
+ name = "voprf"
487
+ version = "0.6.0-pre.1"
488
+ source = "registry+https://github.com/rust-lang/crates.io-index"
489
+ checksum = "1965e90b2c4b5a7b3316d2633bb58345df0ef7f81e44e7cf02088bb01cd45104"
490
+ dependencies = [
491
+ "curve25519-dalek",
492
+ "derive-where",
493
+ "digest",
494
+ "displaydoc",
495
+ "elliptic-curve",
496
+ "generic-array 1.4.4",
497
+ "rand_core 0.9.5",
498
+ "serde",
499
+ "sha2",
500
+ "subtle",
501
+ "zeroize",
502
+ ]
503
+
504
+ [[package]]
505
+ name = "wasip2"
506
+ version = "1.0.4+wasi-0.2.12"
507
+ source = "registry+https://github.com/rust-lang/crates.io-index"
508
+ checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
509
+ dependencies = [
510
+ "wit-bindgen",
511
+ ]
512
+
513
+ [[package]]
514
+ name = "wit-bindgen"
515
+ version = "0.57.1"
516
+ source = "registry+https://github.com/rust-lang/crates.io-index"
517
+ checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
518
+
519
+ [[package]]
520
+ name = "zerocopy"
521
+ version = "0.8.54"
522
+ source = "registry+https://github.com/rust-lang/crates.io-index"
523
+ checksum = "b7cbbc0a705a0fd05cc3676525980d2bf5a9bc4adac6d6475209a7887cf59d19"
524
+ dependencies = [
525
+ "zerocopy-derive",
526
+ ]
527
+
528
+ [[package]]
529
+ name = "zerocopy-derive"
530
+ version = "0.8.54"
531
+ source = "registry+https://github.com/rust-lang/crates.io-index"
532
+ checksum = "e2e817b7b52d0c7358d3246da9d69935ebb18116b2b102b4230dac079b4862f5"
533
+ dependencies = [
534
+ "proc-macro2",
535
+ "quote",
536
+ "syn",
537
+ ]
538
+
539
+ [[package]]
540
+ name = "zeroize"
541
+ version = "1.9.0"
542
+ source = "registry+https://github.com/rust-lang/crates.io-index"
543
+ checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
voprf-0.1.0/Cargo.toml ADDED
@@ -0,0 +1,18 @@
1
+ [package]
2
+ name = "voprf"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+ rust-version = "1.85"
6
+ publish = false
7
+ readme = "README.md"
8
+
9
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10
+ [lib]
11
+ name = "voprf"
12
+ crate-type = ["cdylib"]
13
+
14
+ [dependencies]
15
+ generic-array = "1.4.4"
16
+ pyo3 = "0.29.0"
17
+ rand = "0.9"
18
+ voprf = { version="0.6.0-pre.1", features=["ristretto255", "alloc"] }
voprf-0.1.0/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Copyright 2026 asterized
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
voprf-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: voprf
3
+ Version: 0.1.0
4
+ Classifier: License :: OSI Approved :: BSD License
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: Programming Language :: Rust
10
+ Classifier: Topic :: Security :: Cryptography
11
+ Classifier: Topic :: Security
12
+ Classifier: Operating System :: OS Independent
13
+ License-File: LICENSE
14
+ Summary: A verifiable OPRF for Python
15
+ Author: asterized
16
+ Requires-Python: >=3.9
17
+ Project-URL: homepage, https://github.com/asterized/voprf
voprf-0.1.0/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # voprf
2
+
3
+ A Ristretto255-based verifiable [oblivious pseudo(r)andom function (VOPRF)](https://datatracker.ietf.org/doc/rfc9497/) implementation for Python.
4
+
5
+ ## Installation
6
+
7
+ To install, just run:
8
+
9
+ ```
10
+ $ pip install voprf
11
+ ```
12
+
13
+ The package should install with a Rust compiler on version 1.85.1 or above.
14
+
15
+ ## Usage
16
+
17
+ A basic example is shown below.
18
+
19
+ ```py
20
+ import voprf
21
+ import secrets
22
+
23
+ server = voprf.Evaluator(secrets.token_bytes(32))
24
+
25
+ client, blinded_input = voprf.Client.blind(b"hello!")
26
+ blinded_output = server.evaluate(blinded_input)
27
+
28
+ client.finalize(blinded_output, server.public_key)
29
+ ```
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.14,<2.0"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "voprf"
7
+ requires-python = ">=3.9"
8
+ description = "A verifiable OPRF for Python"
9
+ authors = [{ name = "asterized" }]
10
+ classifiers = [
11
+ "License :: OSI Approved :: BSD License",
12
+ "Programming Language :: Python :: Implementation :: CPython",
13
+ "Programming Language :: Python :: Implementation :: PyPy",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3 :: Only",
16
+ "Programming Language :: Rust",
17
+ "Topic :: Security :: Cryptography",
18
+ "Topic :: Security",
19
+ "Operating System :: OS Independent"
20
+ ]
21
+ license = { file = "LICENSE" }
22
+ dynamic = ["version"]
23
+
24
+ [project.urls]
25
+ homepage = "https://github.com/asterized/voprf"
26
+
27
+ [tool.maturin]
28
+ python-source = "python"
29
+ module-name = "voprf._voprf"
@@ -0,0 +1,4 @@
1
+ from ._voprf import *
2
+
3
+ __name__ = "voprf"
4
+ __version__ = "0.1.0"
@@ -0,0 +1,157 @@
1
+ use voprf::{BlindedElement, EvaluationElement, Group, Proof as _Proof, Ristretto255};
2
+ use pyo3::{exceptions::PyValueError, prelude::*};
3
+ use crate::helpers::implementor;
4
+
5
+ use std::borrow::Cow;
6
+
7
+ implementor!(
8
+ BlindedInput,
9
+ BlindedElement,
10
+ "invalid blinded group element",
11
+ "A blinded OPRF input from a client to be passed into an `Evaluator`."
12
+ );
13
+
14
+ implementor!(
15
+ EvaluatedElement,
16
+ EvaluationElement,
17
+ "invalid blinded OPRF output",
18
+ "A blinded output returned from the evaluator, which can be unblinded by a `Client`."
19
+ );
20
+
21
+ implementor!(
22
+ Proof,
23
+ _Proof,
24
+ "invalid proof element",
25
+ "A proof returned from the server which can validate an `EvaluatedElement`."
26
+ );
27
+
28
+ /// A verifiable output returned from the server, consisting of the blinded output and proof, which
29
+ /// can be finalized by a `Client`.
30
+ #[pyclass]
31
+ pub struct VerifiableOutput {
32
+ pub(crate) output: EvaluatedElement,
33
+
34
+ pub(crate) proof: Proof
35
+ }
36
+
37
+ impl VerifiableOutput {
38
+ pub(crate) fn new(message: EvaluatedElement, proof: Proof) -> Self {
39
+ Self {
40
+ output: message,
41
+ proof: proof
42
+ }
43
+ }
44
+ }
45
+
46
+ #[pymethods]
47
+ impl VerifiableOutput {
48
+ /// Serializes a `VerifiableOutput` into a `bytes` form to be able to be passed over-the-wire,
49
+ /// including its proof and blinded output.
50
+ fn serialize(&self) -> Cow<'_, [u8]> {
51
+ Cow::Owned([self.proof._serialize(), self.output._serialize()].concat())
52
+ }
53
+
54
+ /// Deserializes a `VerifiableOutput` from `bytes`.
55
+ ///
56
+ /// This function may error if the input data is an invalid `VerifiableOutput` representation.
57
+ #[staticmethod]
58
+ fn deserialize(data: Vec<u8>) -> PyResult<Self> {
59
+ if data.len() != 96 {
60
+ return Err(PyValueError::new_err("invalid data"));
61
+ }
62
+
63
+ Ok(VerifiableOutput::new(
64
+ EvaluatedElement::deserialize(&data[64..])?,
65
+ Proof::deserialize(&data[..64])?
66
+ ))
67
+ }
68
+ }
69
+
70
+ #[pyclass]
71
+ pub struct VerifiableBatchOutput {
72
+ pub(crate) output: Vec<EvaluatedElement>,
73
+
74
+ pub(crate) proof: Proof
75
+ }
76
+
77
+ impl VerifiableBatchOutput {
78
+ pub(crate) fn new(messages: Vec<EvaluatedElement>, proof: Proof) -> Self {
79
+ Self {
80
+ output: messages,
81
+ proof: proof
82
+ }
83
+ }
84
+ }
85
+
86
+ #[pymethods]
87
+ impl VerifiableBatchOutput {
88
+ /// Serializes a `VerifiableBatchOutput` into a `bytes` form to be able to be passed over-the-wire,
89
+ /// including its proof and blinded output(s).
90
+ fn serialize(&self) -> Cow<'_, [u8]> {
91
+ let mut output = Vec::with_capacity(64 + 32 * self.output.len());
92
+ output.append(&mut self.proof._serialize());
93
+
94
+ for element in self.output.iter() {
95
+ output.append(&mut element._serialize());
96
+ }
97
+
98
+ Cow::Owned(output)
99
+ }
100
+
101
+ /// Deserializes a `VerifiableBatchOutput` from `bytes`.
102
+ ///
103
+ /// This function may error if the input data is an invalid `VerifiableBatchOutput`
104
+ /// representation.
105
+ #[staticmethod]
106
+ fn deserialize(data: Vec<u8>) -> PyResult<Self> {
107
+ if data.len() < 96 && data.len() % 32 != 0 {
108
+ return Err(PyValueError::new_err("invalid data"));
109
+ }
110
+
111
+ let proof = Proof::deserialize(&data[..64])
112
+ .map_err(|_| PyValueError::new_err("could not deserialize proof"))?;
113
+
114
+ let mut elements: Vec<EvaluatedElement> = Vec::with_capacity(data.len());
115
+
116
+ for chunk in data[64..].chunks(32) {
117
+ elements.push(EvaluatedElement::deserialize(chunk)?);
118
+ }
119
+
120
+ Ok(Self {
121
+ output: elements,
122
+ proof: proof
123
+ })
124
+ }
125
+ }
126
+
127
+ #[pyclass]
128
+ pub struct PublicKey {
129
+ pub(crate) inner: <Ristretto255 as Group>::Elem
130
+ }
131
+
132
+ impl PublicKey {
133
+ pub(crate) fn from_inner(inner: <Ristretto255 as Group>::Elem) -> Self {
134
+ Self {
135
+ inner: inner
136
+ }
137
+ }
138
+ }
139
+
140
+ #[pymethods]
141
+ impl PublicKey {
142
+ /// Serializes a `PublicKey` into a `bytes` form to be transmitted over-the-wire.
143
+ fn serialize(&self) -> Cow<'_, [u8]> {
144
+ Cow::Owned(Ristretto255::serialize_elem(self.inner).to_vec())
145
+ }
146
+
147
+ /// Deserializes raw `bytes` into a `PublicKey`.
148
+ ///
149
+ /// This function may error if the input is an invalid `PublicKey` representation.
150
+ #[staticmethod]
151
+ fn deserialize(raw: &[u8]) -> PyResult<Self> {
152
+ Ok(Self {
153
+ inner: Ristretto255::deserialize_elem(&raw)
154
+ .map_err(|_| PyValueError::new_err("invalid public key"))?
155
+ })
156
+ }
157
+ }
@@ -0,0 +1,49 @@
1
+ macro_rules! implementor {
2
+ (
3
+ $struct:ident,
4
+ $inner:ident,
5
+ $error:expr,
6
+ $comment:expr
7
+ ) => {
8
+ #[pyclass]
9
+ #[doc = $comment]
10
+ pub struct $struct {
11
+ pub(crate) inner: $inner<Ristretto255>
12
+ }
13
+
14
+ impl $struct {
15
+ pub(crate) fn from_inner(inner: $inner<Ristretto255>) -> Self {
16
+ Self { inner }
17
+ }
18
+ }
19
+
20
+ impl $struct {
21
+ fn _serialize(&self) -> Vec<u8> {
22
+ self.inner.serialize().to_vec()
23
+ }
24
+ }
25
+
26
+ #[pymethods]
27
+ impl $struct {
28
+ #[doc = "Serializing a(n)"]
29
+ #[doc = concat!("`", stringify!($struct), "`")]
30
+ #[doc = "into `bytes` to be able to be passed over-the-wire, which can be deserialized back."]
31
+ fn serialize(&self) -> Cow<'_, [u8]> {
32
+ Cow::Owned(self._serialize())
33
+ }
34
+
35
+ #[doc = "Deserializing a(n)"]
36
+ #[doc = concat!("`", stringify!($struct), "`")]
37
+ #[doc = "from `bytes`."]
38
+ #[staticmethod]
39
+ fn deserialize(data: &[u8]) -> PyResult<Self> {
40
+ let deserialized = $inner::<Ristretto255>::deserialize(data)
41
+ .map_err(|_| PyValueError::new_err($error))?;
42
+
43
+ Ok(Self { inner: deserialized })
44
+ }
45
+ }
46
+ };
47
+ }
48
+
49
+ pub(crate) use implementor;
voprf-0.1.0/src/lib.rs ADDED
@@ -0,0 +1,226 @@
1
+ mod elements;
2
+ pub(crate) mod helpers;
3
+
4
+ use pyo3::exceptions::PyValueError;
5
+ use pyo3::prelude::*;
6
+
7
+ use voprf::{BlindedElement, EvaluationElement, Ristretto255, VoprfClient, VoprfClientBlindResult, VoprfServer, VoprfServerBatchEvaluateResult, VoprfServerEvaluateResult};
8
+ use rand::rngs::OsRng;
9
+
10
+ use elements::{EvaluatedElement, BlindedInput, Proof, VerifiableOutput, VerifiableBatchOutput};
11
+
12
+ use crate::elements::PublicKey;
13
+
14
+ use std::borrow::Cow;
15
+
16
+ fn map_error(err: voprf::Error) -> PyErr {
17
+ match err {
18
+ voprf::Error::Batch => PyValueError::new_err("invalid element in messages"),
19
+ voprf::Error::ProofVerification => PyValueError::new_err("could not verify proof"),
20
+ voprf::Error::DeriveKeyPair => PyValueError::new_err("`seed` and `info` combined must be shorter than 2^16 - 4"),
21
+ voprf::Error::Protocol => PyValueError::new_err("key generation could not be completed"),
22
+ voprf::Error::Deserialization => PyValueError::new_err("failed to deserialize client"),
23
+ _ => PyValueError::new_err(format!("error: {:?}", err))
24
+ }
25
+ }
26
+
27
+ /// The equivalent of a Ristretto-255 VOPRF "server" in the RFC 9497 OPRF protocol. The server can take in a `BlindedInput`,
28
+ /// through `Evaluator.evaluate` to return a verifiable blinded output to the client.
29
+ ///
30
+ /// A server can be instantiated (through its default initializer) through a random input of exactly 32 bytes,
31
+ /// equivalent to `Evaluator.from_seed` with an empty info string, or from a seed through a randomly
32
+ /// generated `seed` and `info` bytes. The `seed` should be kept completely secret, but `info` *can*
33
+ /// be public information.
34
+ #[pyclass]
35
+ struct Evaluator {
36
+ state: VoprfServer<Ristretto255>,
37
+ }
38
+
39
+ #[pymethods]
40
+ impl Evaluator {
41
+ #[new]
42
+ fn new(random: &[u8]) -> PyResult<Self> {
43
+ Self::from_seed(random, &[])
44
+ }
45
+
46
+ /// Instantiates a new `Evaluator` from a random `seed` and `info` byte string, equivalent to
47
+ /// the `DeriveKeyPair` function in RFC 9497.
48
+ ///
49
+ /// This function errors when seed is not 32 bytes, or the `seed` and `info` string together are
50
+ /// longer than 2^16 - 4.
51
+ #[staticmethod]
52
+ fn from_seed(seed: &[u8], info: &[u8]) -> PyResult<Self> {
53
+ if seed.len() != 32 {
54
+ return Err(PyValueError::new_err("seed must be 32 bytes"))
55
+ }
56
+
57
+ let server = VoprfServer::new_from_seed(seed, info)
58
+ .map_err(map_error)?;
59
+
60
+ Ok(Self {
61
+ state: server
62
+ })
63
+ }
64
+
65
+ /// Takes in a blinded OPRF input in the form of a `BlindedInput`, and returns a `VerifiableOutput`
66
+ /// consisting of the blinded input and an accompanying verifiable proof that the specified
67
+ /// output was computed by a server holding the given public key.
68
+ ///
69
+ /// Equivalent of `BlindEvaluate` in RFC 9497.
70
+ fn evaluate(&self, input: &BlindedInput) -> VerifiableOutput {
71
+ let VoprfServerEvaluateResult { message, proof } = self.state.blind_evaluate(&mut OsRng, &input.inner);
72
+
73
+ VerifiableOutput::new(EvaluatedElement::from_inner(message), Proof::from_inner(proof))
74
+ }
75
+
76
+ /// Takes in a known input in the form of `bytes` and returns the raw OPRF output in `bytes`.
77
+ ///
78
+ /// Equivalent of OPRF `Evaluate` in RFC 9497.
79
+ ///
80
+ /// This function may error if the input is longer than 2^16 - 1.
81
+ fn evaluate_known_input(&self, input: &[u8]) -> PyResult<Cow<'_, [u8]>> {
82
+ self.state.evaluate(input)
83
+ .map(|x| Cow::Owned(x.to_vec()))
84
+ .map_err(
85
+ |_| PyValueError::new_err("invalid element")
86
+ )
87
+ }
88
+
89
+ /// Takes in a list of `BlindedInput`s and returns a `VerifiableBatchOutput`, consisting of a
90
+ /// batch output which can be verified and recomputed in batch by their respective clients.
91
+ ///
92
+ /// This may error if more than 2^16 - 1 messages are passed in.
93
+ fn evaluate_batch(&self, messages: Vec<PyRefMut<BlindedInput>>) -> PyResult<VerifiableBatchOutput> {
94
+ if messages.len() > u16::MAX as usize {
95
+ return Err(PyValueError::new_err("too many messages"));
96
+ }
97
+
98
+ let VoprfServerBatchEvaluateResult { messages, proof } =
99
+ self.state.batch_blind_evaluate(
100
+ &mut OsRng,
101
+ &messages
102
+ .into_iter()
103
+ .map(|m| m.inner.clone())
104
+ .collect::<Vec<BlindedElement<Ristretto255>>>()
105
+ )
106
+ .map_err(map_error)?;
107
+
108
+ Ok(
109
+ VerifiableBatchOutput::new(
110
+ messages.iter()
111
+ .map(
112
+ |x| EvaluatedElement::from_inner(x.clone()))
113
+ .collect(),
114
+ Proof::from_inner(proof)
115
+ )
116
+ )
117
+ }
118
+
119
+ /// The VOPRF server's public key.
120
+ #[getter]
121
+ fn public_key(&self) -> PublicKey {
122
+ PublicKey::from_inner(self.state.get_public_key())
123
+ }
124
+ }
125
+
126
+ /// A client in the RFC 9497 online protocol, which blinds messages and unblinds outputs from the
127
+ /// server.
128
+ ///
129
+ /// A server may be instantiated using `Client.blind`, which takes in a `bytes` input and returns a
130
+ /// following instantiation of a server and a `BlindedInput`, being the blinded form of the input of
131
+ /// `blind`.
132
+ #[pyclass]
133
+ struct Client {
134
+ state: VoprfClient<Ristretto255>,
135
+
136
+ input: Vec<u8>
137
+ }
138
+
139
+ #[pymethods]
140
+ impl Client {
141
+ /// Blinds an arbitrary input from `bytes` and returns an instantiation of a `Client` and `BlindedInput`.
142
+ ///
143
+ /// This function may error if `input` is empty or is longer than 2^16 - 1.
144
+ #[staticmethod]
145
+ fn blind(input: Vec<u8>) -> PyResult<(Self, BlindedInput)> {
146
+ if input.len() == 0 {
147
+ return Err(PyValueError::new_err("`input` cannot be empty"));
148
+ }
149
+
150
+ let VoprfClientBlindResult { message, state } = VoprfClient::blind(&input, &mut OsRng)
151
+ .map_err(|_| PyValueError::new_err("`input` must be shorter than 2^16 - 1"))?;
152
+
153
+ Ok((
154
+ Self {
155
+ state: state,
156
+ input: input
157
+ },
158
+
159
+ BlindedInput::from_inner(message)
160
+ ))
161
+ }
162
+
163
+ /// Unblinds an output from the server and verifies it with the accompanying proof from the
164
+ /// server's public key, returning a `bytes` object of the unblinded output.
165
+ ///
166
+ /// This function may error if the proof provided by the server is invalid/does not verify
167
+ /// properly with the public key.
168
+ fn finalize(&self, input: &VerifiableOutput, public_key: &PublicKey) -> PyResult<Cow<'_, [u8]>> {
169
+ Ok(Cow::Owned(
170
+ self.state.finalize(
171
+ &self.input,
172
+ &input.output.inner,
173
+ &input.proof.inner,
174
+ public_key.inner
175
+ )
176
+ .map_err(|_| PyValueError::new_err("invalid proof"))?
177
+ .to_vec()
178
+ ))
179
+ }
180
+
181
+ /// Unblinds all messages in a batch server output and verifies it with the accompanying proof
182
+ /// verified with the server's public key, returning a list of `bytes` objects of the unblinded
183
+ /// server outputs.
184
+ ///
185
+ /// This function may error if the number of messages is above 2^16 - 1, the proof could not be
186
+ /// verified or the number of clients does not match the number of blinded outputs.
187
+ #[staticmethod]
188
+ fn finalize_batch<'a>(clients: Vec<PyRef<Self>>, outputs: &VerifiableBatchOutput, public_key: &PublicKey) -> PyResult<Vec<Cow<'a, [u8]>>> {
189
+ if outputs.output.len() != clients.len() {
190
+ return Err(PyValueError::new_err("the number of clients must match the number of blinded outputs"));
191
+ }
192
+
193
+ if clients.len() > u16::MAX as usize {
194
+ return Err(PyValueError::new_err("number of messages must be less than 2^16"));
195
+ }
196
+
197
+ let c: Vec<&Vec<u8>> = clients.iter().map(|x| &x.input).collect();
198
+ Ok(
199
+ VoprfClient::<Ristretto255>
200
+ ::batch_finalize::<&&Vec<u8>, Vec<&Vec<u8>>, Vec<VoprfClient<Ristretto255>>, Vec<EvaluationElement<Ristretto255>>>
201
+ (
202
+ &c,
203
+ &clients.iter().map(|x| x.state.clone()).collect(),
204
+ &outputs.output.iter().map(|x| x.inner.clone()).collect(),
205
+ &outputs.proof.inner,
206
+ public_key.inner
207
+ )
208
+ .unwrap()
209
+ .collect::<Result<Vec<_>, _>>()
210
+ .map_err(|_| PyValueError::new_err("failed to validate proof"))?
211
+ .iter()
212
+ .map(|x| Cow::Owned(x.to_vec()))
213
+ .collect()
214
+ )
215
+ }
216
+ }
217
+
218
+ #[pymodule]
219
+ #[pyo3(name = "_voprf")]
220
+ mod _voprf {
221
+ #[pymodule_export]
222
+ use super::{Evaluator, Client};
223
+
224
+ #[pymodule_export]
225
+ use super::elements::{BlindedInput, EvaluatedElement, Proof, VerifiableOutput, VerifiableBatchOutput};
226
+ }
voprf-0.1.0/uv.lock ADDED
@@ -0,0 +1,7 @@
1
+ version = 1
2
+ revision = 3
3
+ requires-python = ">=3.9"
4
+
5
+ [[package]]
6
+ name = "voprf"
7
+ source = { editable = "." }