Skip to content

Commit ff3de5c

Browse files
committed
chore: Merge branch 'release/v4.0.0'
2 parents 3fa0eda + ac063cf commit ff3de5c

File tree

24 files changed

+579
-160
lines changed

24 files changed

+579
-160
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
pip install flake8
1919
- name: Linter
2020
run: |
21-
flake8 --max-line-length=100
21+
flake8 --max-line-length=100 --ignore E501
2222
- name: Build package
2323
run: |
2424
python -m build
@@ -62,9 +62,10 @@ jobs:
6262
pip install cloudproof_py*.whl
6363
- name: Type-check
6464
run: |
65-
mypy src/cloudproof_py/findex/
65+
mypy src/cloudproof_py/anonymization/
6666
mypy src/cloudproof_py/cover_crypt/
67-
mypy src/cloudproof_py/cloudproof_fpe/
67+
mypy src/cloudproof_py/findex/
68+
mypy src/cloudproof_py/fpe/
6869
mypy tests/
6970
mypy examples/cli_demo
7071
mypy examples/findex_upsert_search
@@ -88,12 +89,13 @@ jobs:
8889
needs: test
8990
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof_java_in_docker.yml@develop
9091
with:
91-
branch: develop
92+
branch: v6.0.0
9293
target: x86_64-unknown-linux-gnu
9394
extension: so
9495
destination: linux-x86-64
9596
os: ubuntu-20.04
9697
kms-version: 4.3.3
98+
findex-cloud-version: 0.1.0
9799
copy_fresh_build: false
98100
copy_regression_files: |
99101
cp ./cloudproof_python/non_regression_vector.json src/test/resources/cover_crypt/non_regression/python_non_regression_vector.json
@@ -116,7 +118,7 @@ jobs:
116118
- test
117119
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof_flutter.yml@develop
118120
with:
119-
branch: develop
121+
branch: v7.0.0
120122
target: x86_64-unknown-linux-gnu
121123
extension: so
122124
copy_fresh_build: false

.github/workflows/publish.yml

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,48 @@
1-
name: Publish
1+
name: Build doc, release and publish
22

3-
on:
4-
push:
5-
tags:
6-
- '*'
3+
on: [push]
74

85
jobs:
6+
build_doc:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v3
11+
with:
12+
python-version: 3.7
13+
- name: Install dependencies
14+
run: |
15+
python -m pip install --upgrade pip
16+
scripts/ci_install_pyo3_builds.sh
17+
pip install -r docs/requirements.txt
18+
- name: Build package
19+
run: |
20+
python scripts/extract_lib_types.py
21+
cd docs
22+
make html
23+
cd _build
24+
zip -r ../../Documentation.zip html/
25+
- uses: actions/upload-artifact@v3
26+
with:
27+
name: html_doc
28+
path: Documentation.zip
29+
retention-days: 1
30+
931
release:
32+
needs: build_doc
1033
runs-on: ubuntu-latest
1134
steps:
1235
- uses: actions/checkout@v3
13-
- name: Release
36+
- name: Download artifact
37+
uses: actions/download-artifact@v3
38+
with:
39+
name: html_doc
40+
path: .
41+
- name: Release on tags, attach asset on release
42+
if: startsWith(github.ref, 'refs/tags/')
1443
uses: softprops/action-gh-release@v1
44+
with:
45+
files: Documentation.zip
1546

1647
publish:
1748
runs-on: ubuntu-latest
@@ -27,29 +58,8 @@ jobs:
2758
pip install twine
2859
python -m build
2960
- name: Upload to Pypi
61+
if: startsWith(github.ref, 'refs/tags/')
3062
run: twine upload -u "${PYPI_USERNAME}" -p "${PYPI_PASSWORD}" dist/cloudproof_py*.whl
3163
env:
3264
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
3365
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
34-
35-
docs:
36-
runs-on: ubuntu-latest
37-
steps:
38-
- uses: actions/checkout@v3
39-
- uses: actions/setup-python@v3
40-
with:
41-
python-version: 3.7
42-
- name: Install dependencies
43-
run: |
44-
python -m pip install --upgrade pip
45-
scripts/ci_install_pyo3_builds.sh
46-
pip install -r docs/requirements.txt
47-
- name: Build package
48-
run: |
49-
python scripts/extract_lib_types.py
50-
cd docs && make html
51-
- uses: actions/upload-artifact@v3
52-
with:
53-
name: html_doc
54-
path: docs/_build/html
55-
retention-days: 60

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,37 @@ repos:
3333
- id: trailing-whitespace
3434

3535
- repo: https://github.com/compilerla/conventional-pre-commit
36-
rev: v2.1.1
36+
rev: v2.2.0
3737
hooks:
3838
- id: conventional-pre-commit
3939
stages: [commit-msg]
4040
args: [] # optional: list of Conventional Commits types to allow e.g. [feat, fix, ci, chore, test]
4141

4242
- repo: https://github.com/pre-commit/mirrors-prettier
43-
rev: v3.0.0-alpha.6
43+
rev: v3.0.0-alpha.9-for-vscode
4444
hooks:
4545
- id: prettier
4646
types_or: [css, javascript, jsx, markdown, bash, java, sh]
4747

4848
- repo: https://github.com/psf/black
49-
rev: 23.1.0
49+
rev: 23.3.0
5050
hooks:
5151
- id: black
5252

5353
- repo: https://github.com/pycqa/flake8
5454
rev: 6.0.0
5555
hooks:
5656
- id: flake8
57-
args: [--max-line-length=100]
57+
args: ["--max-line-length=100", "--ignore", "E501"]
5858

5959
- repo: https://github.com/pre-commit/mirrors-mypy
60-
rev: 'v1.1.1'
60+
rev: 'v1.3.0'
6161
hooks:
6262
- id: mypy
6363
additional_dependencies: [types_termcolor==1.1.6, types_redis==4.3.21.6, types-requests==2.28.11.15, types-urllib3==1.26.25.8]
6464

6565
- repo: https://github.com/igorshubovych/markdownlint-cli
66-
rev: v0.33.0
66+
rev: v0.34.0
6767
hooks:
6868
- id: markdownlint-fix
6969
args:

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [4.0.0] - 2023-06-01
6+
7+
### Features
8+
9+
- upgrade Findex (v3.0.0 -> v4.0.0):
10+
- change indexed values size (require a reset of the index database)
11+
- change search interface
12+
- change parameter order
13+
- remove `max_result_per_keyword`
14+
- remove `max_depth`
15+
- remove `fetch_chains_batch_size`
16+
- searching for a non indexed keyword leads to an empty array for this
17+
keyword in the search results instead of this keyword being missing from
18+
the results.
19+
- change upsert interface:
20+
- change parameter order
21+
- add deletions
22+
- change compact interface:
23+
- change parameter order
24+
- add data anonymization methods such as:
25+
- noise methods
26+
- hash methods
27+
- number methods
28+
- word methods
29+
530
---
631

732
## [3.1.0] - 2023-04-06

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,23 @@ examples/cli_demo/run_demo.sh
6161
To build from source:
6262

6363
```sh
64-
scripts/build.sh [-i]
64+
scripts/build.sh
6565
```
6666

67-
**Note**: add `-i` to install after build.
68-
6967
To build and run the tests:
7068

69+
```sh
70+
scripts/build.sh -t
71+
```
72+
73+
With PyO3 packages from [package.cosmian.com](https://package.cosmian.com):
74+
7175
```sh
7276
scripts/build.sh -it
7377
```
7478

79+
**Note**: edit [scripts/ci_install_pyo3_builds.sh](./scripts/ci_install_pyo3_builds.sh) with the right build name.
80+
7581
To build the documentation:
7682

7783
```sh
@@ -88,6 +94,7 @@ This table shows the minimum version correspondence between the various componen
8894

8995
| `cloudproof_py` | CoverCrypt | Findex | KMS |
9096
| --------------- | ---------- | ----------- | ----- |
97+
| >=4.0.0 | 11.0.0 | 4.0.0,4.0.1 | 4.3.3 |
9198
| >=3.0.0 | 11.0.0 | 3.0.0 | 4.3.3 |
9299
| >=2.0.0 | 10.0.0 | 2.0.1,2.1.0 | 4.2.0 |
93100
| >=1.0.0 | 8.0.1 | 2.0.0 | - |

examples/cli_demo/findex_db.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22
import sqlite3
3-
from cloudproof_py.findex import Findex
3+
from typing import Dict, List, Set, Tuple, Sequence
44

5-
from typing import Dict, List, Set, Tuple
5+
from cloudproof_py.findex import Findex
66

77

88
class FindexSQLite(Findex.FindexUpsert, Findex.FindexSearch):
@@ -12,25 +12,27 @@ def __init__(self, db_conn: sqlite3.Connection) -> None:
1212
super().__init__()
1313
self.conn = db_conn
1414

15-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
15+
def fetch_entry_table(
16+
self, entry_uids: List[bytes]
17+
) -> Sequence[Tuple[bytes, bytes]]:
1618
"""Query the Entry Table.
1719
1820
Args:
1921
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
2022
2123
Returns:
22-
Dict[bytes, bytes]: uid -> value mapping
24+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
2325
"""
2426
str_uids = ",".join("?" * len(entry_uids))
2527
cur = self.conn.execute(
2628
f"SELECT uid, value FROM entry_table WHERE uid IN ({str_uids})",
2729
entry_uids,
2830
)
2931
values = cur.fetchall()
30-
output_dict = {}
32+
output_array = []
3133
for value in values:
32-
output_dict[value[0]] = value[1]
33-
return output_dict
34+
output_array.append((value[0], value[1]))
35+
return output_array
3436

3537
def fetch_all_entry_table_uids(self) -> Set[bytes]:
3638
"""Return all UIDs in the Entry Table.

examples/cli_demo/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
}
133133
# Upsert keywords
134134
findex_interface.upsert(
135-
mapping_indexed_values_to_keywords, findex_master_key, findex_label
135+
findex_master_key, findex_label, mapping_indexed_values_to_keywords, {}
136136
)
137137
print("Findex: Done indexing", len(users), "users")
138138
print(
@@ -142,9 +142,10 @@
142142
if activate_auto_completion:
143143
keywords = [keyword.lower() for user in users for keyword in user.values()]
144144
findex_interface.upsert(
145-
findex.utils.generate_auto_completion(keywords),
146145
findex_master_key,
147146
findex_label,
147+
findex.utils.generate_auto_completion(keywords),
148+
{},
148149
)
149150

150151
cc_user_keys = {"Alice": key_Alice, "Bob": key_Bob, "Charlie": key_Charlie}
@@ -168,7 +169,7 @@
168169

169170
# 1. Findex search
170171
found_users = findex_interface.search(
171-
[keyword], findex_master_key, findex_label
172+
findex_master_key, findex_label, [keyword]
172173
)
173174
if len(found_users) == 0:
174175
print(colored("No user found!", "red", attrs=["bold"]))

examples/findex_upsert_search/findex_dict.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from cloudproof_py.findex import Findex
33

4-
from typing import Dict, List, Tuple
4+
from typing import Dict, List, Tuple, Sequence
55

66

77
class FindexDict(Findex.FindexUpsert, Findex.FindexSearch):
@@ -14,19 +14,21 @@ def __init__(self) -> None:
1414
self.chain_table: Dict[bytes, bytes] = {}
1515

1616
# Implement callback functions
17-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
17+
def fetch_entry_table(
18+
self, entry_uids: List[bytes]
19+
) -> Sequence[Tuple[bytes, bytes]]:
1820
"""Query the Entry Table.
1921
2022
Args:
2123
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
2224
2325
Returns:
24-
Dict[bytes, bytes]: uid -> value mapping
26+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
2527
"""
26-
res = {}
28+
res = []
2729
for uid in entry_uids:
2830
if uid in self.entry_table:
29-
res[uid] = self.entry_table[uid]
31+
res.append((uid, self.entry_table[uid]))
3032
return res
3133

3234
def fetch_chain_table(self, chain_uids: List[bytes]) -> Dict[bytes, bytes]:

examples/findex_upsert_search/findex_redis.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from cloudproof_py.findex import Findex
33

4-
from typing import Dict, List, Tuple
4+
from typing import Dict, List, Tuple, Sequence
55
import redis
66

77

@@ -16,20 +16,22 @@ def __init__(self) -> None:
1616
self.prefix_chain = b"chain:"
1717

1818
# Implement callback functions
19-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
19+
def fetch_entry_table(
20+
self, entry_uids: List[bytes]
21+
) -> Sequence[Tuple[bytes, bytes]]:
2022
"""Query the Entry Table.
2123
2224
Args:
2325
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
2426
2527
Returns:
26-
Dict[bytes, bytes]: uid -> value mapping
28+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
2729
"""
28-
res = {}
30+
res = []
2931
for uid in entry_uids:
3032
existing_value = self.redis.get(self.prefix_entry + uid)
3133
if existing_value:
32-
res[uid] = existing_value
34+
res.append((uid, existing_value))
3335
return res
3436

3537
def fetch_chain_table(self, chain_uids: List[bytes]) -> Dict[bytes, bytes]:

0 commit comments

Comments
 (0)