You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -17,7 +19,7 @@ The library supports three homomorphic operations on ciphertext `in` (= `Enc(b,
17
19
Decryption will both result in message `M`. Specifically, `in = Enc(r, M, Y)` is transformed to `out = Enc(r, M, k*Y)`.
18
20
-`out = reshuffle(in, s)`: modifies a ciphertext `in` (an encrypted form of `M`), so that after decryption of `out` the decrypted message will be equal to `s*M`.
19
21
Specifically, `in = Enc(r, M, Y)` is transformed to `out = Enc(r, n*M, Y)`.
20
-
-`out = rerandomize(in, r)`: scrambles a ciphertext.
22
+
-`o = rerandomize(in, r)`: scrambles a ciphertext.
21
23
Both `in` and `out` can be decrypted by the same secret key `y`, both resulting in the same decrypted message `M`.
22
24
However, the binary form of `in` and `out` differs. Spec: `in = Enc(b, M, Y)` is transformed to `out = Enc(r+b, M, Y)`;
23
25
@@ -29,7 +31,65 @@ The key idea behind this form of cryptography is that the pseudonymization and r
29
31
This means that during initial encryption, the ultimate receiver(s) do(es) not yet need to be known.
30
32
Data can initially be encrypted for one key, and later rekeyed and potentially reshuffled (in case of identifiers) for another key, leading to asynchronous end-to-end encryption with built-in pseudonymisation.
31
33
32
-
Apart from a Rust crate, this library also contains a WASM library for usage in the browser or web applications with a similar API, enabled with the `wasm` feature.
34
+
Apart from a Rust crate, this library provides bindings for multiple platforms:
35
+
36
+
## Language Bindings
37
+
38
+
### Python
39
+
40
+
Install from PyPI:
41
+
```bash
42
+
pip install libpep
43
+
```
44
+
45
+
Use with direct imports from submodules:
46
+
```python
47
+
from libpep.high_level import Pseudonym, DataPoint, make_global_keys
48
+
from libpep.arithmetic import GroupElement, ScalarNonZero
49
+
50
+
# Generate keys
51
+
keys = make_global_keys()
52
+
53
+
# Create and work with pseudonyms
54
+
pseudonym = Pseudonym.random()
55
+
print(f"Pseudonym: {pseudonym.as_hex()}")
56
+
57
+
# Create data points
58
+
data = DataPoint.random()
59
+
print(f"Data point: {data.as_hex()}")
60
+
```
61
+
62
+
### WebAssembly (WASM)
63
+
64
+
Install from npm:
65
+
```bash
66
+
npm install @nolai/libpep-wasm
67
+
```
68
+
69
+
Use in Node.js or browser applications:
70
+
```javascript
71
+
import*aslibpepfrom'@nolai/libpep-wasm';
72
+
73
+
// Generate keys
74
+
constkeys=libpep.make_global_keys();
75
+
76
+
// Create and work with pseudonyms
77
+
constpseudonym=libpep.Pseudonym.random();
78
+
console.log(`Pseudonym: ${pseudonym.as_hex()}`);
79
+
80
+
// Create data points
81
+
constdata=libpep.DataPoint.random();
82
+
console.log(`Data point: ${data.as_hex()}`);
83
+
```
84
+
85
+
### API Structure
86
+
87
+
Both Python and WASM bindings mirror the Rust API structure with the same modules:
88
+
-`arithmetic` - Basic arithmetic operations on scalars and group elements
89
+
-`elgamal` - ElGamal encryption and decryption
90
+
-`primitives` - Core PEP operations (`rekey`, `reshuffle`, `rerandomize`)
91
+
-`high_level` - User-friendly API with `Pseudonym` and `DataPoint` classes
92
+
-`distributed` - Distributed n-PEP operations with multiple servers
33
93
34
94
## Applications
35
95
@@ -70,15 +130,39 @@ We offer APIs at different abstraction levels.
70
130
71
131
Depending on the use case, you can choose the appropriate level of abstraction.
72
132
73
-
## Building and running
133
+
## Development
74
134
75
-
Build using cargo: `cargo build` and test using `cargo test`.
135
+
Build and test the core Rust library:
136
+
```bash
137
+
cargo build
138
+
cargo test
139
+
cargo doc --no-deps
140
+
```
141
+
142
+
## Building Bindings
143
+
144
+
### Python
76
145
77
-
To build the WASM library, use either `npm run build:nodejs` or `npm run build:web` (which will call `wasm-pack build --features wasm` for the preferred target).
146
+
To build Python bindings for testing:
147
+
```bash
148
+
python -m venv .venv
149
+
source .venv/bin/activate
150
+
pip install -e ".[dev]"
151
+
maturin develop --features python
152
+
python -m pytest tests/python/ -v
153
+
```
154
+
155
+
### WASM
78
156
79
-
The wasm library can be tested using the Node.js `jest` framework, after compiling the wasm library for Node.js: `npm run test`.
157
+
To build WASM bindings for testing:
158
+
```bash
159
+
npm install
160
+
npm run build # Builds both Node.js and web targets
161
+
npm test
162
+
```
80
163
81
164
The following features are available:
165
+
-`python`: enables the Python bindings.
82
166
-`wasm`: enables the WASM library.
83
167
-`elgamal3`: enables longer ElGamal for debugging purposes or backward compatibility, but with being less efficient.
84
168
-`legacy-pep-repo-compatible`: enables the legacy PEP repository compatible mode, which uses a different function to derive scalars from domains, contexts and secrets.
0 commit comments