Compare commits
1 Commits
cleverwild
...
666cf52755
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
666cf52755 |
282
server/Cargo.lock
generated
282
server/Cargo.lock
generated
@@ -504,7 +504,7 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"auto_impl",
|
"auto_impl",
|
||||||
"either",
|
"either",
|
||||||
"elliptic-curve 0.13.8",
|
"elliptic-curve",
|
||||||
"k256",
|
"k256",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
@@ -772,6 +772,7 @@ dependencies = [
|
|||||||
"prost-types",
|
"prost-types",
|
||||||
"rand 0.10.1",
|
"rand 0.10.1",
|
||||||
"rand_core 0.10.1",
|
"rand_core 0.10.1",
|
||||||
|
"rand_core 0.6.4",
|
||||||
"rcgen",
|
"rcgen",
|
||||||
"restructed",
|
"restructed",
|
||||||
"rstest",
|
"rstest",
|
||||||
@@ -822,7 +823,7 @@ dependencies = [
|
|||||||
"ark-serialize 0.3.0",
|
"ark-serialize 0.3.0",
|
||||||
"ark-std 0.3.0",
|
"ark-std 0.3.0",
|
||||||
"derivative",
|
"derivative",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"paste",
|
"paste",
|
||||||
"rustc_version 0.3.3",
|
"rustc_version 0.3.3",
|
||||||
@@ -842,7 +843,7 @@ dependencies = [
|
|||||||
"derivative",
|
"derivative",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"itertools 0.10.5",
|
"itertools 0.10.5",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"paste",
|
"paste",
|
||||||
"rustc_version 0.4.1",
|
"rustc_version 0.4.1",
|
||||||
@@ -863,7 +864,7 @@ dependencies = [
|
|||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"educe",
|
"educe",
|
||||||
"itertools 0.13.0",
|
"itertools 0.13.0",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"paste",
|
"paste",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
@@ -905,7 +906,7 @@ version = "0.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20"
|
checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
@@ -917,7 +918,7 @@ version = "0.4.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565"
|
checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -930,7 +931,7 @@ version = "0.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3"
|
checksum = "09be120733ee33f7693ceaa202ca41accd5653b779563608f1234f78ae07c4b3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -955,7 +956,7 @@ checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"ark-std 0.4.0",
|
"ark-std 0.4.0",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -967,7 +968,7 @@ dependencies = [
|
|||||||
"ark-std 0.5.0",
|
"ark-std 0.5.0",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1197,12 +1198,6 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "base16ct"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
@@ -1560,12 +1555,6 @@ version = "0.8.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cpubits"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@@ -1628,22 +1617,20 @@ checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"generic-array 0.14.7",
|
"generic-array 0.14.7",
|
||||||
"rand_core 0.6.4",
|
"rand_core 0.6.4",
|
||||||
|
"serdect 0.2.0",
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-bigint"
|
name = "crypto-bigint"
|
||||||
version = "0.7.5"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271"
|
checksum = "96272c2ff28b807e09250b180ad1fb7889a3258f7455759b5c3c58b719467130"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cpubits",
|
|
||||||
"ctutils",
|
|
||||||
"hybrid-array",
|
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rand_core 0.10.1",
|
"rand_core 0.6.4",
|
||||||
"serdect 0.4.3",
|
"serdect 0.3.0",
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
@@ -1676,7 +1663,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
|
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cmov",
|
"cmov",
|
||||||
"subtle",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1839,7 +1825,7 @@ dependencies = [
|
|||||||
"asn1-rs",
|
"asn1-rs",
|
||||||
"displaydoc",
|
"displaydoc",
|
||||||
"nom",
|
"nom",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"rusticata-macros",
|
"rusticata-macros",
|
||||||
]
|
]
|
||||||
@@ -2036,7 +2022,7 @@ checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"der 0.7.10",
|
"der 0.7.10",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"elliptic-curve 0.13.8",
|
"elliptic-curve",
|
||||||
"rfc6979",
|
"rfc6979",
|
||||||
"serdect 0.2.0",
|
"serdect 0.2.0",
|
||||||
"signature 2.2.0",
|
"signature 2.2.0",
|
||||||
@@ -2070,50 +2056,34 @@ version = "0.13.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
|
checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct 0.2.0",
|
"base16ct",
|
||||||
"crypto-bigint 0.5.5",
|
"crypto-bigint 0.5.5",
|
||||||
"digest 0.10.7",
|
"digest 0.10.7",
|
||||||
"ff 0.13.1",
|
"ff",
|
||||||
"generic-array 0.14.7",
|
"generic-array 0.14.7",
|
||||||
"group 0.13.0",
|
"group",
|
||||||
|
"hkdf",
|
||||||
"pkcs8 0.10.2",
|
"pkcs8 0.10.2",
|
||||||
"rand_core 0.6.4",
|
"rand_core 0.6.4",
|
||||||
"sec1 0.7.3",
|
"sec1",
|
||||||
"serdect 0.2.0",
|
"serdect 0.2.0",
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"tap",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "elliptic-curve"
|
|
||||||
version = "0.14.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9d65aa39b3a5c1c9c1b745c9a019234bb7a21b77abcb4f4d266d706e2d577d65"
|
|
||||||
dependencies = [
|
|
||||||
"base16ct 1.0.0",
|
|
||||||
"crypto-bigint 0.7.5",
|
|
||||||
"crypto-common 0.2.1",
|
|
||||||
"ff 0.14.0",
|
|
||||||
"group 0.14.0",
|
|
||||||
"hybrid-array",
|
|
||||||
"pkcs8 0.11.0",
|
|
||||||
"rand_core 0.10.1",
|
|
||||||
"sec1 0.8.1",
|
|
||||||
"serdect 0.4.3",
|
|
||||||
"subtle",
|
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "elliptic-curve-tools"
|
name = "elliptic-curve-tools"
|
||||||
version = "0.3.0"
|
version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7a0d5e534f103b079a71ef1d66c6e62c89413f1b62709ca11f744429b4afe5b4"
|
checksum = "1de2b6fae800f08032a6ea32995b52925b1d451bff9d445c8ab2932323277faf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"elliptic-curve 0.14.1",
|
"elliptic-curve",
|
||||||
"heapless",
|
"heapless",
|
||||||
|
"hex",
|
||||||
|
"multiexp",
|
||||||
"serde",
|
"serde",
|
||||||
"serdect 0.4.3",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2186,20 +2156,11 @@ version = "0.13.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393"
|
checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bitvec",
|
||||||
"rand_core 0.6.4",
|
"rand_core 0.6.4",
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ff"
|
|
||||||
version = "0.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "a1f686ab92a9fb0eaf188f6c6c87b89490baa6fdb0db4544ba4dc47f7942489f"
|
|
||||||
dependencies = [
|
|
||||||
"rand_core 0.10.1",
|
|
||||||
"subtle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fiat-crypto"
|
name = "fiat-crypto"
|
||||||
version = "0.2.9"
|
version = "0.2.9"
|
||||||
@@ -2466,22 +2427,11 @@ version = "0.13.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
|
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ff 0.13.1",
|
"ff",
|
||||||
"rand_core 0.6.4",
|
"rand_core 0.6.4",
|
||||||
"subtle",
|
"subtle",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "group"
|
|
||||||
version = "0.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7fd1a1c7a5206c5b7a3f5a0d7ccd3ff85d0c8f5133d62a02680255b0004af5f4"
|
|
||||||
dependencies = [
|
|
||||||
"ff 0.14.0",
|
|
||||||
"rand_core 0.10.1",
|
|
||||||
"subtle",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "h2"
|
name = "h2"
|
||||||
version = "0.4.13"
|
version = "0.4.13"
|
||||||
@@ -2552,9 +2502,9 @@ checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heapless"
|
name = "heapless"
|
||||||
version = "0.9.3"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "25ba4bd83f9415b58b4ed8dc5714c76e626a105be4646c02630ad730ad3b5aa4"
|
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hash32",
|
"hash32",
|
||||||
"stable_deref_trait",
|
"stable_deref_trait",
|
||||||
@@ -2587,6 +2537,15 @@ dependencies = [
|
|||||||
"arrayvec",
|
"arrayvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hkdf"
|
||||||
|
version = "0.12.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7"
|
||||||
|
dependencies = [
|
||||||
|
"hmac 0.12.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hmac"
|
name = "hmac"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
@@ -2652,13 +2611,12 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hybrid-array"
|
name = "hybrid-array"
|
||||||
version = "0.4.15"
|
version = "0.4.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
|
checksum = "08d46837a0ed51fe95bd3b05de33cd64a1ee88fc797477ca48446872504507c5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ctutils",
|
"ctutils",
|
||||||
"serde",
|
"serde",
|
||||||
"subtle",
|
|
||||||
"typenum",
|
"typenum",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
@@ -3061,7 +3019,7 @@ checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"ecdsa",
|
"ecdsa",
|
||||||
"elliptic-curve 0.13.8",
|
"elliptic-curve",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"serdect 0.2.0",
|
"serdect 0.2.0",
|
||||||
"sha2 0.10.9",
|
"sha2 0.10.9",
|
||||||
@@ -3405,6 +3363,20 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "multiexp"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7ec2ce93a6f06ac6cae04c1da3f2a6a24fcfc1f0eb0b4e0f3d302f0df45326cb"
|
||||||
|
dependencies = [
|
||||||
|
"ff",
|
||||||
|
"group",
|
||||||
|
"rand_core 0.6.4",
|
||||||
|
"rustversion",
|
||||||
|
"std-shims",
|
||||||
|
"zeroize",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "multimap"
|
name = "multimap"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
@@ -3436,6 +3408,20 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"num-complex",
|
||||||
|
"num-integer",
|
||||||
|
"num-iter",
|
||||||
|
"num-rational",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-bigint"
|
name = "num-bigint"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
@@ -3444,16 +3430,18 @@ checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"rand 0.8.6",
|
||||||
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-bigint"
|
name = "num-complex"
|
||||||
version = "0.5.1"
|
version = "0.4.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "93e7820bc0a80a0238e650327316f929ba18d5be054b647490a3a6a339f3e7c0"
|
checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
"num-traits",
|
||||||
|
"rand 0.8.6",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3472,6 +3460,28 @@ dependencies = [
|
|||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-iter"
|
||||||
|
version = "0.1.46"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b"
|
||||||
|
dependencies = [
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-rational"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||||
|
dependencies = [
|
||||||
|
"num-bigint",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.19"
|
||||||
@@ -4351,7 +4361,7 @@ dependencies = [
|
|||||||
"bytes",
|
"bytes",
|
||||||
"fastrlp 0.3.1",
|
"fastrlp 0.3.1",
|
||||||
"fastrlp 0.4.0",
|
"fastrlp 0.4.0",
|
||||||
"num-bigint 0.4.6",
|
"num-bigint",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"parity-scale-codec",
|
"parity-scale-codec",
|
||||||
@@ -4578,7 +4588,7 @@ version = "0.7.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
|
checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct 0.2.0",
|
"base16ct",
|
||||||
"der 0.7.10",
|
"der 0.7.10",
|
||||||
"generic-array 0.14.7",
|
"generic-array 0.14.7",
|
||||||
"pkcs8 0.10.2",
|
"pkcs8 0.10.2",
|
||||||
@@ -4587,21 +4597,6 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sec1"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d56d437c2f19203ce5f7122e507831de96f3d2d4d3be5af44a0b0a09d8a80e4d"
|
|
||||||
dependencies = [
|
|
||||||
"base16ct 1.0.0",
|
|
||||||
"ctutils",
|
|
||||||
"der 0.8.0",
|
|
||||||
"hybrid-array",
|
|
||||||
"serdect 0.4.3",
|
|
||||||
"subtle",
|
|
||||||
"zeroize",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "secp256k1"
|
name = "secp256k1"
|
||||||
version = "0.30.0"
|
version = "0.30.0"
|
||||||
@@ -4759,17 +4754,17 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177"
|
checksum = "a84f14a19e9a014bb9f4512488d9829a68e04ecabffb0f9904cd1ace94598177"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct 0.2.0",
|
"base16ct",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serdect"
|
name = "serdect"
|
||||||
version = "0.4.3"
|
version = "0.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e"
|
checksum = "f42f67da2385b51a5f9652db9c93d78aeaf7610bf5ec366080b6de810604af53"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base16ct 1.0.0",
|
"base16ct",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4815,17 +4810,6 @@ dependencies = [
|
|||||||
"keccak 0.2.0",
|
"keccak 0.2.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha3"
|
|
||||||
version = "0.12.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bc9bad02c26382724b2d2692c6f179285e4b54eeecd7968f52a50059c3c11759"
|
|
||||||
dependencies = [
|
|
||||||
"digest 0.11.2",
|
|
||||||
"keccak 0.2.0",
|
|
||||||
"sponge-cursor",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha3-asm"
|
name = "sha3-asm"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
@@ -4836,17 +4820,6 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shake"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "09057cb2149ad4cbd2da1e26b351f9a4c354219421229c69c3063e6f61947c4a"
|
|
||||||
dependencies = [
|
|
||||||
"digest 0.11.2",
|
|
||||||
"keccak 0.2.0",
|
|
||||||
"sponge-cursor",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sharded-slab"
|
name = "sharded-slab"
|
||||||
version = "0.1.7"
|
version = "0.1.7"
|
||||||
@@ -4960,6 +4933,12 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spin"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spki"
|
name = "spki"
|
||||||
version = "0.7.3"
|
version = "0.7.3"
|
||||||
@@ -4980,12 +4959,6 @@ dependencies = [
|
|||||||
"der 0.8.0",
|
"der 0.8.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sponge-cursor"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3a0219bd7d979d58245a4f41f695e1ac9f8befdffadd7f61f1bae9e39abc6620"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sqlite-wasm-rs"
|
name = "sqlite-wasm-rs"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
@@ -5010,6 +4983,17 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "std-shims"
|
||||||
|
version = "0.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "227c4f8561598188d0df96dbe749824576174bba278b5b6bb2eacff1066067d0"
|
||||||
|
dependencies = [
|
||||||
|
"hashbrown 0.16.1",
|
||||||
|
"rustversion",
|
||||||
|
"spin",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "string_morph"
|
name = "string_morph"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -5766,23 +5750,21 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vsss-rs"
|
name = "vsss-rs"
|
||||||
version = "6.0.1"
|
version = "5.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d6bfc736cfd88115aedb95ba84bc2d428fe351e92a56f69fce090af301402d91"
|
checksum = "6ec751bdcc8bda099e269b24cc6b4ad14f9ce8b0490c1599174070e792ecd70c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crypto-bigint 0.7.5",
|
"crypto-bigint 0.5.5",
|
||||||
"elliptic-curve 0.14.1",
|
"crypto-bigint 0.6.1",
|
||||||
|
"elliptic-curve",
|
||||||
"elliptic-curve-tools",
|
"elliptic-curve-tools",
|
||||||
"ff 0.14.0",
|
|
||||||
"generic-array 1.4.2",
|
"generic-array 1.4.2",
|
||||||
"hex",
|
"hex",
|
||||||
"hybrid-array",
|
"hybrid-array",
|
||||||
"num-bigint 0.5.1",
|
"num",
|
||||||
"num-traits",
|
"rand_core 0.6.4",
|
||||||
"rand_core 0.10.1",
|
|
||||||
"serde",
|
"serde",
|
||||||
"sha3 0.12.0",
|
"sha3 0.10.9",
|
||||||
"shake",
|
|
||||||
"subtle",
|
"subtle",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ pub_underscore_fields = "allow"
|
|||||||
redundant_pub_crate = "allow"
|
redundant_pub_crate = "allow"
|
||||||
uninhabited_references = "allow" # safe with unsafe_code = "forbid" and standard uninhabited pattern (match *self {})
|
uninhabited_references = "allow" # safe with unsafe_code = "forbid" and standard uninhabited pattern (match *self {})
|
||||||
too-many-lines = "allow" # this is a very common pattern in server code, and it's not always possible to break it down into smaller modules without hurting readability
|
too-many-lines = "allow" # this is a very common pattern in server code, and it's not always possible to break it down into smaller modules without hurting readability
|
||||||
unused_async_trait_impl = "allow" # too pedantic
|
unused_async_trait_impl = "allow" # to pedantic
|
||||||
|
|
||||||
# restriction lints
|
# restriction lints
|
||||||
alloc_instead_of_core = "warn"
|
alloc_instead_of_core = "warn"
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ subtle = "2.6.1"
|
|||||||
x25519-dalek.workspace = true
|
x25519-dalek.workspace = true
|
||||||
k256.workspace = true
|
k256.workspace = true
|
||||||
kameo_actors.workspace = true
|
kameo_actors.workspace = true
|
||||||
vsss-rs = "6.0.1"
|
vsss-rs = "5.4.0"
|
||||||
|
rand_core_06 = { package = "rand_core", version = "0.6" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
proptest = "1.11.0"
|
proptest = "1.11.0"
|
||||||
|
|||||||
@@ -76,9 +76,6 @@ pub enum Error {
|
|||||||
/// declared, so the token stays valid across several registrations and is
|
/// declared, so the token stays valid across several registrations and is
|
||||||
/// retired by the `Bootstrapped` event rather than by first use, whichever
|
/// retired by the `Bootstrapped` event rather than by first use, whichever
|
||||||
/// bootstrap path fired it.
|
/// bootstrap path fired it.
|
||||||
///
|
|
||||||
/// Every daemon start mints a fresh token and overwrites the file: a token
|
|
||||||
/// handed out by an earlier run is dead.
|
|
||||||
pub struct Bootstrapper {
|
pub struct Bootstrapper {
|
||||||
token: Option<SafeCell<[u8; TOKEN_LENGTH]>>,
|
token: Option<SafeCell<[u8; TOKEN_LENGTH]>>,
|
||||||
token_path: Option<PathBuf>,
|
token_path: Option<PathBuf>,
|
||||||
@@ -119,13 +116,41 @@ impl Bootstrapper {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let registered = diesel::select(diesel::dsl::exists(
|
||||||
|
schema::operator_identity::table.select(schema::operator_identity::id),
|
||||||
|
))
|
||||||
|
.get_result::<bool>(&mut conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let token = if registered {
|
||||||
|
match tokio::fs::read_to_string(&path).await {
|
||||||
|
Ok(existing)
|
||||||
|
if existing.len() == TOKEN_LENGTH
|
||||||
|
&& existing.chars().all(|c| c.is_ascii_alphanumeric()) =>
|
||||||
|
{
|
||||||
|
let mut cell = SafeCell::new([0u8; TOKEN_LENGTH]);
|
||||||
|
cell.write().copy_from_slice(existing.as_bytes());
|
||||||
|
cell
|
||||||
|
}
|
||||||
|
Ok(_) | Err(_) => generate_token(&path).await?,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
generate_token(&path).await?
|
||||||
|
};
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
token: Some(generate_token(&path).await?),
|
token: Some(token),
|
||||||
token_path: Some(path),
|
token_path: Some(path),
|
||||||
events,
|
events,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_correct_token(&mut self, token: &[u8]) -> bool {
|
||||||
|
self.token.as_mut().is_some_and(|expected| {
|
||||||
|
expected.read_inline(|bytes| bool::from(bytes.as_ref().ct_eq(token)))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async fn forget(&mut self) {
|
async fn forget(&mut self) {
|
||||||
self.token = None;
|
self.token = None;
|
||||||
if let Some(path) = self.token_path.take() {
|
if let Some(path) = self.token_path.take() {
|
||||||
@@ -150,9 +175,7 @@ impl Message<events::Bootstrapped> for Bootstrapper {
|
|||||||
impl Bootstrapper {
|
impl Bootstrapper {
|
||||||
#[message]
|
#[message]
|
||||||
pub fn verify_token(&mut self, token: Vec<u8>) -> bool {
|
pub fn verify_token(&mut self, token: Vec<u8>) -> bool {
|
||||||
self.token.as_mut().is_some_and(|expected| {
|
self.is_correct_token(&token)
|
||||||
expected.read_inline(|bytes| bool::from(bytes.as_ref().ct_eq(token.as_slice())))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[message]
|
#[message]
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ use crate::{
|
|||||||
bootstrap::Bootstrapper, evm::EvmActor, flow_coordinator::FlowCoordinator,
|
bootstrap::Bootstrapper, evm::EvmActor, flow_coordinator::FlowCoordinator,
|
||||||
operator_registry::OperatorRegistry, vault::Vault, vault_coordinator::VaultCoordinator,
|
operator_registry::OperatorRegistry, vault::Vault, vault_coordinator::VaultCoordinator,
|
||||||
},
|
},
|
||||||
db,
|
db::{
|
||||||
|
self,
|
||||||
|
custody::{CustodyStore, DieselCustodyStore},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use kameo::actor::{ActorRef, Spawn};
|
use kameo::actor::{ActorRef, Spawn};
|
||||||
use kameo_actors::{DeliveryStrategy, message_bus::MessageBus};
|
use kameo_actors::{DeliveryStrategy, message_bus::MessageBus};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
@@ -45,10 +50,12 @@ impl GlobalActors {
|
|||||||
|
|
||||||
pub async fn spawn(db: db::DatabasePool) -> Result<Self, SpawnError> {
|
pub async fn spawn(db: db::DatabasePool) -> Result<Self, SpawnError> {
|
||||||
let events = Self::spawn_message_bus();
|
let events = Self::spawn_message_bus();
|
||||||
let vault = Vault::spawn(Vault::new(db.clone(), events.clone()).await?);
|
let custody: Arc<dyn CustodyStore> = Arc::new(DieselCustodyStore);
|
||||||
|
let vault =
|
||||||
|
Vault::spawn(Vault::new(db.clone(), events.clone(), Arc::clone(&custody)).await?);
|
||||||
let bootstrapper = Bootstrapper::spawn(Bootstrapper::new(&db, events.clone()).await?);
|
let bootstrapper = Bootstrapper::spawn(Bootstrapper::new(&db, events.clone()).await?);
|
||||||
let vault_coordinator =
|
let vault_coordinator =
|
||||||
VaultCoordinator::spawn(VaultCoordinator::new(db.clone(), vault.clone()));
|
VaultCoordinator::spawn(VaultCoordinator::new(db.clone(), vault.clone(), custody));
|
||||||
let operator_registry = OperatorRegistry::spawn(OperatorRegistry::default());
|
let operator_registry = OperatorRegistry::spawn(OperatorRegistry::default());
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
bootstrapper,
|
bootstrapper,
|
||||||
|
|||||||
@@ -6,13 +6,14 @@ use crate::{
|
|||||||
},
|
},
|
||||||
db::{
|
db::{
|
||||||
self,
|
self,
|
||||||
custody::{self, CustodyRecord},
|
custody::{CustodyRecord, CustodyStore},
|
||||||
models::{self, RootKeyHistory, RootKeyHistoryId},
|
models::{self, RootKeyHistory, RootKeyHistoryId},
|
||||||
schema::{self},
|
schema::{self},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use diesel::{
|
use diesel::{
|
||||||
@@ -63,7 +64,7 @@ pub enum Error {
|
|||||||
DatabaseTransaction(#[from] diesel::result::Error),
|
DatabaseTransaction(#[from] diesel::result::Error),
|
||||||
|
|
||||||
#[error("Custody storage error: {0}")]
|
#[error("Custody storage error: {0}")]
|
||||||
Custody(#[from] custody::Error),
|
Custody(#[from] db::custody::Error),
|
||||||
|
|
||||||
#[error("Broken database")]
|
#[error("Broken database")]
|
||||||
BrokenDatabase,
|
BrokenDatabase,
|
||||||
@@ -100,12 +101,17 @@ pub struct Vault {
|
|||||||
db: db::DatabasePool,
|
db: db::DatabasePool,
|
||||||
state: State,
|
state: State,
|
||||||
events: ActorRef<MessageBus>,
|
events: ActorRef<MessageBus>,
|
||||||
|
custody: Arc<dyn CustodyStore>,
|
||||||
unseal_failures: u32,
|
unseal_failures: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[messages]
|
#[messages]
|
||||||
impl Vault {
|
impl Vault {
|
||||||
pub async fn new(db: db::DatabasePool, events: ActorRef<MessageBus>) -> Result<Self, Error> {
|
pub async fn new(
|
||||||
|
db: db::DatabasePool,
|
||||||
|
events: ActorRef<MessageBus>,
|
||||||
|
custody: Arc<dyn CustodyStore>,
|
||||||
|
) -> Result<Self, Error> {
|
||||||
let state = {
|
let state = {
|
||||||
let mut conn = db.get().await?;
|
let mut conn = db.get().await?;
|
||||||
|
|
||||||
@@ -127,6 +133,7 @@ impl Vault {
|
|||||||
db,
|
db,
|
||||||
state,
|
state,
|
||||||
events,
|
events,
|
||||||
|
custody,
|
||||||
unseal_failures: 0,
|
unseal_failures: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -206,6 +213,7 @@ impl Vault {
|
|||||||
let mut conn = self.db.get().await?;
|
let mut conn = self.db.get().await?;
|
||||||
|
|
||||||
let data_encryption_nonce_bytes = data_encryption_nonce.to_vec();
|
let data_encryption_nonce_bytes = data_encryption_nonce.to_vec();
|
||||||
|
let custody_store = Arc::clone(&self.custody);
|
||||||
let root_key_history_id = conn
|
let root_key_history_id = conn
|
||||||
.transaction(async |conn| {
|
.transaction(async |conn| {
|
||||||
let root_key_history_id = insert_into(schema::root_key_history::table)
|
let root_key_history_id = insert_into(schema::root_key_history::table)
|
||||||
@@ -227,7 +235,7 @@ impl Vault {
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
if let Some(record) = custody.as_ref() {
|
if let Some(record) = custody.as_ref() {
|
||||||
custody::write_record(&mut *conn, record).await?;
|
custody_store.write_record(&mut *conn, record).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result::<_, Error>::Ok(RootKeyHistoryId::from_raw(root_key_history_id))
|
Result::<_, Error>::Ok(RootKeyHistoryId::from_raw(root_key_history_id))
|
||||||
@@ -449,14 +457,18 @@ impl Vault {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::actors::GlobalActors;
|
use crate::{actors::GlobalActors, db::custody::DieselCustodyStore};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
async fn bootstrapped_actor(db: &db::DatabasePool) -> Vault {
|
async fn bootstrapped_actor(db: &db::DatabasePool) -> Vault {
|
||||||
let mut actor = Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let seal_key = KeyCell::from([0u8; 32]);
|
let seal_key = KeyCell::from([0u8; 32]);
|
||||||
actor.bootstrap(seal_key, None).await.unwrap();
|
actor.bootstrap(seal_key, None).await.unwrap();
|
||||||
actor
|
actor
|
||||||
|
|||||||
@@ -2,20 +2,21 @@
|
|||||||
//!
|
//!
|
||||||
//! The coordinator collects one passphrase per committee member, then hands the
|
//! The coordinator collects one passphrase per committee member, then hands the
|
||||||
//! assembled material to [`Vault`] in a single message. It owns no Diesel code:
|
//! assembled material to [`Vault`] in a single message. It owns no Diesel code:
|
||||||
//! everything it reads or writes goes through [`db::custody`].
|
//! everything it reads or writes goes through [`CustodyStore`].
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
||||||
use argon2::RECOMMENDED_SALT_LEN;
|
use argon2::RECOMMENDED_SALT_LEN;
|
||||||
use kameo::{Actor, actor::ActorRef, error::SendError, messages};
|
use kameo::{Actor, actor::ActorRef, error::SendError, messages};
|
||||||
use rand::rngs::SysRng;
|
use rand_core_06::{OsRng, RngCore as _};
|
||||||
use rand_core::{Rng as _, UnwrapErr};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
actors::vault::{self, Bootstrap, TryUnseal, Vault},
|
actors::vault::{self, Bootstrap, TryUnseal, Vault},
|
||||||
crypto::{KeyCell, derive_key, encryption::v1::Nonce, shamir},
|
crypto::{KeyCell, derive_key, encryption::v1::Nonce, shamir},
|
||||||
db::{
|
db::{
|
||||||
self,
|
self,
|
||||||
custody::{self, CustodyRecord, EncryptedShare},
|
custody::{CustodyRecord, CustodyStore, EncryptedShare},
|
||||||
models::OperatorId,
|
models::OperatorId,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -50,7 +51,7 @@ pub enum Error {
|
|||||||
#[error("Database connection error: {0}")]
|
#[error("Database connection error: {0}")]
|
||||||
DatabaseConnection(#[from] db::PoolError),
|
DatabaseConnection(#[from] db::PoolError),
|
||||||
#[error("Custody storage error: {0}")]
|
#[error("Custody storage error: {0}")]
|
||||||
Custody(#[from] custody::Error),
|
Custody(#[from] db::custody::Error),
|
||||||
#[error("Encryption error")]
|
#[error("Encryption error")]
|
||||||
Encryption,
|
Encryption,
|
||||||
#[error("The vault is already bootstrapped")]
|
#[error("The vault is already bootstrapped")]
|
||||||
@@ -109,14 +110,20 @@ enum CoordinatorState {
|
|||||||
pub struct VaultCoordinator {
|
pub struct VaultCoordinator {
|
||||||
db: db::DatabasePool,
|
db: db::DatabasePool,
|
||||||
vault: ActorRef<Vault>,
|
vault: ActorRef<Vault>,
|
||||||
|
custody: Arc<dyn CustodyStore>,
|
||||||
state: CoordinatorState,
|
state: CoordinatorState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl VaultCoordinator {
|
impl VaultCoordinator {
|
||||||
pub const fn new(db: db::DatabasePool, vault: ActorRef<Vault>) -> Self {
|
pub fn new(
|
||||||
|
db: db::DatabasePool,
|
||||||
|
vault: ActorRef<Vault>,
|
||||||
|
custody: Arc<dyn CustodyStore>,
|
||||||
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
db,
|
db,
|
||||||
vault,
|
vault,
|
||||||
|
custody,
|
||||||
state: CoordinatorState::Idle,
|
state: CoordinatorState::Idle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +143,7 @@ fn encrypt_share(
|
|||||||
share: &[u8],
|
share: &[u8],
|
||||||
) -> Result<EncryptedShare, Error> {
|
) -> Result<EncryptedShare, Error> {
|
||||||
let mut salt = [0u8; RECOMMENDED_SALT_LEN];
|
let mut salt = [0u8; RECOMMENDED_SALT_LEN];
|
||||||
UnwrapErr(SysRng).fill_bytes(&mut salt);
|
OsRng.fill_bytes(&mut salt);
|
||||||
|
|
||||||
let nonce = Nonce::default();
|
let nonce = Nonce::default();
|
||||||
let ciphertext = derive_key(passphrase, &salt)
|
let ciphertext = derive_key(passphrase, &salt)
|
||||||
@@ -181,17 +188,15 @@ async fn finalize_bootstrap(
|
|||||||
let threshold = shamir::shamir_threshold(total).ok_or_else(|| committee_error(total))?;
|
let threshold = shamir::shamir_threshold(total).ok_or_else(|| committee_error(total))?;
|
||||||
|
|
||||||
let mut seal_key = KeyCell::new_secure_random();
|
let mut seal_key = KeyCell::new_secure_random();
|
||||||
let mut shares = shamir::split_key(threshold, total, &mut seal_key, UnwrapErr(SysRng))
|
let mut shares = shamir::split_key(threshold, total, &mut seal_key, OsRng)
|
||||||
.map_err(|error| Error::Shamir(error.to_string()))?;
|
.map_err(|error| Error::Shamir(error.to_string()))?;
|
||||||
|
|
||||||
if shares.len() < total {
|
|
||||||
return Err(Error::Shamir("missing share for operator".to_owned()));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut encrypted = Vec::with_capacity(total);
|
let mut encrypted = Vec::with_capacity(total);
|
||||||
for ((operator_id, passphrase), share) in contributions.0.iter_mut().zip(shares.iter_mut()) {
|
for (index, (operator_id, passphrase)) in contributions.0.iter_mut().enumerate() {
|
||||||
let share = share.read_inline(|share| encrypt_share(passphrase, share))?;
|
let share = shares
|
||||||
encrypted.push((*operator_id, share));
|
.read_inline(|shares| shares.get(index).cloned())
|
||||||
|
.ok_or_else(|| Error::Shamir("missing share for operator".to_owned()))?;
|
||||||
|
encrypted.push((*operator_id, encrypt_share(passphrase, &share)?));
|
||||||
}
|
}
|
||||||
|
|
||||||
vault
|
vault
|
||||||
@@ -209,18 +214,24 @@ async fn finalize_bootstrap(
|
|||||||
/// Reconstruct the seal key from the contributed passphrases and unseal.
|
/// Reconstruct the seal key from the contributed passphrases and unseal.
|
||||||
async fn finalize_unseal(
|
async fn finalize_unseal(
|
||||||
db: &db::DatabasePool,
|
db: &db::DatabasePool,
|
||||||
|
custody: &Arc<dyn CustodyStore>,
|
||||||
vault: &ActorRef<Vault>,
|
vault: &ActorRef<Vault>,
|
||||||
threshold: usize,
|
threshold: usize,
|
||||||
contributions: &mut Contributions,
|
contributions: &mut Contributions,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let stored = {
|
let stored = {
|
||||||
let mut conn = db.get().await?;
|
let mut conn = db.get().await?;
|
||||||
custody::shares(&mut conn, &contributions.operators()).await?
|
custody
|
||||||
|
.shares(&mut conn, &contributions.operators())
|
||||||
|
.await?
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut plaintext = Vec::with_capacity(stored.len());
|
let mut plaintext = SafeCell::new(Vec::with_capacity(stored.len()));
|
||||||
for ((_, passphrase), share) in contributions.0.iter_mut().zip(stored) {
|
for ((_, passphrase), share) in contributions.0.iter_mut().zip(stored) {
|
||||||
plaintext.push(decrypt_share(passphrase, share)?);
|
let mut decrypted = decrypt_share(passphrase, share)?;
|
||||||
|
decrypted.read_inline(|share| {
|
||||||
|
plaintext.write_inline(|shares| shares.push(share.clone()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let seal_key = shamir::combine_shares(threshold, &mut plaintext)
|
let seal_key = shamir::combine_shares(threshold, &mut plaintext)
|
||||||
@@ -325,7 +336,7 @@ impl VaultCoordinator {
|
|||||||
if matches!(self.state, CoordinatorState::Idle) {
|
if matches!(self.state, CoordinatorState::Idle) {
|
||||||
let threshold = {
|
let threshold = {
|
||||||
let mut conn = self.db.get().await?;
|
let mut conn = self.db.get().await?;
|
||||||
custody::threshold(&mut conn).await?
|
self.custody.threshold(&mut conn).await?
|
||||||
};
|
};
|
||||||
self.state = CoordinatorState::Unsealing {
|
self.state = CoordinatorState::Unsealing {
|
||||||
threshold,
|
threshold,
|
||||||
@@ -363,7 +374,15 @@ impl VaultCoordinator {
|
|||||||
unreachable!("state was matched as Unsealing above")
|
unreachable!("state was matched as Unsealing above")
|
||||||
};
|
};
|
||||||
|
|
||||||
match finalize_unseal(&self.db, &self.vault, threshold, &mut contributions).await {
|
match finalize_unseal(
|
||||||
|
&self.db,
|
||||||
|
&self.custody,
|
||||||
|
&self.vault,
|
||||||
|
threshold,
|
||||||
|
&mut contributions,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(()) => Ok(true),
|
Ok(()) => Ok(true),
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
self.state = CoordinatorState::Unsealing {
|
self.state = CoordinatorState::Unsealing {
|
||||||
|
|||||||
@@ -206,6 +206,9 @@ pub async fn is_signing_available(vault: &ActorRef<Vault>) -> Result<bool, Error
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::db::custody::DieselCustodyStore;
|
||||||
use diesel::{ExpressionMethods as _, QueryDsl};
|
use diesel::{ExpressionMethods as _, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use kameo::{actor::ActorRef, prelude::Spawn};
|
use kameo::{actor::ActorRef, prelude::Spawn};
|
||||||
@@ -231,9 +234,13 @@ mod tests {
|
|||||||
|
|
||||||
async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef<Vault> {
|
async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef<Vault> {
|
||||||
let actor = Vault::spawn(
|
let actor = Vault::spawn(
|
||||||
Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap(),
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
);
|
);
|
||||||
actor
|
actor
|
||||||
.ask(Bootstrap {
|
.ask(Bootstrap {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
||||||
use rand_core::CryptoRng;
|
|
||||||
use vsss_rs::Gf256;
|
use vsss_rs::Gf256;
|
||||||
|
|
||||||
use crate::crypto::KeyCell;
|
use crate::crypto::KeyCell;
|
||||||
@@ -16,13 +15,10 @@ pub enum ShamirError {
|
|||||||
Combine(String),
|
Combine(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the required threshold for a Shamir share pool of `committee_size`.
|
/// Return the required majority threshold for an ordinary operator committee.
|
||||||
///
|
///
|
||||||
/// A pool of two is rejected: a majority of two is two, which gives each holder
|
/// Committees of two are rejected: a majority of two is two, which gives each
|
||||||
/// a veto over every unseal without giving either one recovery. That rejects no
|
/// member a veto over every unseal without giving either one recovery.
|
||||||
/// supported committee, because a two-operator vault must carry at least one
|
|
||||||
/// recovery share and so never splits into a pool of two -- see
|
|
||||||
/// `docs/ARCHITECTURE.md` 3.9.
|
|
||||||
#[expect(
|
#[expect(
|
||||||
clippy::integer_division,
|
clippy::integer_division,
|
||||||
reason = "majority thresholds use integer arithmetic"
|
reason = "majority thresholds use integer arithmetic"
|
||||||
@@ -42,8 +38,8 @@ pub fn split_key(
|
|||||||
threshold: usize,
|
threshold: usize,
|
||||||
total: usize,
|
total: usize,
|
||||||
key: &mut KeyCell,
|
key: &mut KeyCell,
|
||||||
rng: impl CryptoRng,
|
mut rng: impl rand_core_06::RngCore + rand_core_06::CryptoRng,
|
||||||
) -> Result<Vec<SafeCell<Vec<u8>>>, ShamirError> {
|
) -> Result<SafeCell<Vec<Vec<u8>>>, ShamirError> {
|
||||||
if total == 0 || threshold == 0 || threshold > total || total == 2 || total > MAX_COMMITTEE_SIZE
|
if total == 0 || threshold == 0 || threshold > total || total == 2 || total > MAX_COMMITTEE_SIZE
|
||||||
{
|
{
|
||||||
return Err(ShamirError::Split(
|
return Err(ShamirError::Split(
|
||||||
@@ -51,23 +47,20 @@ pub fn split_key(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing to interpolate when one share suffices.
|
|
||||||
if threshold == 1 {
|
|
||||||
return Ok(key.0.read_inline(|key| {
|
|
||||||
std::iter::repeat_with(|| SafeCell::new(key.as_slice().to_vec()))
|
|
||||||
.take(total)
|
|
||||||
.collect()
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
key.0.read_inline(|key| {
|
key.0.read_inline(|key| {
|
||||||
let key: &[u8; 32] = key
|
let key: &[u8; 32] = key
|
||||||
.as_slice()
|
.as_slice()
|
||||||
.try_into()
|
.try_into()
|
||||||
.map_err(|_| ShamirError::Split("unexpected seal key length".to_owned()))?;
|
.map_err(|_| ShamirError::Split("unexpected seal key length".to_owned()))?;
|
||||||
|
|
||||||
Gf256::split_array(threshold, total, key, rng)
|
if threshold == 1 {
|
||||||
.map(|shares| shares.into_iter().map(SafeCell::new).collect())
|
return Ok(SafeCell::new(
|
||||||
|
std::iter::repeat_n(key.to_vec(), total).collect(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Gf256::split_array(threshold, total, key, &mut rng)
|
||||||
|
.map(SafeCell::new)
|
||||||
.map_err(|error| ShamirError::Split(format!("{error:?}")))
|
.map_err(|error| ShamirError::Split(format!("{error:?}")))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -80,43 +73,30 @@ pub fn split_key(
|
|||||||
/// sized.
|
/// sized.
|
||||||
pub fn combine_shares(
|
pub fn combine_shares(
|
||||||
threshold: usize,
|
threshold: usize,
|
||||||
shares: &mut [SafeCell<Vec<u8>>],
|
shares: &mut SafeCell<Vec<Vec<u8>>>,
|
||||||
) -> Result<KeyCell, ShamirError> {
|
) -> Result<KeyCell, ShamirError> {
|
||||||
if threshold == 0 {
|
if threshold == 0 {
|
||||||
return Err(ShamirError::Combine("threshold is zero".to_owned()));
|
return Err(ShamirError::Combine("threshold is zero".to_owned()));
|
||||||
}
|
}
|
||||||
if shares.len() < threshold {
|
if shares.read().len() < threshold {
|
||||||
return Err(ShamirError::Combine(
|
return Err(ShamirError::Combine(
|
||||||
"not enough shares supplied".to_owned(),
|
"not enough shares supplied".to_owned(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mirror of the one-of-one case in [`split_key`]: the share is the key.
|
let combined = shares.read_inline(|shares| {
|
||||||
if threshold == 1 {
|
if threshold == 1 {
|
||||||
let share = shares
|
let share = shares
|
||||||
.first_mut()
|
.first()
|
||||||
.ok_or_else(|| ShamirError::Combine("no shares supplied".to_owned()))?;
|
.ok_or_else(|| ShamirError::Combine("no shares supplied".to_owned()))?;
|
||||||
return reconstructed_key(share.read_inline(|share| SafeCell::new(share.clone())));
|
return Ok(SafeCell::new(share.clone()));
|
||||||
}
|
}
|
||||||
|
Gf256::combine_array(shares)
|
||||||
let mut gathered = SafeCell::new(Vec::with_capacity(shares.len()));
|
|
||||||
for share in shares.iter_mut() {
|
|
||||||
share.read_inline(|share| {
|
|
||||||
gathered.write_inline(|gathered| gathered.push(share.clone()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let combined = gathered.read_inline(|gathered| {
|
|
||||||
Gf256::combine_array(gathered.as_slice())
|
|
||||||
.map(SafeCell::new)
|
.map(SafeCell::new)
|
||||||
.map_err(|error| ShamirError::Combine(format!("{error:?}")))
|
.map_err(|error| ShamirError::Combine(format!("{error:?}")))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
reconstructed_key(combined)
|
KeyCell::try_from(combined)
|
||||||
}
|
|
||||||
|
|
||||||
fn reconstructed_key(bytes: SafeCell<Vec<u8>>) -> Result<KeyCell, ShamirError> {
|
|
||||||
KeyCell::try_from(bytes)
|
|
||||||
.map_err(|()| ShamirError::Combine("unexpected reconstructed key length".to_owned()))
|
.map_err(|()| ShamirError::Combine("unexpected reconstructed key length".to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,9 +105,6 @@ mod tests {
|
|||||||
use super::{MAX_COMMITTEE_SIZE, combine_shares, shamir_threshold, split_key};
|
use super::{MAX_COMMITTEE_SIZE, combine_shares, shamir_threshold, split_key};
|
||||||
use crate::crypto::KeyCell;
|
use crate::crypto::KeyCell;
|
||||||
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
use arbiter_crypto::safecell::{SafeCell, SafeCellHandle as _};
|
||||||
use rand::rngs::SysRng;
|
|
||||||
use rand_core::UnwrapErr;
|
|
||||||
use rstest::rstest;
|
|
||||||
|
|
||||||
fn key_bytes(mut key: KeyCell) -> [u8; 32] {
|
fn key_bytes(mut key: KeyCell) -> [u8; 32] {
|
||||||
key.0.read_inline(|key| {
|
key.0.read_inline(|key| {
|
||||||
@@ -137,36 +114,35 @@ mod tests {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn select(shares: &mut [SafeCell<Vec<u8>>], indexes: &[usize]) -> Vec<SafeCell<Vec<u8>>> {
|
fn select(shares: &mut SafeCell<Vec<Vec<u8>>>, indexes: &[usize]) -> SafeCell<Vec<Vec<u8>>> {
|
||||||
indexes
|
shares.read_inline(|shares| {
|
||||||
.iter()
|
SafeCell::new(
|
||||||
.filter_map(|index| {
|
indexes
|
||||||
shares
|
.iter()
|
||||||
.get_mut(*index)
|
.filter_map(|index| shares.get(*index).cloned())
|
||||||
.map(|share| share.read_inline(|share| SafeCell::new(share.clone())))
|
.collect(),
|
||||||
})
|
)
|
||||||
.collect()
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[test]
|
||||||
#[case(&[0, 1])]
|
fn threshold_shares_reconstruct_fixed_key() {
|
||||||
#[case(&[0, 2])]
|
|
||||||
#[case(&[1, 2])]
|
|
||||||
fn threshold_shares_reconstruct_fixed_key(#[case] indexes: &[usize]) {
|
|
||||||
let expected = [9_u8; 32];
|
let expected = [9_u8; 32];
|
||||||
let mut key = KeyCell::from(expected);
|
let mut key = KeyCell::from(expected);
|
||||||
let rng = UnwrapErr(SysRng);
|
let rng = rand_core_06::OsRng;
|
||||||
let mut shares = split_key(2, 3, &mut key, rng).expect("split should succeed");
|
let mut shares = split_key(2, 3, &mut key, rng).expect("split should succeed");
|
||||||
let mut selected = select(&mut shares, indexes);
|
for indexes in [[0_usize, 1_usize], [0, 2], [1, 2]] {
|
||||||
let combined = combine_shares(2, &mut selected).expect("combine should succeed");
|
let mut selected = select(&mut shares, &indexes);
|
||||||
assert_eq!(key_bytes(combined), expected);
|
let combined = combine_shares(2, &mut selected).expect("combine should succeed");
|
||||||
|
assert_eq!(key_bytes(combined), expected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn one_of_one_round_trips_a_fixed_size_key() {
|
fn one_of_one_round_trips_a_fixed_size_key() {
|
||||||
let expected = [7_u8; 32];
|
let expected = [7_u8; 32];
|
||||||
let mut key = KeyCell::from(expected);
|
let mut key = KeyCell::from(expected);
|
||||||
let rng = UnwrapErr(SysRng);
|
let rng = rand_core_06::OsRng;
|
||||||
let mut shares = split_key(1, 1, &mut key, rng).expect("split should succeed");
|
let mut shares = split_key(1, 1, &mut key, rng).expect("split should succeed");
|
||||||
let combined = combine_shares(1, &mut shares).expect("combine should succeed");
|
let combined = combine_shares(1, &mut shares).expect("combine should succeed");
|
||||||
assert_eq!(key_bytes(combined), expected);
|
assert_eq!(key_bytes(combined), expected);
|
||||||
@@ -175,7 +151,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn fewer_shares_than_threshold_is_rejected() {
|
fn fewer_shares_than_threshold_is_rejected() {
|
||||||
let mut key = KeyCell::from([3_u8; 32]);
|
let mut key = KeyCell::from([3_u8; 32]);
|
||||||
let rng = UnwrapErr(SysRng);
|
let rng = rand_core_06::OsRng;
|
||||||
let mut shares = split_key(3, 5, &mut key, rng).expect("split should succeed");
|
let mut shares = split_key(3, 5, &mut key, rng).expect("split should succeed");
|
||||||
let mut selected = select(&mut shares, &[0, 1]);
|
let mut selected = select(&mut shares, &[0, 1]);
|
||||||
assert!(
|
assert!(
|
||||||
@@ -184,25 +160,24 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[test]
|
||||||
#[case(0, None)]
|
fn empty_committee_has_no_threshold() {
|
||||||
#[case(1, Some(1))]
|
assert_eq!(shamir_threshold(0), None);
|
||||||
#[case(2, None)]
|
|
||||||
#[case(3, Some(2))]
|
|
||||||
#[case(4, Some(3))]
|
|
||||||
#[case(MAX_COMMITTEE_SIZE, Some(128))]
|
|
||||||
#[case(MAX_COMMITTEE_SIZE + 1, None)]
|
|
||||||
fn committee_threshold_is_a_majority(
|
|
||||||
#[case] committee_size: usize,
|
|
||||||
#[case] expected: Option<usize>,
|
|
||||||
) {
|
|
||||||
assert_eq!(shamir_threshold(committee_size), expected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn oversized_committee_is_rejected_by_split() {
|
fn committee_threshold_is_majority_for_three_or_more() {
|
||||||
|
assert_eq!(shamir_threshold(1), Some(1));
|
||||||
|
assert_eq!(shamir_threshold(3), Some(2));
|
||||||
|
assert_eq!(shamir_threshold(4), Some(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn oversized_committee_has_no_threshold() {
|
||||||
|
assert_eq!(shamir_threshold(MAX_COMMITTEE_SIZE), Some(128));
|
||||||
|
assert_eq!(shamir_threshold(MAX_COMMITTEE_SIZE + 1), None);
|
||||||
let mut key = KeyCell::from([1_u8; 32]);
|
let mut key = KeyCell::from([1_u8; 32]);
|
||||||
let rng = UnwrapErr(SysRng);
|
let rng = rand_core_06::OsRng;
|
||||||
assert!(
|
assert!(
|
||||||
split_key(129, MAX_COMMITTEE_SIZE + 1, &mut key, rng).is_err(),
|
split_key(129, MAX_COMMITTEE_SIZE + 1, &mut key, rng).is_err(),
|
||||||
"committees above the GF(256) share limit must be rejected"
|
"committees above the GF(256) share limit must be rejected"
|
||||||
@@ -211,8 +186,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn two_operator_committee_is_explicitly_unsupported() {
|
fn two_operator_committee_is_explicitly_unsupported() {
|
||||||
|
assert_eq!(shamir_threshold(2), None);
|
||||||
let mut key = KeyCell::from([7_u8; 32]);
|
let mut key = KeyCell::from([7_u8; 32]);
|
||||||
let rng = UnwrapErr(SysRng);
|
let rng = rand_core_06::OsRng;
|
||||||
assert!(
|
assert!(
|
||||||
split_key(2, 2, &mut key, rng).is_err(),
|
split_key(2, 2, &mut key, rng).is_err(),
|
||||||
"two-operator committees must be rejected"
|
"two-operator committees must be rejected"
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
//! Storage for Shamir custody material: the reconstruction threshold and the
|
//! Storage for Shamir custody material: the reconstruction threshold and the
|
||||||
//! per-operator encrypted shares of the vault seal key.
|
//! per-operator encrypted shares of the vault seal key.
|
||||||
//!
|
//!
|
||||||
//! The queries live here so that the actors above hold no Diesel code of their
|
//! Every query lives behind [`CustodyStore`] so that the actors above it hold
|
||||||
//! own. Every one of them borrows the caller's connection instead of taking one
|
//! no Diesel code of their own. [`CustodyStore::write_record`] borrows the
|
||||||
//! from the pool, which is what lets the vault write custody material inside
|
//! caller's connection instead of taking one from the pool, which lets the
|
||||||
//! the same transaction that stores the root key.
|
//! vault write custody material inside the same transaction that stores the
|
||||||
|
//! root key.
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
use diesel::{ExpressionMethods as _, QueryDsl};
|
use diesel::{ExpressionMethods as _, QueryDsl};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
|
||||||
@@ -44,94 +46,117 @@ pub enum Error {
|
|||||||
MissingShare(OperatorId),
|
MissingShare(OperatorId),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Persist threshold and shares on the caller's connection, joining any
|
#[async_trait]
|
||||||
/// transaction the caller has already opened.
|
pub trait CustodyStore: std::fmt::Debug + Send + Sync {
|
||||||
pub async fn write_record(
|
/// Persist threshold and shares on the caller's connection, joining any
|
||||||
conn: &mut db::DatabaseConnection,
|
/// transaction the caller has already opened.
|
||||||
record: &CustodyRecord,
|
async fn write_record(
|
||||||
) -> Result<(), Error> {
|
&self,
|
||||||
let threshold = i32::try_from(record.threshold).map_err(|_| Error::BrokenThreshold)?;
|
conn: &mut db::DatabaseConnection,
|
||||||
|
record: &CustodyRecord,
|
||||||
|
) -> Result<(), Error>;
|
||||||
|
|
||||||
// SQLite has no batch form for REPLACE INTO in diesel, so the rows go
|
/// Number of shares required to reconstruct the seal key.
|
||||||
// in one at a time. The caller's transaction still makes them atomic.
|
async fn threshold(&self, conn: &mut db::DatabaseConnection) -> Result<usize, Error>;
|
||||||
let now = SqliteTimestamp::now();
|
|
||||||
for (operator_id, share) in &record.shares {
|
/// Load the shares of `operators` in one query, in the order requested.
|
||||||
diesel::replace_into(schema::operator::table)
|
async fn shares(
|
||||||
.values((
|
&self,
|
||||||
schema::operator::id.eq(Some(*operator_id)),
|
conn: &mut db::DatabaseConnection,
|
||||||
schema::operator::share.eq(&share.ciphertext),
|
operators: &[OperatorId],
|
||||||
schema::operator::share_nonce.eq(&share.nonce),
|
) -> Result<Vec<EncryptedShare>, Error>;
|
||||||
schema::operator::share_salt.eq(&share.salt),
|
}
|
||||||
schema::operator::created_at.eq(now.clone()),
|
|
||||||
schema::operator::updated_at.eq(now.clone()),
|
/// The production [`CustodyStore`], backed by the `SQLite` schema.
|
||||||
))
|
#[derive(Debug, Clone, Copy, Default)]
|
||||||
|
pub struct DieselCustodyStore;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl CustodyStore for DieselCustodyStore {
|
||||||
|
async fn write_record(
|
||||||
|
&self,
|
||||||
|
conn: &mut db::DatabaseConnection,
|
||||||
|
record: &CustodyRecord,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
let threshold = i32::try_from(record.threshold).map_err(|_| Error::BrokenThreshold)?;
|
||||||
|
|
||||||
|
// SQLite has no batch form for REPLACE INTO in diesel, so the rows go
|
||||||
|
// in one at a time. The caller's transaction still makes them atomic.
|
||||||
|
let now = SqliteTimestamp::now();
|
||||||
|
for (operator_id, share) in &record.shares {
|
||||||
|
diesel::replace_into(schema::operator::table)
|
||||||
|
.values((
|
||||||
|
schema::operator::id.eq(Some(*operator_id)),
|
||||||
|
schema::operator::share.eq(&share.ciphertext),
|
||||||
|
schema::operator::share_nonce.eq(&share.nonce),
|
||||||
|
schema::operator::share_salt.eq(&share.salt),
|
||||||
|
schema::operator::created_at.eq(now.clone()),
|
||||||
|
schema::operator::updated_at.eq(now.clone()),
|
||||||
|
))
|
||||||
|
.execute(&mut *conn)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let updated = diesel::update(schema::arbiter_settings::table)
|
||||||
|
.set(schema::arbiter_settings::shamir_threshold.eq(Some(threshold)))
|
||||||
.execute(&mut *conn)
|
.execute(&mut *conn)
|
||||||
.await?;
|
.await?;
|
||||||
|
if updated != 1 {
|
||||||
|
return Err(Error::MissingSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
let updated = diesel::update(schema::arbiter_settings::table)
|
async fn threshold(&self, conn: &mut db::DatabaseConnection) -> Result<usize, Error> {
|
||||||
.set(schema::arbiter_settings::shamir_threshold.eq(Some(threshold)))
|
let stored: Option<i32> = schema::arbiter_settings::table
|
||||||
.execute(&mut *conn)
|
.select(schema::arbiter_settings::shamir_threshold)
|
||||||
.await?;
|
.first(conn)
|
||||||
if updated != 1 {
|
.await?;
|
||||||
return Err(Error::MissingSettings);
|
|
||||||
|
stored
|
||||||
|
.and_then(|value| usize::try_from(value).ok())
|
||||||
|
.filter(|threshold| *threshold > 0)
|
||||||
|
.ok_or(Error::BrokenThreshold)
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
async fn shares(
|
||||||
}
|
&self,
|
||||||
|
conn: &mut db::DatabaseConnection,
|
||||||
|
operators: &[OperatorId],
|
||||||
|
) -> Result<Vec<EncryptedShare>, Error> {
|
||||||
|
let wanted: Vec<Option<OperatorId>> = operators.iter().copied().map(Some).collect();
|
||||||
|
|
||||||
/// Number of shares required to reconstruct the seal key.
|
let rows: Vec<(Option<OperatorId>, Vec<u8>, Vec<u8>, Vec<u8>)> = schema::operator::table
|
||||||
pub async fn threshold(conn: &mut db::DatabaseConnection) -> Result<usize, Error> {
|
.filter(schema::operator::id.eq_any(wanted))
|
||||||
let stored: Option<i32> = schema::arbiter_settings::table
|
.select((
|
||||||
.select(schema::arbiter_settings::shamir_threshold)
|
schema::operator::id,
|
||||||
.first(conn)
|
schema::operator::share,
|
||||||
.await?;
|
schema::operator::share_nonce,
|
||||||
|
schema::operator::share_salt,
|
||||||
|
))
|
||||||
|
.load(conn)
|
||||||
|
.await?;
|
||||||
|
|
||||||
stored
|
let mut found: HashMap<OperatorId, EncryptedShare> = rows
|
||||||
.and_then(|value| usize::try_from(value).ok())
|
.into_iter()
|
||||||
.filter(|threshold| *threshold > 0)
|
.filter_map(|(id, ciphertext, nonce, salt)| {
|
||||||
.ok_or(Error::BrokenThreshold)
|
id.map(|id| {
|
||||||
}
|
(
|
||||||
|
id,
|
||||||
/// Load the shares of `operators` in one query, in the order requested.
|
EncryptedShare {
|
||||||
pub async fn shares(
|
ciphertext,
|
||||||
conn: &mut db::DatabaseConnection,
|
nonce,
|
||||||
operators: &[OperatorId],
|
salt,
|
||||||
) -> Result<Vec<EncryptedShare>, Error> {
|
},
|
||||||
/// (id, then the three columns that make up [`EncryptedShare`])
|
)
|
||||||
type ShareRow = (Option<OperatorId>, Vec<u8>, Vec<u8>, Vec<u8>);
|
})
|
||||||
|
|
||||||
let wanted: Vec<Option<OperatorId>> = operators.iter().copied().map(Some).collect();
|
|
||||||
|
|
||||||
let rows: Vec<ShareRow> = schema::operator::table
|
|
||||||
.filter(schema::operator::id.eq_any(wanted))
|
|
||||||
.select((
|
|
||||||
schema::operator::id,
|
|
||||||
schema::operator::share,
|
|
||||||
schema::operator::share_nonce,
|
|
||||||
schema::operator::share_salt,
|
|
||||||
))
|
|
||||||
.load(conn)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let mut found: HashMap<OperatorId, EncryptedShare> = rows
|
|
||||||
.into_iter()
|
|
||||||
.filter_map(|(id, ciphertext, nonce, salt)| {
|
|
||||||
id.map(|id| {
|
|
||||||
(
|
|
||||||
id,
|
|
||||||
EncryptedShare {
|
|
||||||
ciphertext,
|
|
||||||
nonce,
|
|
||||||
salt,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
.collect();
|
||||||
.collect();
|
|
||||||
|
|
||||||
operators
|
operators
|
||||||
.iter()
|
.iter()
|
||||||
.map(|id| found.remove(id).ok_or(Error::MissingShare(*id)))
|
.map(|id| found.remove(id).ok_or(Error::MissingShare(*id)))
|
||||||
.collect()
|
.collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -501,6 +501,9 @@ impl Engine {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use crate::db::custody::DieselCustodyStore;
|
||||||
use alloy::primitives::{Address, Bytes, U256, address};
|
use alloy::primitives::{Address, Bytes, U256, address};
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
use diesel::{SelectableHelper, insert_into};
|
use diesel::{SelectableHelper, insert_into};
|
||||||
@@ -766,9 +769,13 @@ mod tests {
|
|||||||
|
|
||||||
async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef<Vault> {
|
async fn bootstrapped_vault(db: &db::DatabasePool) -> ActorRef<Vault> {
|
||||||
let actor = Vault::spawn(
|
let actor = Vault::spawn(
|
||||||
Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap(),
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap(),
|
||||||
);
|
);
|
||||||
actor
|
actor
|
||||||
.ask(Bootstrap {
|
.ask(Bootstrap {
|
||||||
|
|||||||
@@ -7,18 +7,23 @@ use arbiter_proto::transport::{Bi, Error, Receiver, Sender};
|
|||||||
use arbiter_server::{
|
use arbiter_server::{
|
||||||
actors::{GlobalActors, vault::Vault},
|
actors::{GlobalActors, vault::Vault},
|
||||||
crypto::KeyCell,
|
crypto::KeyCell,
|
||||||
db::{self, schema},
|
db::{self, custody::DieselCustodyStore, schema},
|
||||||
};
|
};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use diesel::QueryDsl;
|
use diesel::QueryDsl;
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
use std::sync::Arc;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
pub(crate) async fn bootstrapped_vault(db: &db::DatabasePool) -> Vault {
|
pub(crate) async fn bootstrapped_vault(db: &db::DatabasePool) -> Vault {
|
||||||
let mut actor = Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
actor
|
actor
|
||||||
.bootstrap(KeyCell::from([0u8; 32]), None)
|
.bootstrap(KeyCell::from([0u8; 32]), None)
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ use arbiter_server::{
|
|||||||
vault::{CreateNew, Error, Vault},
|
vault::{CreateNew, Error, Vault},
|
||||||
},
|
},
|
||||||
crypto::KeyCell,
|
crypto::KeyCell,
|
||||||
db::{self, models, schema},
|
db::{self, custody::DieselCustodyStore, models, schema},
|
||||||
};
|
};
|
||||||
|
|
||||||
use diesel::{ExpressionMethods as _, QueryDsl, SelectableHelper, dsl::sql_query};
|
use diesel::{ExpressionMethods as _, QueryDsl, SelectableHelper, dsl::sql_query};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
use kameo::actor::{ActorRef, Spawn as _};
|
use kameo::actor::{ActorRef, Spawn as _};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::{
|
||||||
|
collections::{HashMap, HashSet},
|
||||||
|
sync::Arc,
|
||||||
|
};
|
||||||
use tokio::task::JoinSet;
|
use tokio::task::JoinSet;
|
||||||
|
|
||||||
const TEST_AAD: &[u8] = b"test-aad";
|
const TEST_AAD: &[u8] = b"test-aad";
|
||||||
@@ -166,9 +169,13 @@ async fn decrypt_roundtrip_after_high_concurrency() {
|
|||||||
let writes = write_concurrently(actor, "roundtrip", 40).await;
|
let writes = write_concurrently(actor, "roundtrip", 40).await;
|
||||||
let expected: HashMap<i32, Vec<u8>> = writes.into_iter().collect();
|
let expected: HashMap<i32, Vec<u8>> = writes.into_iter().collect();
|
||||||
|
|
||||||
let mut decryptor = Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
let mut decryptor = Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
decryptor
|
decryptor
|
||||||
.try_unseal(KeyCell::from([0u8; 32]))
|
.try_unseal(KeyCell::from([0u8; 32]))
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -9,11 +9,12 @@ use arbiter_server::{
|
|||||||
KeyCell,
|
KeyCell,
|
||||||
encryption::v1::{Nonce, ROOT_KEY_TAG},
|
encryption::v1::{Nonce, ROOT_KEY_TAG},
|
||||||
},
|
},
|
||||||
db::{self, models, schema},
|
db::{self, custody::DieselCustodyStore, models, schema},
|
||||||
};
|
};
|
||||||
|
|
||||||
use diesel::{QueryDsl, SelectableHelper};
|
use diesel::{QueryDsl, SelectableHelper};
|
||||||
use diesel_async::RunQueryDsl;
|
use diesel_async::RunQueryDsl;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
const TEST_AAD: &[u8] = b"test-aad";
|
const TEST_AAD: &[u8] = b"test-aad";
|
||||||
|
|
||||||
@@ -21,9 +22,13 @@ const TEST_AAD: &[u8] = b"test-aad";
|
|||||||
#[test_log::test]
|
#[test_log::test]
|
||||||
async fn bootstrap() {
|
async fn bootstrap() {
|
||||||
let db = db::create_test_pool().await;
|
let db = db::create_test_pool().await;
|
||||||
let mut actor = Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let seal_key = KeyCell::from([0u8; 32]);
|
let seal_key = KeyCell::from([0u8; 32]);
|
||||||
actor.bootstrap(seal_key, None).await.unwrap();
|
actor.bootstrap(seal_key, None).await.unwrap();
|
||||||
@@ -57,9 +62,13 @@ async fn bootstrap_rejects_double() {
|
|||||||
#[test_log::test]
|
#[test_log::test]
|
||||||
async fn create_new_before_bootstrap_fails() {
|
async fn create_new_before_bootstrap_fails() {
|
||||||
let db = db::create_test_pool().await;
|
let db = db::create_test_pool().await;
|
||||||
let mut actor = Vault::new(db, GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db,
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let err = actor
|
let err = actor
|
||||||
.create_new(SafeCell::new(b"data".to_vec()), TEST_AAD.to_vec())
|
.create_new(SafeCell::new(b"data".to_vec()), TEST_AAD.to_vec())
|
||||||
@@ -72,9 +81,13 @@ async fn create_new_before_bootstrap_fails() {
|
|||||||
#[test_log::test]
|
#[test_log::test]
|
||||||
async fn decrypt_before_bootstrap_fails() {
|
async fn decrypt_before_bootstrap_fails() {
|
||||||
let db = db::create_test_pool().await;
|
let db = db::create_test_pool().await;
|
||||||
let mut actor = Vault::new(db, GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db,
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let err = actor.decrypt(1, TEST_AAD.to_vec()).await.unwrap_err();
|
let err = actor.decrypt(1, TEST_AAD.to_vec()).await.unwrap_err();
|
||||||
assert!(matches!(err, Error::NotBootstrapped));
|
assert!(matches!(err, Error::NotBootstrapped));
|
||||||
@@ -87,9 +100,13 @@ async fn new_restores_sealed_state() {
|
|||||||
let actor = common::bootstrapped_vault(&db).await;
|
let actor = common::bootstrapped_vault(&db).await;
|
||||||
drop(actor);
|
drop(actor);
|
||||||
|
|
||||||
let mut actor2 = Vault::new(db, GlobalActors::spawn_message_bus())
|
let mut actor2 = Vault::new(
|
||||||
.await
|
db,
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let err = actor2.decrypt(1, TEST_AAD.to_vec()).await.unwrap_err();
|
let err = actor2.decrypt(1, TEST_AAD.to_vec()).await.unwrap_err();
|
||||||
assert!(matches!(err, Error::Sealed));
|
assert!(matches!(err, Error::Sealed));
|
||||||
}
|
}
|
||||||
@@ -107,9 +124,13 @@ async fn unseal_correct_password() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
drop(actor);
|
drop(actor);
|
||||||
|
|
||||||
let mut actor = Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
let seal_key = KeyCell::from([0u8; 32]);
|
let seal_key = KeyCell::from([0u8; 32]);
|
||||||
actor.try_unseal(seal_key).await.unwrap();
|
actor.try_unseal(seal_key).await.unwrap();
|
||||||
|
|
||||||
@@ -130,9 +151,13 @@ async fn unseal_wrong_then_correct_password() {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
drop(actor);
|
drop(actor);
|
||||||
|
|
||||||
let mut actor = Vault::new(db.clone(), GlobalActors::spawn_message_bus())
|
let mut actor = Vault::new(
|
||||||
.await
|
db.clone(),
|
||||||
.unwrap();
|
GlobalActors::spawn_message_bus(),
|
||||||
|
Arc::new(DieselCustodyStore),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let bad_key = KeyCell::from([1u8; 32]);
|
let bad_key = KeyCell::from([1u8; 32]);
|
||||||
let err = actor.try_unseal(bad_key).await.unwrap_err();
|
let err = actor.try_unseal(bad_key).await.unwrap_err();
|
||||||
|
|||||||
Reference in New Issue
Block a user