Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bindings python #65

Merged
merged 39 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
55f521b
fix: use "develop" branch of CryptoCore
tbrezot Nov 3, 2022
2998ad7
[PyO3] Rewrite to a more object oriented syntax
Nov 3, 2022
9d1b1f6
[PyO3] Adding user secret key generation
Nov 3, 2022
9152727
[PyO3] Adding encrypt and decrypt (header + symm)
Nov 3, 2022
fc5c35a
[PyO3] Adding individual header and symmetric encryption
Nov 3, 2022
8959e1a
[PyO3] Fix fmt
Nov 3, 2022
6447bd7
[PyO3] Adding Policy and Encryption tests
Nov 4, 2022
bceae2f
[PyO3] Adding header encryption test
Nov 4, 2022
8cbd6fa
[PyO3] Refacto tests
Nov 4, 2022
4136e01
edit test_rotate_then_encrypt
Nov 4, 2022
b2f21aa
[PyO3] fix rotate test
Nov 4, 2022
b082505
[PyO3] testing different serialization/copy method
Nov 4, 2022
f3f4b9d
[PyO3] feat: add JSON serialization for the Policy python object
Nov 7, 2022
071b48e
[PyO3] feat: add byte serialization for keys
Nov 7, 2022
4772999
[PyO3] refactor: split abe_policy and cover_crypt methods
Nov 7, 2022
a77030d
[PyO3] test: add symmetric key serialization test
Nov 8, 2022
275ac2c
[PyO3] ci: adding automatic build and test for the python lib
Nov 8, 2022
4b20158
[PyO3] fix: cargo clippy error
Nov 8, 2022
2ca0dc5
ci(PyO3): split build and test in 2 different stage
Nov 8, 2022
c8e87b0
ci(PyO3): fix python build
Nov 8, 2022
2718665
ci(PyO3): fix maturin image entrypoint
Nov 8, 2022
263143d
ci(PyO3): using cache from base_compile for python build
Nov 8, 2022
5c81d71
ci(PyO3): remove base_compile from build_python due to sscache
Nov 8, 2022
adb2e1a
ci(PyO3): add automatic publishing to Pypi
Nov 8, 2022
d87877e
fix(PyO3): apply suggestions from code review
ackRow Nov 10, 2022
557fef0
fix(PyO3): change default PyErr to PyException
Nov 10, 2022
51b797a
fix(PyO3): use PyErr::from
Nov 10, 2022
d498641
fix(PyO3): update refresh_user_secret_key comment
ackRow Nov 10, 2022
cda9980
refactor(PyO3): add explicit map_err
Nov 10, 2022
b35b748
refactor(PyO3): update comments
Nov 10, 2022
9ce5a4b
refactor(PyO3): change from String to &str to avoid copy
Nov 10, 2022
80a12ea
fix(PyO3): typo in Changelog
Nov 10, 2022
5130d42
refactor(PyO3): simplify struct field
Nov 11, 2022
a9e21af
refactor(PyO3): clippy redundant closure
Nov 11, 2022
5a5127d
refactor(PyO3): apply suggestions from Manuthor
ackRow Nov 14, 2022
69ea5d2
refactor(PyO3): update tabs in pyproject
Nov 14, 2022
e9100ef
build(PyO3): update cicd comments
Nov 15, 2022
b768315
build(PyO3): set crypto core version
Nov 15, 2022
073e643
fix(PyO3): remove crypto core git field
Nov 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
image: gitlab.cosmian.com:5000/core/ci-rust:latest

variables:
Expand Down Expand Up @@ -67,7 +68,7 @@ is_publishable:
.base_compile: &base_compile
stage: build
cache:
key: "${CI_COMMIT_REF_SLUG}"
key: ${CI_COMMIT_REF_SLUG}
policy: pull
paths:
- $CARGO_HOME
Expand Down Expand Up @@ -144,6 +145,19 @@ build_android:
- jniLibs
expire_in: 3 mos

build_python:
stage: build
image:
name: ghcr.io/pyo3/maturin
# override the image entrypoint
entrypoint: ['']
script:
- maturin build --release --features python
artifacts:
paths:
- target/wheels/*.whl
expire_in: 3 mos

test_cloudproof_java:
image: openjdk:8
stage: test
Expand All @@ -159,12 +173,8 @@ test_cloudproof_java:
test_python:
stage: test
script:
- maturin build --release --features python
- bash src/interfaces/pyo3/tests/test.sh
artifacts:
paths:
- target/wheels/*.whl
expire_in: 3 mos
- pip install --force-reinstall target/wheels/cover_crypt*.whl
- python3 src/interfaces/pyo3/tests/test_cover_crypt.py

test_cloudproof_js:
image: node:16
Expand All @@ -181,13 +191,13 @@ test_cloudproof_js:
pack_all_artifacts:
stage: pack
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
- if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/
before_script:
- apt update && apt install -y zip
script:
- zip -r ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}-bin.zip pkg target jniLibs
artifacts:
name: "cosmian_${CI_PROJECT_NAME}_${CI_COMMIT_TAG}"
name: cosmian_${CI_PROJECT_NAME}_${CI_COMMIT_TAG}
paths:
- ${CI_PROJECT_NAME}-${CI_COMMIT_TAG}-bin.zip
expire_in: 3 mos
Expand All @@ -196,7 +206,7 @@ npm_publish:
image: gitlab.cosmian.com:5000/core/ci-npm:latest
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
- if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/
script:
- echo "//registry.npmjs.org/:_authToken=$NPM_ACCESS_TOKEN" > ~/.npmrc
- wasm-pack build --target web --release --features wasm_bindgen
Expand All @@ -206,7 +216,7 @@ npm_publish:
cargo_publish:
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
- if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/
script:
- echo "[registry]" > ~/.cargo/credentials
- echo "token = \"$CRATES_IO\"" >> ~/.cargo/credentials
Expand All @@ -217,11 +227,19 @@ cargo_publish:
- cargo publish --token $CRATES_IO
- rm -rf /tmp/${CI_PROJECT_NAME}

python_publish:
stage: publish
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/
script:
- pip install twine
- twine upload -u "${PYPI_USERNAME}" -p "${PYPI_PASSWORD}" target/wheels/cover_crypt-${CI_COMMIT_TAG}*.whl

# Finally, run benchmarks at once
benchmarks:
stage: publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/'
- if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+$/
before_script:
- apt update && apt install -y gnuplot
script:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
### Changed

- improve serialization
- new python interfaces based on objects rather than functions

### Fixed

Expand Down Expand Up @@ -57,6 +58,7 @@ All notable changes to this project will be documented in this file.
---

---

## [6.0.8] - 2022-10-17

### Added
Expand All @@ -68,14 +70,17 @@ All notable changes to this project will be documented in this file.
### Fixed

### Removed

---

---

## [6.0.7] - 2022-10-14

### Added

- expose boolean Access Policy parsing in WASM

### Fixed

### Removed
Expand Down
46 changes: 28 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ zeroize = "1.5"
# Optional ones
js-sys = { version = "0.3", optional = true }
lazy_static = { version = "1.4", optional = true }
pyo3 = { version = "0.16.3", features = ["extension-module"], optional = true }
# Build python package for version 3.7 and above: https://pyo3.rs/v0.17.3/features.html
pyo3 = { version = "0.17.3", features = ["extension-module", "abi3", "abi3-py37"], optional = true }
wasm-bindgen = { version = "0.2", features = [
"serde-serialize",
], optional = true }
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
[build-system]
requires = ["maturin>=0.12,<0.13"]
requires = ["maturin>=0.13,<0.14"]
build-backend = "maturin"

[tool.maturin]
# https://github.com/pypa/manylinux#manylinux
compatibility = "manylinux_2_17"

[project]
name = "cover_crypt"
requires-python = ">=3.6"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum Error {
#[error("could not decode number of attributes in encrypted message")]
DecodingAttributeNumber,
#[error(
"Unable to decrypt the header size. User decryption key has not the right policy to \
"Unable to decrypt the header. User decryption key has not the right policy to \
decrypt this input."
)]
InsufficientAccessPolicy,
Expand Down
92 changes: 0 additions & 92 deletions src/interfaces/pyo3/generate_cc_keys.rs

This file was deleted.

Loading