Skip to content

Commit dc59a90

Browse files
committed
feat: adapt to findex v4
1 parent e24c04b commit dc59a90

11 files changed

Lines changed: 61 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jobs:
9595
destination: linux-x86-64
9696
os: ubuntu-20.04
9797
kms-version: 4.3.3
98+
findex-cloud-version: 0.1.0
9899
copy_fresh_build: false
99100
copy_regression_files: |
100101
cp ./cloudproof_python/non_regression_vector.json src/test/resources/cover_crypt/non_regression/python_non_regression_vector.json

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

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

5-
## Unreleased
5+
## [4.0.0] - 2023-06-01
66

77
### Features
88

@@ -21,6 +21,11 @@ All notable changes to this project will be documented in this file.
2121
- add deletions
2222
- change compact interface:
2323
- change parameter order
24+
- add data anonymization methods such as:
25+
- noise methods
26+
- hash methods
27+
- number methods
28+
- word methods
2429

2530
---
2631

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ This table shows the minimum version correspondence between the various componen
9494

9595
| `cloudproof_py` | CoverCrypt | Findex | KMS |
9696
| --------------- | ---------- | ----------- | ----- |
97+
| >=4.0.0 | 11.0.0 | 4.0.0,4.0.1 | 4.3.3 |
9798
| >=3.0.0 | 11.0.0 | 3.0.0 | 4.3.3 |
9899
| >=2.0.0 | 10.0.0 | 2.0.1,2.1.0 | 4.2.0 |
99100
| >=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/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]:

examples/findex_upsert_search/findex_sqlite.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sqlite3
33
from cloudproof_py.findex import Findex
44

5-
from typing import Dict, List, Set, Tuple
5+
from typing import Dict, List, Set, Tuple, Sequence
66

77

88
class FindexSQLite(Findex.FindexUpsert, Findex.FindexSearch):
@@ -26,24 +26,26 @@ def __init__(self) -> None:
2626
);"""
2727
)
2828

29-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
29+
def fetch_entry_table(
30+
self, entry_uids: List[bytes]
31+
) -> Sequence[Tuple[bytes, bytes]]:
3032
"""Query the Entry Table.
3133
3234
Args:
3335
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
3436
3537
Returns:
36-
Dict[bytes, bytes]: uid -> value mapping
38+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
3739
"""
3840
str_uids = ",".join("?" * len(entry_uids))
3941
cur = self.conn.execute(
4042
f"SELECT uid, value FROM entry_table WHERE uid IN ({str_uids})",
4143
entry_uids,
4244
)
4345
values = cur.fetchall()
44-
output_dict = {}
46+
output_dict = []
4547
for value in values:
46-
output_dict[value[0]] = value[1]
48+
output_dict.append((value[0], value[1]))
4749
return output_dict
4850

4951
def fetch_all_entry_table_uids(self) -> Set[bytes]:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cloudproof_py = ["py.typed", "*.pyi"]
77

88
[project]
99
name = "cloudproof_py"
10-
version = "3.1.0"
10+
version = "4.0.0"
1111
authors = [{ name = "Cosmian Tech", email = "tech@cosmian.com" }]
1212
description = "Python library for Cosmian Cloudproof"
1313
readme = "README.md"
@@ -17,6 +17,7 @@ classifiers = [
1717
"Operating System :: OS Independent",
1818
]
1919
dependencies = [
20+
"cloudproof-anonymization >= 0.1.0, < 1.0.0",
2021
"cover-crypt >= 11.0.0, < 12.0.0",
2122
"findex >= 4.0.0, < 5.0.0",
2223
"cosmian-kms >= 4.3.3, < 5.0.0",

scripts/ci_install_pyo3_builds.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ install_lib() {
88
rm linux.zip && rm -rf x86_64*
99
}
1010

11-
install_lib "v2.1.0"
11+
install_lib "v2.0.1"
1212
if [ $? -ne 0 ]; then
13-
install_lib "last_build/feature/rust_anonymization"
13+
install_lib "last_build/release/v2.0.1"
1414
fi
1515

1616
exit 0

src/cloudproof_py/findex/Findex.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,16 @@ def upsert(
5050
self.findex_core.upsert_wrapper(master_key, label, additions, deletions)
5151

5252
@abstractmethod
53-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
53+
def fetch_entry_table(
54+
self, entry_uids: List[bytes]
55+
) -> Sequence[Tuple[bytes, bytes]]:
5456
"""Query the Entry Table.
5557
5658
Args:
5759
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
5860
5961
Returns:
60-
Dict[bytes, bytes]: uid -> value mapping
62+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
6163
"""
6264

6365
@abstractmethod
@@ -92,14 +94,16 @@ def __init__(self) -> None:
9294
)
9395

9496
@abstractmethod
95-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
97+
def fetch_entry_table(
98+
self, entry_uids: List[bytes]
99+
) -> Sequence[Tuple[bytes, bytes]]:
96100
"""Query the Entry Table.
97101
98102
Args:
99103
entry_uids (List[bytes], optional): uids to query. if None, return the entire table
100104
101105
Returns:
102-
Dict[bytes, bytes]: uid -> value mapping
106+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
103107
"""
104108

105109
@abstractmethod
@@ -154,14 +158,16 @@ def __init__(self) -> None:
154158
)
155159

156160
@abstractmethod
157-
def fetch_entry_table(self, entry_uids: List[bytes]) -> Dict[bytes, bytes]:
161+
def fetch_entry_table(
162+
self, entry_uids: List[bytes]
163+
) -> Sequence[Tuple[bytes, bytes]]:
158164
"""Query the Entry Table.
159165
160166
Args:
161167
entry_uids (List[bytes]): uids to query
162168
163169
Returns:
164-
Dict[bytes, bytes]: uid -> value mapping
170+
Sequence[Tuple[bytes, bytes]]: uid -> value mapping
165171
"""
166172

167173
@abstractmethod

0 commit comments

Comments
 (0)