Skip to content

Commit 20fcc38

Browse files
authored
Refactor (#18)
* Restructure * Safety * Refactor scalars and distributed keys * Big refactor * Fixes * Fixes * More refactoring * Add tests * Fix' * Fix refactors * Fix tests * Fix more tests * Fix one more test * Update CI/CD * Cleanup * Fix * fix export * PEPJson * PEPjson wasm and python * Fix * Improve and fix PEP json * Fix clippy * Update * Updates * Fixes * Fixes * Fixes
1 parent a3f9312 commit 20fcc38

File tree

161 files changed

+20470
-10979
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+20470
-10979
lines changed

.github/workflows/build-and-test.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,49 @@ on:
99
jobs:
1010
semver-checks:
1111
runs-on: ubuntu-latest
12-
1312
name: cargo semver-checks
1413
steps:
1514
- uses: actions/checkout@v4
1615
- uses: obi1kenobi/cargo-semver-checks-action@v2
16+
with:
17+
# Check default feature set, plus elgamal3 and legacy.
18+
# python/wasm bindings are not included here (and remain mutually exclusive).
19+
feature-group: default-features
20+
features: elgamal3,legacy,insecure
1721

1822
test:
1923
runs-on: ubuntu-latest
2024
strategy:
25+
fail-fast: false
2126
matrix:
2227
features:
2328
- ""
2429
- "elgamal3"
25-
- "legacy-pep-repo-compatible"
26-
- "elgamal3,legacy-pep-repo-compatible"
30+
- "legacy"
31+
- "elgamal3,legacy"
2732

28-
name: cargo test
33+
name: cargo test (${{ matrix.features || 'default' }})
2934
steps:
3035
- uses: actions/checkout@v4
3136
- uses: actions-rust-lang/setup-rust-toolchain@v1
37+
- uses: Swatinem/rust-cache@v2
3238
- run: cargo test --features "${{ matrix.features }}"
3339

3440
build-wasm:
3541
runs-on: ubuntu-latest
3642
needs: test
3743
strategy:
44+
fail-fast: false
3845
matrix:
3946
target: [ "web", "nodejs" ]
40-
features: [ "", "elgamal3" ]
47+
features:
48+
- "wasm"
49+
- "wasm,elgamal3"
4150

42-
name: wasm-pack build
51+
name: wasm-pack build (${{ matrix.target }}, ${{ matrix.features }})
4352
steps:
4453
- uses: actions/checkout@v4
4554
- uses: actions-rust-lang/setup-rust-toolchain@v1
55+
- uses: Swatinem/rust-cache@v2
4656
- run: cargo install wasm-pack
47-
- run: npm install
48-
- run: npm test
49-
- run: wasm-pack build --target ${{ matrix.target }} --features "wasm,${{ matrix.features }}"
57+
- run: wasm-pack build --target ${{ matrix.target }} --features "${{ matrix.features }}"

.github/workflows/check-version.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ on:
88
jobs:
99
semver-checks:
1010
runs-on: ubuntu-latest
11-
1211
name: cargo semver-checks
1312
steps:
1413
- uses: actions/checkout@v4
1514
- uses: obi1kenobi/cargo-semver-checks-action@v2
15+
with:
16+
# Check default feature set, plus elgamal3 and legacy.
17+
# python/wasm bindings are not included here (and remain mutually exclusive).
18+
feature-group: default-features
19+
features: elgamal3,legacy,insecure
1620

1721
check-versions:
1822
runs-on: ubuntu-latest

.github/workflows/lint-and-test.yml

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,22 @@ on:
88
jobs:
99
lint:
1010
runs-on: ubuntu-latest
11-
name: cargo clippy
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
features:
15+
- ""
16+
- "elgamal3"
17+
- "python"
18+
- "python,elgamal3"
19+
- "wasm"
20+
- "wasm,elgamal3"
21+
name: cargo clippy (${{ matrix.features || 'default' }})
1222
steps:
1323
- uses: actions/checkout@v4
1424
- uses: actions-rust-lang/setup-rust-toolchain@v1
15-
- run: cargo clippy --all-targets --all-features -- -D warnings
25+
- uses: Swatinem/rust-cache@v2
26+
- run: cargo clippy --all-targets --features "${{ matrix.features }}" -- -D warnings
1627

1728
fmt:
1829
runs-on: ubuntu-latest
@@ -24,20 +35,33 @@ jobs:
2435

2536
test:
2637
runs-on: ubuntu-latest
27-
name: cargo test
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
features:
42+
- ""
43+
- "elgamal3"
44+
- "python"
45+
- "python,elgamal3"
46+
- "wasm"
47+
- "wasm,elgamal3"
48+
name: cargo test (${{ matrix.features || 'default' }})
2849
steps:
2950
- uses: actions/checkout@v4
3051
- uses: actions-rust-lang/setup-rust-toolchain@v1
31-
- run: cargo test --all-features
32-
- run: cargo doc --no-deps
52+
- uses: Swatinem/rust-cache@v2
53+
54+
- run: cargo test --features "${{ matrix.features }}"
55+
- run: cargo doc --no-deps --features "${{ matrix.features }}"
3356

3457
test-python:
3558
runs-on: ubuntu-latest
3659
name: test python bindings
3760
steps:
3861
- uses: actions/checkout@v4
3962
- uses: actions-rust-lang/setup-rust-toolchain@v1
40-
- uses: actions/setup-python@v4
63+
- uses: Swatinem/rust-cache@v2
64+
- uses: actions/setup-python@v5
4165
with:
4266
python-version: '3.x'
4367
- name: Create virtual environment
@@ -58,12 +82,11 @@ jobs:
5882
steps:
5983
- uses: actions/checkout@v4
6084
- uses: actions-rust-lang/setup-rust-toolchain@v1
85+
- uses: Swatinem/rust-cache@v2
6186
- uses: actions/setup-node@v4
6287
with:
6388
node-version: '20.x'
6489
- run: cargo install wasm-pack
6590
- run: npm install
66-
- name: Build WASM package
67-
run: npm run build
68-
- name: Run WASM tests
69-
run: npm test
91+
- name: Build and test WASM package
92+
run: npm test

.github/workflows/publish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ on:
77
jobs:
88
semver-checks:
99
runs-on: ubuntu-latest
10-
1110
name: cargo semver-checks
1211
steps:
1312
- uses: actions/checkout@v4
1413
- uses: obi1kenobi/cargo-semver-checks-action@v2
14+
with:
15+
# Check default feature set, plus elgamal3 and legacy.
16+
# python/wasm bindings are not included here (and remain mutually exclusive).
17+
feature-group: default-features
18+
features: elgamal3,legacy,insecure
1519

1620
publish-crate:
1721
runs-on: ubuntu-latest
@@ -24,6 +28,7 @@ jobs:
2428
steps:
2529
- uses: actions/checkout@v4
2630
- uses: actions-rust-lang/setup-rust-toolchain@v1
31+
- uses: Swatinem/rust-cache@v2
2732
- uses: rust-lang/crates-io-auth-action@v1
2833
id: auth
2934
- run: cargo publish
@@ -41,6 +46,7 @@ jobs:
4146
steps:
4247
- uses: actions/checkout@v4
4348
- uses: actions-rust-lang/setup-rust-toolchain@v1
49+
- uses: Swatinem/rust-cache@v2
4450
- uses: actions/setup-node@v4
4551
with:
4652
node-version: '22.x'

Cargo.toml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
[package]
22
name = "libpep"
33
edition = "2021"
4-
version = "0.7.5"
4+
version = "0.8.0"
55
authors = ["Bernard van Gastel <bvgastel@bitpowder.com>", "Job Doesburg <job@jobdoesburg.nl>"]
66
homepage = "https://github.com/NOLAI/libpep"
77
repository = "https://github.com/NOLAI/libpep"
88
documentation = "https://docs.rs/libpep"
99
license = "Apache-2.0"
1010
keywords = ["crypto", "pep", "pseudonymization"]
1111
categories = ["cryptography", "algorithms"]
12-
description = "Implementation of PEP primitives, offering pseudonymization and encryption interfaces"
12+
description = "Library for polymorphic encryption and pseudonymization"
1313
readme = "README.md"
1414

1515
[features]
16-
default = ["build-binary"]
17-
elgamal3 = []
18-
wasm = ["wasm-bindgen", "getrandom"]
19-
python = ["pyo3"]
20-
legacy-pep-repo-compatible = []
21-
insecure-methods = []
22-
build-binary = ["buildinfy","commandy","commandy_macros"]
16+
default = ["build-binary", "long", "offline", "batch", "serde", "json"]
17+
serde = ["dep:serde"] # For (de)serialization support via Serde
18+
elgamal3 = [] # For ElGamal triple encryption, including the recipient's public key in message encoding
19+
offline = [] # For encryption towards global keys (instead of encryption with session keys)
20+
batch = [] # For batch transcryption with reordering to prevent linkability
21+
long = [] # For long pseudonyms and attributes over 15 bytes
22+
json = ["serde", "dep:serde_json"] # For JSON encryption/decryption support
23+
global-pseudonyms = ["offline"] # Allow pseudonyms in a global domain (uses global pseudonyms with reshuffle factor 1), which is potentially insecure
24+
legacy = ["elgamal3", "offline", "global-pseudonyms"] # For compatibility with the legacy PEP repository implementation
25+
insecure = [] # Enable insecure methods that typically should not be used in production (does not include "global-pseudonyms", which is a separate feature)
26+
build-binary = ["buildinfy","commandy","commandy_macros","rand"] # Build the peppy command line utility
2327

28+
wasm = ["wasm-bindgen", "serde-wasm-bindgen", "js-sys", "getrandom/wasm_js"] # For building WebAssembly bindings via wasm-bindgen
29+
python = ["pyo3"] # For building Python bindings via PyO3
2430
# Note: python and wasm are mutually exclusive and should not be enabled together.
25-
# PyO3 builds a cdylib that links to Python interpreter, while wasm-bindgen builds
31+
# PyO3 builds a cdylib that links to the Python interpreter, while wasm-bindgen builds
2632
# a cdylib targeting WebAssembly - they have incompatible linking requirements.
2733

2834
[lib]
@@ -35,24 +41,28 @@ name = "peppy"
3541
required-features = ["build-binary"]
3642

3743
[dependencies]
38-
curve25519-dalek-libpep = { version = "^4.0", features = ["rand_core"] } # This is a published fork of signalapp/curve25519-dalek, which is a fork of popular dalek-cryptography/curve25519-dalek implementing lizard support
39-
rand = { version = "^0.8", features = ["std"] }
40-
rand_core = { version = "^0.6", features = ["std"] }
41-
sha2 = "^0.10"
42-
hmac = "^0.12"
43-
derive_more = { version = "^1.0", features = ["deref", "from", "into"] }
44+
curve25519-dalek = { version = "^ 5.0.0-pre.2", features = ["rand_core", "lizard"] }
45+
rand_core = "0.10.0-rc.2"
46+
rand = { version = "0.10.0-rc.5", optional = true }
47+
sha2 = "^0.11.0-rc.3"
48+
hmac = "^0.13.0-rc.3"
49+
derive_more = { version = "^2.0", features = ["deref", "from", "into"] }
4450
hex = "^0.4"
4551
base64 = "^0.22"
46-
serde = { version = "^1.0", features = ["derive"] }
52+
serde = { version = "^1.0", features = ["derive"], optional = true }
53+
serde_json = { version = "^1.0", optional = true }
4754
wasm-bindgen = { version = "0.2", optional = true }
48-
getrandom = { version = "^0.2", features = ["js"], optional = true}
55+
serde-wasm-bindgen = { version = "0.6", optional = true }
56+
js-sys = { version = "0.3", optional = true }
57+
getrandom = { version = "0.3", optional = true }
4958
pyo3 = { version = "0.27", features = ["extension-module"], optional = true }
5059
buildinfy = { version = "^0.1", optional = true }
5160
commandy = { version = "^0.2", optional = true }
5261
commandy_macros = { version = "^0.2", optional = true }
5362

5463
[dev-dependencies]
5564
serde_json = "^1.0"
65+
rand = "0.10.0-rc.5"
5666

5767
[package.metadata.deb]
5868
name = "peppy"
@@ -67,3 +77,14 @@ assets = [
6777
["peppy.1", "man/man1/", "444"],
6878
["target/release/peppy", "bin/peppy", "555"],
6979
]
80+
81+
[package.metadata.docs.rs]
82+
features = ["offline", "batch", "long", "serde", "elgamal3", "insecure"]
83+
rustdoc-args = ["--cfg", "docsrs"]
84+
85+
[lints.rust]
86+
unsafe_code = "deny"
87+
88+
[lints.clippy]
89+
unwrap_used = "deny"
90+
expect_used = "deny"

0 commit comments

Comments
 (0)