Skip to content

Commit 08f0d2f

Browse files
committed
Separate raw documents from the database.
This CR implements a layered-approach for the database: the first layer is a meta database that stores all the information except the raw document content. Instead, the meta database stores ids of the raw documents. The second layer is a simple key value storage, which stores the raw documents and the meta database as a encrypted data blob. Assuming a pair memory id and a blob id is about 20 bytes, this allows users store about 500000 documents, each below 10M. BUG: 412698203 Change-Id: Ia40fd696547d3279bc13ed58f4374682ec3a6a41
1 parent 9f15c1a commit 08f0d2f

File tree

10 files changed

+605
-137
lines changed

10 files changed

+605
-137
lines changed

oak_private_memory/BUILD

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ package(
2424
)
2525

2626
rust_library(
27-
name = "private_memory_database_server_lib",
27+
name = "private_memory_test_database_server_lib",
2828
srcs = [
29-
"src/database/lib.rs",
30-
"src/database/service.rs",
29+
"test/database/lib.rs",
30+
"test/database/service.rs",
3131
],
3232
proc_macro_deps = ["@oak_crates_index//:async-trait"],
3333
deps = [
@@ -52,6 +52,7 @@ rust_library(
5252
"src/app.rs",
5353
"src/app_config.rs",
5454
"src/app_service.rs",
55+
"src/database.rs",
5556
"src/encryption.rs",
5657
"src/lib.rs",
5758
],
@@ -66,9 +67,11 @@ rust_library(
6667
"@oak_crates_index//:aes-gcm",
6768
"@oak_crates_index//:anyhow",
6869
"@oak_crates_index//:async-stream",
70+
"@oak_crates_index//:futures",
6971
"@oak_crates_index//:log",
7072
"@oak_crates_index//:prost",
7173
"@oak_crates_index//:prost-types",
74+
"@oak_crates_index//:rand",
7275
"@oak_crates_index//:serde",
7376
"@oak_crates_index//:serde_json",
7477
"@oak_crates_index//:tokio",
@@ -106,8 +109,8 @@ rust_test(
106109
srcs = ["test/standalone_test.rs"],
107110
proc_macro_deps = ["@oak_crates_index//:async-trait"],
108111
deps = [
109-
":private_memory_database_server_lib",
110112
":private_memory_server_lib",
113+
":private_memory_test_database_server_lib",
111114
"//proto:sealed_memory_rust_proto",
112115
"//proto/grpc:sealed_memory_grpc_proto",
113116
"@oak//oak_client",

oak_private_memory/Cargo.bazel.lock

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
929929
checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
930930
dependencies = [
931931
"generic-array",
932-
"rand_core",
932+
"rand_core 0.6.4",
933933
"subtle",
934934
"zeroize",
935935
]
@@ -941,7 +941,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
941941
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
942942
dependencies = [
943943
"generic-array",
944-
"rand_core",
944+
"rand_core 0.6.4",
945945
"typenum",
946946
]
947947

@@ -1252,9 +1252,9 @@ dependencies = [
12521252
"prost-derive",
12531253
"prost-types",
12541254
"quote",
1255-
"rand",
1256-
"rand_chacha",
1257-
"rand_core",
1255+
"rand 0.9.1",
1256+
"rand_chacha 0.3.1",
1257+
"rand_core 0.6.4",
12581258
"regex",
12591259
"regex-lite",
12601260
"rlsf",
@@ -1377,7 +1377,7 @@ dependencies = [
13771377
"group",
13781378
"pem-rfc7468",
13791379
"pkcs8",
1380-
"rand_core",
1380+
"rand_core 0.6.4",
13811381
"sec1",
13821382
"subtle",
13831383
"zeroize",
@@ -1481,7 +1481,7 @@ version = "0.13.1"
14811481
source = "registry+https://github.com/rust-lang/crates.io-index"
14821482
checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393"
14831483
dependencies = [
1484-
"rand_core",
1484+
"rand_core 0.6.4",
14851485
"subtle",
14861486
]
14871487

@@ -1760,7 +1760,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
17601760
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
17611761
dependencies = [
17621762
"ff",
1763-
"rand_core",
1763+
"rand_core 0.6.4",
17641764
"subtle",
17651765
]
17661766

@@ -1913,7 +1913,7 @@ dependencies = [
19131913
"generic-array",
19141914
"hkdf",
19151915
"hmac",
1916-
"rand_core",
1916+
"rand_core 0.6.4",
19171917
"sha2",
19181918
"subtle",
19191919
"x25519-dalek",
@@ -2627,7 +2627,7 @@ dependencies = [
26272627
"num-integer",
26282628
"num-iter",
26292629
"num-traits",
2630-
"rand",
2630+
"rand 0.8.5",
26312631
"smallvec",
26322632
"zeroize",
26332633
]
@@ -2802,7 +2802,7 @@ dependencies = [
28022802
"opentelemetry",
28032803
"ordered-float 4.6.0",
28042804
"percent-encoding",
2805-
"rand",
2805+
"rand 0.8.5",
28062806
"serde_json",
28072807
"thiserror 1.0.69",
28082808
"tokio",
@@ -3082,7 +3082,7 @@ version = "0.1.1"
30823082
source = "registry+https://github.com/rust-lang/crates.io-index"
30833083
checksum = "be97d76faf1bfab666e1375477b23fde79eccf0276e9b63b92a39d676a889ba9"
30843084
dependencies = [
3085-
"rand",
3085+
"rand 0.8.5",
30863086
]
30873087

30883088
[[package]]
@@ -3363,8 +3363,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
33633363
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
33643364
dependencies = [
33653365
"libc",
3366-
"rand_chacha",
3367-
"rand_core",
3366+
"rand_chacha 0.3.1",
3367+
"rand_core 0.6.4",
3368+
]
3369+
3370+
[[package]]
3371+
name = "rand"
3372+
version = "0.9.1"
3373+
source = "registry+https://github.com/rust-lang/crates.io-index"
3374+
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
3375+
dependencies = [
3376+
"rand_chacha 0.9.0",
3377+
"rand_core 0.9.3",
33683378
]
33693379

33703380
[[package]]
@@ -3374,7 +3384,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
33743384
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
33753385
dependencies = [
33763386
"ppv-lite86",
3377-
"rand_core",
3387+
"rand_core 0.6.4",
3388+
]
3389+
3390+
[[package]]
3391+
name = "rand_chacha"
3392+
version = "0.9.0"
3393+
source = "registry+https://github.com/rust-lang/crates.io-index"
3394+
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
3395+
dependencies = [
3396+
"ppv-lite86",
3397+
"rand_core 0.9.3",
33783398
]
33793399

33803400
[[package]]
@@ -3386,6 +3406,15 @@ dependencies = [
33863406
"getrandom 0.2.15",
33873407
]
33883408

3409+
[[package]]
3410+
name = "rand_core"
3411+
version = "0.9.3"
3412+
source = "registry+https://github.com/rust-lang/crates.io-index"
3413+
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
3414+
dependencies = [
3415+
"getrandom 0.3.2",
3416+
]
3417+
33893418
[[package]]
33903419
name = "raw-cpuid"
33913420
version = "10.7.0"
@@ -3541,7 +3570,7 @@ dependencies = [
35413570
"num-traits",
35423571
"pkcs1",
35433572
"pkcs8",
3544-
"rand_core",
3573+
"rand_core 0.6.4",
35453574
"signature",
35463575
"spki",
35473576
"subtle",
@@ -3863,7 +3892,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
38633892
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
38643893
dependencies = [
38653894
"digest",
3866-
"rand_core",
3895+
"rand_core 0.6.4",
38673896
]
38683897

38693898
[[package]]
@@ -4452,7 +4481,7 @@ dependencies = [
44524481
"indexmap 1.9.3",
44534482
"pin-project",
44544483
"pin-project-lite",
4455-
"rand",
4484+
"rand 0.8.5",
44564485
"slab",
44574486
"tokio",
44584487
"tokio-util",
@@ -5399,7 +5428,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
53995428
checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277"
54005429
dependencies = [
54015430
"curve25519-dalek",
5402-
"rand_core",
5431+
"rand_core 0.6.4",
54035432
]
54045433

54055434
[[package]]

oak_private_memory/bazel/crates/oak_crates.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ OAK_STD_CRATES = _common_crates(std = True) | {
431431
"prost-derive": crate.spec(version = "0.12.4"),
432432
"prost-types": crate.spec(version = "0.12.3"),
433433
"quote": crate.spec(version = "1.0.35"),
434-
"rand": crate.spec(version = "0.8.5"),
434+
"rand": crate.spec(version = "0.9.1"),
435435
"regex": crate.spec(
436436
default_features = False,
437437
version = "1.10.2",

0 commit comments

Comments
 (0)