mirror of
https://github.com/fluencelabs/trust-graph-test
synced 2025-04-24 19:52:27 +00:00
add tests
This commit is contained in:
parent
05db49c757
commit
db4165e663
230
Cargo.lock
generated
230
Cargo.lock
generated
@ -28,9 +28,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.42"
|
||||
version = "1.0.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486"
|
||||
checksum = "28ae2b3dec75a406790005a200b1bd89785afc02517a00ca99ecfe093ee9e6cf"
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
@ -95,9 +95,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.1"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2da1976d75adbe5fbc88130ecd119529cf1cc6a93ae1546d8696ee66f0d21af1"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "blake3"
|
||||
@ -182,9 +182,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.0.1"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
|
||||
checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
|
||||
|
||||
[[package]]
|
||||
name = "cargo_toml"
|
||||
@ -199,9 +199,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.69"
|
||||
version = "1.0.70"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2"
|
||||
checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
@ -251,9 +251,9 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.1.5"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef"
|
||||
checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
@ -390,9 +390,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ctor"
|
||||
version = "0.1.20"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d"
|
||||
checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
@ -537,7 +537,7 @@ dependencies = [
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"sha2 0.9.5",
|
||||
"sha2 0.9.6",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
@ -692,7 +692,7 @@ dependencies = [
|
||||
"libsecp256k1",
|
||||
"log",
|
||||
"multihash",
|
||||
"parking_lot 0.11.1",
|
||||
"parking_lot 0.11.2",
|
||||
"pin-project 1.0.8",
|
||||
"prost",
|
||||
"prost-build",
|
||||
@ -700,7 +700,7 @@ dependencies = [
|
||||
"ring",
|
||||
"rw-stream-sink",
|
||||
"serde",
|
||||
"sha2 0.9.5",
|
||||
"sha2 0.9.6",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"unsigned-varint 0.7.0",
|
||||
@ -742,13 +742,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "fluence-it-types"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5006d09553345421af5dd2334cc945fc34dc2a73d7c1ed842a39a3803699619d"
|
||||
checksum = "047f670b4807cab8872550a607b1515daff08b3e3bb7576ce8f45971fd811a4e"
|
||||
dependencies = [
|
||||
"it-to-bytes",
|
||||
"nom",
|
||||
"serde",
|
||||
"variant_count",
|
||||
"wast",
|
||||
]
|
||||
|
||||
@ -771,7 +772,7 @@ dependencies = [
|
||||
"serde_bytes",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"sha2 0.9.5",
|
||||
"sha2 0.9.6",
|
||||
"signature",
|
||||
"thiserror",
|
||||
"zeroize",
|
||||
@ -795,9 +796,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1adc00f486adfc9ce99f77d717836f0c5aa84965eb0b4f051f4e83f7cab53f8b"
|
||||
checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
@ -810,9 +811,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74ed2411805f6e4e3d9bc904c95d5d423b89b3b25dc0250aa74729de20629ff9"
|
||||
checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@ -820,15 +821,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af51b1b4a7fdff033703db39de8802c673eb91855f2e0d47dcf3bf2c0ef01f99"
|
||||
checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d0d535a57b87e1ae31437b892713aee90cd2d7b0ee48727cd11fc72ef54761c"
|
||||
checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
@ -838,15 +839,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582"
|
||||
checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c54913bae956fb8df7f4dc6fc90362aa72e69148e3f39041fbe8742d21e0ac57"
|
||||
checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"proc-macro-hack",
|
||||
@ -857,15 +858,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "futures-sink"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0f30aaa67363d119812743aa5f33c201a7a66329f97d1a887022971feea4b53"
|
||||
checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe54a98670017f3be909561f6ad13e810d9a51f3f061b902062ca3da80799f2"
|
||||
checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99"
|
||||
|
||||
[[package]]
|
||||
name = "futures-timer"
|
||||
@ -875,9 +876,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67eb846bfd58e44a8481a00049e82c43e0ccb5d61f8dc071057cb19249dd4d78"
|
||||
checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"futures-channel",
|
||||
@ -1138,15 +1139,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "0.4.7"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
|
||||
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.52"
|
||||
version = "0.3.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce791b7ca6638aae45be056e068fc756d871eb3b3b10b8efa62d1c9cec616752"
|
||||
checksum = "e4bf49d50e2961077d9c99f4b7997d770a1114f087c3c2e0069b36c13fc2979d"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
@ -1178,9 +1179,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.99"
|
||||
version = "0.2.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765"
|
||||
checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21"
|
||||
|
||||
[[package]]
|
||||
name = "libsecp256k1"
|
||||
@ -1209,9 +1210,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.4.4"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
|
||||
checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109"
|
||||
dependencies = [
|
||||
"scopeguard",
|
||||
]
|
||||
@ -1233,13 +1234,13 @@ checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
||||
|
||||
[[package]]
|
||||
name = "marine-it-generator"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e62f29b16bbdb0763a04f8561c954624ee9cd9f558af4e67b95eb00880da11ec"
|
||||
checksum = "e7b40920a86fb49456f0e94862d56a8e0bfc22489e518d894628da0f3ade03d8"
|
||||
dependencies = [
|
||||
"cargo_toml",
|
||||
"it-lilo",
|
||||
"marine-it-parser 0.6.5",
|
||||
"marine-it-parser 0.6.6",
|
||||
"marine-macro-impl",
|
||||
"once_cell",
|
||||
"serde",
|
||||
@ -1261,9 +1262,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marine-it-interfaces"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f18c137e51fd52ab7a3652233fc4eaa68e25a6a53d609bf9dd0f2e3bf67adee1"
|
||||
checksum = "42e229143e72ba20e754de4766ff0d02e0cf176001f7471593f82b16c72dc26d"
|
||||
dependencies = [
|
||||
"multimap",
|
||||
"wasmer-interface-types-fl",
|
||||
@ -1288,13 +1289,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marine-it-parser"
|
||||
version = "0.6.5"
|
||||
version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19a6606e472587b2e7b759b16d037a4ea951facc2a6650f668f22403978c2442"
|
||||
checksum = "4154fc98fcfeba65a45d774cff6eeb8bddc8aa66e897f46a74dc95e8823771ea"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.10.1",
|
||||
"marine-it-interfaces 0.4.0",
|
||||
"marine-it-interfaces 0.4.1",
|
||||
"marine-module-interface",
|
||||
"nom",
|
||||
"semver 0.11.0",
|
||||
@ -1346,13 +1347,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marine-module-interface"
|
||||
version = "0.1.4"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8a5936273bebb523ed169863282dbc19fc66bb983c7031c5b8b0556584f2401"
|
||||
checksum = "035fb5d160a50cbcbe244a343081550f689ceba945d95281bbe207d98bf25586"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.10.1",
|
||||
"marine-it-interfaces 0.4.0",
|
||||
"marine-it-interfaces 0.4.1",
|
||||
"nom",
|
||||
"semver 0.11.0",
|
||||
"serde",
|
||||
@ -1409,8 +1410,8 @@ dependencies = [
|
||||
"it-lilo",
|
||||
"log",
|
||||
"marine-it-generator",
|
||||
"marine-it-interfaces 0.4.0",
|
||||
"marine-it-parser 0.6.5",
|
||||
"marine-it-interfaces 0.4.1",
|
||||
"marine-it-parser 0.6.6",
|
||||
"marine-module-info-parser",
|
||||
"marine-module-interface",
|
||||
"marine-utils",
|
||||
@ -1430,9 +1431,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marine-sqlite-connector"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7aef66554a852d86eb2ee64fc11651ecb798549d0d8204761866f7fa0a40ebb"
|
||||
checksum = "c514fdaa43d543a58a01136d3ac4ddcfdb438cb5e25fc164554ab556c2126efa"
|
||||
dependencies = [
|
||||
"marine-rs-sdk",
|
||||
]
|
||||
@ -1484,15 +1485,15 @@ checksum = "8dc5838acba84ce4d802d672afd0814fae0ae7098021ae5b06d975e70d09f812"
|
||||
|
||||
[[package]]
|
||||
name = "matches"
|
||||
version = "0.1.8"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.0"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "memmap"
|
||||
@ -1532,7 +1533,7 @@ dependencies = [
|
||||
"digest 0.9.0",
|
||||
"generic-array 0.14.4",
|
||||
"multihash-derive",
|
||||
"sha2 0.9.5",
|
||||
"sha2 0.9.6",
|
||||
"unsigned-varint 0.5.1",
|
||||
]
|
||||
|
||||
@ -1614,9 +1615,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "object"
|
||||
version = "0.26.0"
|
||||
version = "0.26.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c55827317fb4c08822499848a14237d2874d6f139828893017237e7ab93eb386"
|
||||
checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
@ -1667,13 +1668,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot"
|
||||
version = "0.11.1"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
|
||||
checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99"
|
||||
dependencies = [
|
||||
"instant",
|
||||
"lock_api 0.4.4",
|
||||
"parking_lot_core 0.8.3",
|
||||
"lock_api 0.4.5",
|
||||
"parking_lot_core 0.8.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1692,9 +1693,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "parking_lot_core"
|
||||
version = "0.8.3"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
|
||||
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"instant",
|
||||
@ -1841,9 +1842,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.28"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612"
|
||||
checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
@ -2147,9 +2148,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.20"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dead70b0b5e03e9c814bcb6b01e03e68f7c57a80aa48c72ec92152ab3e818d49"
|
||||
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
@ -2273,9 +2274,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.66"
|
||||
version = "1.0.67"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127"
|
||||
checksum = "a7f9e390c27c3c0ce8bc5d725f6e4d30a29d26659494aa4b17535f7522c5c950"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
@ -2294,9 +2295,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_with_macros"
|
||||
version = "1.4.2"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1569374bd54623ec8bd592cf22ba6e03c0f177ff55fbc8c29a49e296e7adecf"
|
||||
checksum = "98c1fcca18d55d1763e1c16873c4bde0ac3ef75179a28c7b372917e0494625be"
|
||||
dependencies = [
|
||||
"darling 0.13.0",
|
||||
"proc-macro2",
|
||||
@ -2318,9 +2319,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.9.5"
|
||||
version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12"
|
||||
checksum = "9204c41a1597a8c5af23c82d1c921cb01ec0a4c59e07a9c7306062829a3903f3"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"cfg-if 1.0.0",
|
||||
@ -2379,9 +2380,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.74"
|
||||
version = "1.0.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c"
|
||||
checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2422,18 +2423,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.26"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
|
||||
checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.26"
|
||||
version = "1.0.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
|
||||
checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2490,7 +2491,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"sha2 0.9.5",
|
||||
"sha2 0.9.6",
|
||||
"signature",
|
||||
"thiserror",
|
||||
]
|
||||
@ -2510,7 +2511,7 @@ dependencies = [
|
||||
"marine-rs-sdk-test",
|
||||
"marine-sqlite-connector",
|
||||
"once_cell",
|
||||
"parking_lot 0.11.1",
|
||||
"parking_lot 0.11.2",
|
||||
"rmp-serde",
|
||||
"serde_bencode",
|
||||
"serde_json",
|
||||
@ -2520,9 +2521,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.13.0"
|
||||
version = "1.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
|
||||
checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
|
||||
|
||||
[[package]]
|
||||
name = "typetag"
|
||||
@ -2556,12 +2557,9 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.5"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0"
|
||||
dependencies = [
|
||||
"matches",
|
||||
]
|
||||
checksum = "246f4c42e67e7a4e3c6106ff716a5d067d4132a642840b242e357e468a2a0085"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
@ -2623,6 +2621,16 @@ dependencies = [
|
||||
"getrandom 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "variant_count"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aae2faf80ac463422992abf4de234731279c058aaf33171ca70277c98406b124"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.3"
|
||||
@ -2675,9 +2683,9 @@ checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.75"
|
||||
version = "0.2.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b608ecc8f4198fe8680e2ed18eccab5f0cd4caaf3d83516fa5fb2e927fda2586"
|
||||
checksum = "8ce9b1b516211d33767048e5d47fa2a381ed8b76fc48d2ce4aa39877f9f183e0"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"wasm-bindgen-macro",
|
||||
@ -2685,9 +2693,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.75"
|
||||
version = "0.2.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "580aa3a91a63d23aac5b6b267e2d13cb4f363e31dce6c352fca4752ae12e479f"
|
||||
checksum = "cfe8dc78e2326ba5f845f4b5bf548401604fa20b1dd1d365fb73b6c1d6364041"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
@ -2700,9 +2708,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.75"
|
||||
version = "0.2.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "171ebf0ed9e1458810dfcb31f2e766ad6b3a89dbda42d8901f2b268277e5f09c"
|
||||
checksum = "44468aa53335841d9d6b6c023eaab07c0cd4bddbcfdee3e2bb1e8d2cb8069fef"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@ -2710,9 +2718,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.75"
|
||||
version = "0.2.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c2657dd393f03aa2a659c25c6ae18a13a4048cebd220e147933ea837efc589f"
|
||||
checksum = "0195807922713af1e67dc66132c7328206ed9766af3858164fb583eedc25fbad"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2723,9 +2731,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.75"
|
||||
version = "0.2.76"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e0c4a743a309662d45f4ede961d7afa4ba4131a59a639f29b0069c3798bbcc2"
|
||||
checksum = "acdb075a845574a1fa5f09fd77e43f7747599301ea3417a9fbffdeedfc1f4a29"
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-clif-backend-fl"
|
||||
@ -2781,9 +2789,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasmer-interface-types-fl"
|
||||
version = "0.20.1"
|
||||
version = "0.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df960871d756f87237e7630daa0e8453dd48f9e44e0f214e795362a6daa04967"
|
||||
checksum = "14ba3b5a07989987994b96bf5cc7ac2947005f9ff6123d71b7064232f07d28fa"
|
||||
dependencies = [
|
||||
"fluence-it-types",
|
||||
"it-lilo",
|
||||
@ -2926,9 +2934,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.52"
|
||||
version = "0.3.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "01c70a82d842c9979078c772d4a1344685045f1a5628f677c2b2eab4dd7d2696"
|
||||
checksum = "224b2f6b67919060055ef1a67807367c2066ed520c3862cc013d26cf893a783c"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::ed25519;
|
||||
use crate::error::{DecodingError, SigningError};
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::rsa;
|
||||
use crate::secp256k1;
|
||||
use crate::error::{DecodingError, SigningError};
|
||||
use crate::signature::Signature;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::key_pair::KeyFormat;
|
||||
use std::convert::TryFrom;
|
||||
use libp2p_core::PeerId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::convert::TryFrom;
|
||||
|
||||
/// The public key of a node's identity keypair.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
@ -42,13 +42,14 @@ impl PublicKey {
|
||||
/// that the signature has been produced by the corresponding
|
||||
/// private key (authenticity), and that the message has not been
|
||||
/// tampered with (integrity).
|
||||
// TODO: add VerificationError
|
||||
pub fn verify(&self, msg: &[u8], sig: &Signature) -> Result<(), SigningError> {
|
||||
use PublicKey::*;
|
||||
match self {
|
||||
Ed25519(pk) => pk.verify(msg, sig.to_vec()),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Rsa(pk) => pk.verify(msg, sig.to_vec()),
|
||||
Secp256k1(pk) => pk.verify(msg, sig.to_vec())
|
||||
Secp256k1(pk) => pk.verify(msg, sig.to_vec()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,8 +71,12 @@ impl PublicKey {
|
||||
match KeyFormat::try_from(bytes[0])? {
|
||||
KeyFormat::Ed25519 => Ok(PublicKey::Ed25519(ed25519::PublicKey::decode(&bytes[1..])?)),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
KeyFormat::Rsa => Ok(PublicKey::Rsa(rsa::PublicKey::from_pkcs1(bytes[1..].to_owned())?)),
|
||||
KeyFormat::Secp256k1 => Ok(PublicKey::Secp256k1(secp256k1::PublicKey::decode(&bytes[1..])?)),
|
||||
KeyFormat::Rsa => Ok(PublicKey::Rsa(rsa::PublicKey::from_pkcs1(
|
||||
bytes[1..].to_owned(),
|
||||
)?)),
|
||||
KeyFormat::Secp256k1 => Ok(PublicKey::Secp256k1(secp256k1::PublicKey::decode(
|
||||
&bytes[1..],
|
||||
)?)),
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,12 +86,14 @@ impl PublicKey {
|
||||
Ed25519(_) => KeyFormat::Ed25519.into(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Rsa(_) => KeyFormat::Rsa.into(),
|
||||
Secp256k1(_) => KeyFormat::Secp256k1.into()
|
||||
Secp256k1(_) => KeyFormat::Secp256k1.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_base58(str: &str) -> Result<PublicKey, DecodingError> {
|
||||
let bytes = bs58::decode(str).into_vec().map_err(DecodingError::Base58DecodeError)?;
|
||||
let bytes = bs58::decode(str)
|
||||
.into_vec()
|
||||
.map_err(DecodingError::Base58DecodeError)?;
|
||||
Self::decode(&bytes)
|
||||
}
|
||||
|
||||
@ -111,10 +118,14 @@ impl From<libp2p_core::identity::PublicKey> for PublicKey {
|
||||
use libp2p_core::identity::PublicKey::*;
|
||||
|
||||
match key {
|
||||
Ed25519(key) => PublicKey::Ed25519(ed25519::PublicKey::decode(&key.encode()[..]).unwrap()),
|
||||
Ed25519(key) => {
|
||||
PublicKey::Ed25519(ed25519::PublicKey::decode(&key.encode()[..]).unwrap())
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Rsa(key) => PublicKey::Rsa(rsa::PublicKey::from_pkcs1(key.encode_pkcs1()).unwrap()),
|
||||
Secp256k1(key) => PublicKey::Secp256k1(secp256k1::PublicKey::decode(&key.encode()[..]).unwrap()),
|
||||
Secp256k1(key) => {
|
||||
PublicKey::Secp256k1(secp256k1::PublicKey::decode(&key.encode()[..]).unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -124,16 +135,28 @@ impl From<PublicKey> for libp2p_core::identity::PublicKey {
|
||||
use libp2p_core::identity as libp2p_identity;
|
||||
|
||||
match key {
|
||||
PublicKey::Ed25519(key) => libp2p_identity::PublicKey::Ed25519(libp2p_identity::ed25519::PublicKey::decode(&key.encode()[..]).unwrap()),
|
||||
PublicKey::Ed25519(key) => libp2p_identity::PublicKey::Ed25519(
|
||||
libp2p_identity::ed25519::PublicKey::decode(&key.encode()[..]).unwrap(),
|
||||
),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
PublicKey::Rsa(key) => libp2p_identity::PublicKey::Rsa(libp2p_identity::rsa::PublicKey::decode_x509(&key.encode_x509()).unwrap()),
|
||||
PublicKey::Secp256k1(key) => libp2p_identity::PublicKey::Secp256k1(libp2p_identity::secp256k1::PublicKey::decode(&key.encode()[..]).unwrap()),
|
||||
PublicKey::Rsa(key) => libp2p_identity::PublicKey::Rsa(
|
||||
libp2p_identity::rsa::PublicKey::decode_x509(&key.encode_x509()).unwrap(),
|
||||
),
|
||||
PublicKey::Secp256k1(key) => libp2p_identity::PublicKey::Secp256k1(
|
||||
libp2p_identity::secp256k1::PublicKey::decode(&key.encode()[..]).unwrap(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn peer_id_to_fluence_pk(peer_id: libp2p_core::PeerId) -> eyre::Result<PublicKey> {
|
||||
Ok(peer_id.as_public_key().ok_or(eyre::eyre!("public key is not inlined in peer id: {}", peer_id))?.into())
|
||||
Ok(peer_id
|
||||
.as_public_key()
|
||||
.ok_or(eyre::eyre!(
|
||||
"public key is not inlined in peer id: {}",
|
||||
peer_id
|
||||
))?
|
||||
.into())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
use crate::ed25519;
|
||||
use crate::{ed25519, PublicKey};
|
||||
use crate::secp256k1;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use crate::rsa;
|
||||
@ -107,6 +107,16 @@ impl Signature {
|
||||
_ => Err(DecodingError::RawSignatureUnsupportedType(raw_signature.sig_type)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_bytes_with_public_key(pk: &PublicKey, bytes: Vec<u8>) -> Self {
|
||||
use PublicKey::*;
|
||||
match pk {
|
||||
Ed25519(_) => Signature::Ed25519(ed25519::Signature(bytes)),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
Rsa(_) => Signature::Rsa(rsa::Signature(bytes)),
|
||||
Secp256k1(_) => Signature::Secp256k1(secp256k1::Signature(bytes))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -14,7 +14,7 @@ path = "src/main.rs"
|
||||
trust-graph = { version = "0.2.6", path = "../." }
|
||||
fluence-keypair = { version = "0.3.0", path = "../keypair" }
|
||||
marine-rs-sdk = { version = "0.6.11", features = ["logger"] }
|
||||
marine-sqlite-connector = "0.5.0"
|
||||
marine-sqlite-connector = "0.5.1"
|
||||
|
||||
libp2p-core = { package = "fluence-fork-libp2p-core", version = "0.27.2", features = ["secp256k1"]}
|
||||
|
||||
|
@ -3,7 +3,7 @@ modules_dir = "artifacts/"
|
||||
[[module]]
|
||||
name = "sqlite3"
|
||||
mem_pages_count = 100
|
||||
logger_enabled = false
|
||||
logger_enabled = true
|
||||
|
||||
[[module]]
|
||||
name = "trust-graph"
|
||||
|
Binary file not shown.
@ -5,7 +5,6 @@ set -o errexit -o nounset -o pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
# build trust-graph.wasm
|
||||
#cargo update
|
||||
marine build --release
|
||||
|
||||
# copy .wasm to artifacts
|
||||
@ -14,7 +13,7 @@ mkdir -p artifacts
|
||||
cp ../target/wasm32-wasi/release/trust-graph.wasm artifacts/
|
||||
|
||||
# download SQLite 3 to use in tests
|
||||
curl -L https://github.com/fluencelabs/sqlite/releases/download/v0.14.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm
|
||||
curl -L https://github.com/fluencelabs/sqlite/releases/download/v0.15.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm
|
||||
|
||||
# generate Aqua bindings
|
||||
marine aqua artifacts/trust-graph.wasm -s TrustGraph -i trust-graph > trust-graph.aqua
|
||||
|
@ -91,7 +91,7 @@ impl TryFrom<Trust> for trust_graph::Trust {
|
||||
|
||||
impl From<trust_graph::Trust> for Trust {
|
||||
fn from(t: trust_graph::Trust) -> Self {
|
||||
let issued_for = bs58::encode(t.issued_for.encode()).into_string();
|
||||
let issued_for = t.issued_for.to_peer_id().to_base58();
|
||||
let raw_signature = t.signature.get_raw_signature();
|
||||
let signature = bs58::encode(raw_signature.bytes).into_string();
|
||||
let expires_at = t.expires_at.as_secs();
|
||||
|
@ -9,7 +9,7 @@ mod tests;
|
||||
|
||||
pub fn main() {
|
||||
WasmLoggerBuilder::new()
|
||||
.with_log_level(log::LevelFilter::Info)
|
||||
.with_log_level(log::LevelFilter::Trace)
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ impl From<Result<Vec<u8>, ServiceError>> for GetTrustMetadataResult {
|
||||
Ok(res) => GetTrustMetadataResult {
|
||||
success: true,
|
||||
error: "".to_string(),
|
||||
result: res
|
||||
result: res,
|
||||
},
|
||||
Err(e) => GetTrustMetadataResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
result: vec![]
|
||||
result: vec![],
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -139,3 +139,48 @@ impl From<Result<Trust, ServiceError>> for IssueTrustResult {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[marine]
|
||||
pub struct VerifyTrustResult {
|
||||
pub success: bool,
|
||||
pub error: String,
|
||||
}
|
||||
|
||||
impl From<Result<(), ServiceError>> for VerifyTrustResult {
|
||||
fn from(result: Result<(), ServiceError>) -> Self {
|
||||
match result {
|
||||
Ok(()) => VerifyTrustResult {
|
||||
success: true,
|
||||
error: "".to_string(),
|
||||
},
|
||||
Err(e) => VerifyTrustResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[marine]
|
||||
pub struct IssueCertificateResult {
|
||||
pub success: bool,
|
||||
pub error: String,
|
||||
pub cert: Certificate,
|
||||
}
|
||||
|
||||
impl From<Result<Certificate, ServiceError>> for IssueCertificateResult {
|
||||
fn from(result: Result<Certificate, ServiceError>) -> Self {
|
||||
match result {
|
||||
Ok(cert) => IssueCertificateResult {
|
||||
success: true,
|
||||
error: "".to_string(),
|
||||
cert,
|
||||
},
|
||||
Err(e) => IssueCertificateResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
cert: Certificate { chain: vec![] },
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,14 @@
|
||||
use crate::dto::Certificate;
|
||||
use crate::results::{AddRootResult, AllCertsResult, InsertResult, WeightResult, GetTrustMetadataResult};
|
||||
use crate::service_impl::{add_root_impl, get_all_certs_impl, get_weight_impl, insert_cert_impl, insert_cert_impl_raw, get_trust_metadata_imp};
|
||||
use marine_rs_sdk::{CallParameters, marine};
|
||||
use crate::dto::{Certificate, Trust};
|
||||
use crate::results::{
|
||||
AddRootResult, AllCertsResult, GetTrustMetadataResult, InsertResult, IssueCertificateResult,
|
||||
IssueTrustResult, VerifyTrustResult, WeightResult,
|
||||
};
|
||||
use crate::service_impl::{
|
||||
add_root_impl, get_all_certs_impl, get_trust_metadata_imp, get_weight_impl, insert_cert_impl,
|
||||
insert_cert_impl_raw, issue_certificate_with_trust_checked_impl,
|
||||
issue_root_certificate_checked_impl, issue_trust_impl, verify_trust_impl,
|
||||
};
|
||||
use marine_rs_sdk::{marine, CallParameters};
|
||||
|
||||
#[marine]
|
||||
/// add a certificate in string representation to trust graph if it is valid
|
||||
@ -18,11 +25,13 @@ fn insert_cert(certificate: Certificate, current_time: u64) -> InsertResult {
|
||||
insert_cert_impl(certificate, current_time).into()
|
||||
}
|
||||
|
||||
// TODO: pass current timestamp, return only valid, delete expired
|
||||
#[marine]
|
||||
fn get_weight(peer_id: String) -> WeightResult {
|
||||
get_weight_impl(peer_id).into()
|
||||
}
|
||||
|
||||
// TODO: pass current timestamp, return only valid, delete expired
|
||||
#[marine]
|
||||
fn get_all_certs(issued_for: String) -> AllCertsResult {
|
||||
get_all_certs_impl(issued_for).into()
|
||||
@ -37,18 +46,52 @@ fn add_root(peer_id: String, weight: u32) -> AddRootResult {
|
||||
add_root_impl(peer_id, weight).into()
|
||||
} else {
|
||||
return AddRootResult {
|
||||
success: true,
|
||||
success: false,
|
||||
error: "Root could add only a host of trust graph service".to_string(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#[marine]
|
||||
fn get_trust_metadata(peer_id: String, expires_at: u64, issued_at: u64) -> GetTrustMetadataResult {
|
||||
get_trust_metadata_imp(peer_id, expires_at, issued_at).into()
|
||||
fn get_trust_metadata(
|
||||
issued_for_peer_id: String,
|
||||
expires_at: u64,
|
||||
issued_at: u64,
|
||||
) -> GetTrustMetadataResult {
|
||||
get_trust_metadata_imp(issued_for_peer_id, expires_at, issued_at).into()
|
||||
}
|
||||
|
||||
// #[marine]
|
||||
// fn issue_trust(peer_id: String, expires_at: u64, issued_at: u64, signed_metadata: Vec<u8>, sig_type: String) -> IssueTrustResult {
|
||||
// issue_trust_impl(peer_id, expires_at, issued_at, signed_metadata).into()
|
||||
// }
|
||||
#[marine]
|
||||
fn issue_trust(
|
||||
issued_for_peer_id: String,
|
||||
expires_at: u64,
|
||||
issued_at: u64,
|
||||
signed_metadata: Vec<u8>,
|
||||
) -> IssueTrustResult {
|
||||
issue_trust_impl(issued_for_peer_id, expires_at, issued_at, signed_metadata).into()
|
||||
}
|
||||
|
||||
// TODO: use "peer" "timestamp_sec" and check tetraplets
|
||||
#[marine]
|
||||
fn verify_trust(trust: Trust, issuer_peer_id: String, cur_time: u64) -> VerifyTrustResult {
|
||||
verify_trust_impl(trust, issuer_peer_id, cur_time).into()
|
||||
}
|
||||
|
||||
#[marine]
|
||||
fn issue_root_certificate_checked(
|
||||
root_trust: Trust,
|
||||
issued_trust: Trust,
|
||||
cur_time: u64,
|
||||
) -> IssueCertificateResult {
|
||||
issue_root_certificate_checked_impl(root_trust, issued_trust, cur_time).into()
|
||||
}
|
||||
|
||||
#[marine]
|
||||
fn issue_certificate_with_trust_checked(
|
||||
cert: Certificate,
|
||||
trust: Trust,
|
||||
issued_by_peer_id: String,
|
||||
cur_time: u64,
|
||||
) -> IssueCertificateResult {
|
||||
issue_certificate_with_trust_checked_impl(cert, trust, issued_by_peer_id, cur_time).into()
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
use crate::dto::{Certificate, DtoConversionError, Trust};
|
||||
use crate::storage_impl::get_data;
|
||||
use fluence_keypair::error::DecodingError;
|
||||
use fluence_keypair::PublicKey;
|
||||
use fluence_keypair::public_key::peer_id_to_fluence_pk;
|
||||
use fluence_keypair::{PublicKey, Signature};
|
||||
use libp2p_core::PeerId;
|
||||
use std::convert::{Into, TryInto};
|
||||
use std::str::FromStr;
|
||||
use std::time::Duration;
|
||||
use thiserror::Error as ThisError;
|
||||
use trust_graph::{CertificateError, TrustGraphError};
|
||||
use fluence_keypair::public_key::peer_id_to_fluence_pk;
|
||||
use libp2p_core::PeerId;
|
||||
use trust_graph::{current_time, CertificateError, TrustError, TrustGraphError};
|
||||
|
||||
#[derive(ThisError, Debug)]
|
||||
pub enum ServiceError {
|
||||
@ -40,14 +40,22 @@ pub enum ServiceError {
|
||||
#[source]
|
||||
DtoConversionError,
|
||||
),
|
||||
#[error("{0}")]
|
||||
TrustError(
|
||||
#[from]
|
||||
#[source]
|
||||
TrustError,
|
||||
),
|
||||
}
|
||||
|
||||
fn parse_peer_id(peer_id: String) -> Result<PeerId, ServiceError> {
|
||||
libp2p_core::PeerId::from_str(&peer_id).map_err(|e| ServiceError::PeerIdParseError(format!("{:?}", e)))
|
||||
libp2p_core::PeerId::from_str(&peer_id)
|
||||
.map_err(|e| ServiceError::PeerIdParseError(format!("{:?}", e)))
|
||||
}
|
||||
|
||||
fn extract_public_key(peer_id: String) -> Result<PublicKey, ServiceError> {
|
||||
peer_id_to_fluence_pk(parse_peer_id(peer_id)?).map_err(|e| ServiceError::PublicKeyExtractionError(e.to_string()))
|
||||
peer_id_to_fluence_pk(parse_peer_id(peer_id)?)
|
||||
.map_err(|e| ServiceError::PublicKeyExtractionError(e.to_string()))
|
||||
}
|
||||
|
||||
pub fn get_weight_impl(peer_id: String) -> Result<Option<u32>, ServiceError> {
|
||||
@ -99,15 +107,76 @@ pub fn add_root_impl(peer_id: String, weight: u32) -> Result<(), ServiceError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_trust_metadata_imp(peer_id: String, expires_at: u64, issued_at: u64) -> Result<Vec<u8>, ServiceError> {
|
||||
pub fn get_trust_metadata_imp(
|
||||
peer_id: String,
|
||||
expires_at: u64,
|
||||
issued_at: u64,
|
||||
) -> Result<Vec<u8>, ServiceError> {
|
||||
let public_key = extract_public_key(peer_id)?;
|
||||
Ok(trust_graph::Trust::metadata_bytes(&public_key,
|
||||
Duration::from_secs(expires_at),
|
||||
Duration::from_secs(issued_at)))
|
||||
Ok(trust_graph::Trust::metadata_bytes(
|
||||
&public_key,
|
||||
Duration::from_secs(expires_at),
|
||||
Duration::from_secs(issued_at),
|
||||
))
|
||||
}
|
||||
|
||||
// pub fn issue_trust_impl(peer_id: String, expires_at: u64, issued_at: u64, signed_metadata: Vec<u8>) -> Result<Trust, ServiceError> {
|
||||
// let public_key = extract_public_key(peer_id)?;
|
||||
// trust_graph::Trust::new(public_key, Duration::from_secs(expires_at), Duration::from_secs(issued_at),
|
||||
// )
|
||||
// }
|
||||
pub fn issue_trust_impl(
|
||||
peer_id: String,
|
||||
expires_at: u64,
|
||||
issued_at: u64,
|
||||
signed_metadata: Vec<u8>,
|
||||
) -> Result<Trust, ServiceError> {
|
||||
let public_key = extract_public_key(peer_id)?;
|
||||
let expires_at = Duration::from_secs(expires_at);
|
||||
let issued_at = Duration::from_secs(issued_at);
|
||||
let signature = Signature::from_bytes_with_public_key(&public_key, signed_metadata);
|
||||
Ok(Trust::from(trust_graph::Trust::new(
|
||||
public_key, expires_at, issued_at, signature,
|
||||
)))
|
||||
}
|
||||
|
||||
pub fn verify_trust_impl(
|
||||
trust: Trust,
|
||||
issuer_peer_id: String,
|
||||
cur_time: u64,
|
||||
) -> Result<(), ServiceError> {
|
||||
let public_key = extract_public_key(issuer_peer_id)?;
|
||||
trust_graph::Trust::verify(
|
||||
&trust.try_into()?,
|
||||
&public_key,
|
||||
Duration::from_secs(cur_time),
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn issue_root_certificate_checked_impl(
|
||||
root_trust: Trust,
|
||||
issued_trust: Trust,
|
||||
cur_time: u64,
|
||||
) -> Result<Certificate, ServiceError> {
|
||||
trust_graph::Certificate::new_from_root_trust(
|
||||
root_trust.try_into()?,
|
||||
issued_trust.try_into()?,
|
||||
Duration::from_secs(cur_time),
|
||||
)
|
||||
.map(|c| c.into())
|
||||
.map_err(ServiceError::CertError)
|
||||
}
|
||||
|
||||
pub fn issue_certificate_with_trust_checked_impl(
|
||||
cert: Certificate,
|
||||
trust: Trust,
|
||||
issued_by: String,
|
||||
cur_time: u64,
|
||||
) -> Result<Certificate, ServiceError> {
|
||||
let public_key = extract_public_key(issued_by)?;
|
||||
trust_graph::Certificate::issue_with_trust(
|
||||
public_key,
|
||||
trust.try_into()?,
|
||||
&cert.try_into()?,
|
||||
Duration::from_secs(cur_time),
|
||||
)
|
||||
.map(|c| c.into())
|
||||
.map_err(ServiceError::CertError)
|
||||
}
|
||||
|
@ -3,15 +3,15 @@
|
||||
// if there is an older trust - don't add received trust
|
||||
|
||||
use crate::storage_impl::SQLiteStorageError::{
|
||||
PublicKeyNotFound, PublicKeyConversion, PublicKeyFromStr, TrustNodeConversion,
|
||||
PublicKeyConversion, PublicKeyFromStr, PublicKeyNotFound, TrustNodeConversion,
|
||||
WeightConversionDB,
|
||||
};
|
||||
use core::convert::TryFrom;
|
||||
use fluence_keypair::public_key::PublicKey;
|
||||
use marine_sqlite_connector;
|
||||
use marine_sqlite_connector::Connection;
|
||||
use marine_sqlite_connector::Error as InternalSqliteError;
|
||||
use marine_sqlite_connector::Value;
|
||||
use fluence_keypair::public_key::PublicKey;
|
||||
use once_cell::sync::OnceCell;
|
||||
use parking_lot::Mutex;
|
||||
use rmp_serde::decode::Error as RmpDecodeError;
|
||||
@ -128,14 +128,13 @@ impl Storage for SQLiteStorage {
|
||||
fn insert(&mut self, pk: PK, node: TrustNode) -> Result<(), Self::Error> {
|
||||
let mut cursor = self
|
||||
.connection
|
||||
.prepare("INSERT OR REPLACE INTO trustnodes VALUES (?, ?)")?
|
||||
.cursor();
|
||||
.prepare("INSERT OR REPLACE INTO trustnodes VALUES (?, ?)")?;
|
||||
|
||||
let tn_vec = rmp_serde::to_vec(&node)?;
|
||||
|
||||
log::info!("insert: {:?}", tn_vec);
|
||||
|
||||
cursor.bind(&[Value::String(format!("{}", pk)), Value::Binary(tn_vec)])?;
|
||||
let p = format!("{}", pk);
|
||||
cursor.bind(1, &Value::String(p))?;
|
||||
cursor.bind(2, &Value::Binary(tn_vec))?;
|
||||
|
||||
cursor.next()?;
|
||||
Ok({})
|
||||
|
@ -14,34 +14,117 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// TODO: clear DB before every test, run in 1 thread
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use marine_rs_sdk_test::marine_test;
|
||||
use fluence_keypair;
|
||||
use fluence_keypair::KeyPair;
|
||||
use marine_rs_sdk_test::marine_test;
|
||||
use std::time::Duration;
|
||||
|
||||
// #[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")]
|
||||
// fn test() {
|
||||
//
|
||||
// let root_kp = Keypair::
|
||||
// let root_kp2 = KeyPair::generate();
|
||||
// let second_kp = KeyPair::generate();
|
||||
//
|
||||
// let expires_at = Duration::new(15, 15);
|
||||
// let issued_at = Duration::new(5, 5);
|
||||
//
|
||||
// let cert = trust_graph::Certificate::issue_root(
|
||||
// &root_kp,
|
||||
// second_kp.public_key(),
|
||||
// expires_at,
|
||||
// issued_at,
|
||||
// );
|
||||
// trast_graph.add_root(root_kp.public().into(), 0).unwrap();
|
||||
// tg.add_root_weight(root_kp2.public().into(), 1).unwrap();
|
||||
// tg.add(cert, Duration::new(10, 10)).unwrap();
|
||||
//
|
||||
// let a = tg.get(second_kp.public_key()).unwrap();
|
||||
// let str = format!("{:?}", a);
|
||||
// log::info!("{}", &str);
|
||||
// }
|
||||
}
|
||||
macro_rules! issue_trust {
|
||||
($trust_graph:expr, $issuer_kp:expr, $issued_peer_id: expr, $expires_at:expr, $issued_at: expr) => {{
|
||||
let trust_metadata_result = $trust_graph.get_trust_metadata(
|
||||
$issued_peer_id.to_base58(),
|
||||
$expires_at,
|
||||
$issued_at,
|
||||
);
|
||||
assert_result!(trust_metadata_result);
|
||||
|
||||
let metadata = trust_metadata_result.result;
|
||||
let signed_metadata = $issuer_kp.sign(&metadata).unwrap().to_vec().to_vec();
|
||||
let trust_result = $trust_graph.issue_trust(
|
||||
$issued_peer_id.to_base58(),
|
||||
$expires_at,
|
||||
$issued_at,
|
||||
signed_metadata.to_vec(),
|
||||
);
|
||||
assert_result!(trust_result);
|
||||
|
||||
trust_result.trust
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! assert_result {
|
||||
($result:expr) => {{
|
||||
assert!($result.success, "{:?}", $result.error);
|
||||
}};
|
||||
}
|
||||
|
||||
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")]
|
||||
fn issue_trust_test() {
|
||||
let issuer_kp = KeyPair::generate_ed25519();
|
||||
let issued_peer_id = KeyPair::generate_ed25519().get_peer_id();
|
||||
let issued_at = 0u64;
|
||||
let expires_at = 10u64;
|
||||
let trust = issue_trust!(
|
||||
trust_graph,
|
||||
issuer_kp,
|
||||
issued_peer_id,
|
||||
expires_at,
|
||||
issued_at
|
||||
);
|
||||
let verify_result = trust_graph.verify_trust(trust, issuer_kp.get_peer_id().to_base58(), 0);
|
||||
assert_result!(verify_result);
|
||||
}
|
||||
|
||||
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")]
|
||||
fn issue_cert_test() {
|
||||
let issuer_kp = KeyPair::generate_ed25519();
|
||||
let issued_peer_id = KeyPair::generate_ed25519().get_peer_id();
|
||||
let issued_at = 0u64;
|
||||
let expires_at = 10u64;
|
||||
let root_trust = issue_trust!(
|
||||
trust_graph,
|
||||
issuer_kp,
|
||||
issuer_kp.get_peer_id(),
|
||||
expires_at,
|
||||
issued_at
|
||||
);
|
||||
let trust = issue_trust!(
|
||||
trust_graph,
|
||||
issuer_kp,
|
||||
issued_peer_id,
|
||||
expires_at,
|
||||
issued_at
|
||||
);
|
||||
|
||||
let cert_result = trust_graph.issue_root_certificate_checked(root_trust, trust, 0u64);
|
||||
assert_result!(cert_result);
|
||||
}
|
||||
|
||||
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")]
|
||||
fn extend_cert_test() {
|
||||
let issuer_kp = KeyPair::generate_ed25519();
|
||||
let issued_peer_id = KeyPair::generate_ed25519().get_peer_id();
|
||||
let issued_at = 0u64;
|
||||
let expires_at = 10u64;
|
||||
let root_trust = issue_trust!(
|
||||
trust_graph,
|
||||
issuer_kp,
|
||||
issuer_kp.get_peer_id(),
|
||||
expires_at,
|
||||
issued_at
|
||||
);
|
||||
let trust = issue_trust!(
|
||||
trust_graph,
|
||||
issuer_kp,
|
||||
issued_peer_id,
|
||||
expires_at,
|
||||
issued_at
|
||||
);
|
||||
|
||||
let cert_result = trust_graph.issue_root_certificate_checked(root_trust, trust, 0u64);
|
||||
assert_result!(cert_result);
|
||||
println!("{:?}", cert_result.cert);
|
||||
|
||||
assert_result!(trust_graph.add_root(issuer_kp.get_peer_id().to_base58(), 300));
|
||||
|
||||
let insert_res = trust_graph.insert_cert(cert_result.cert, 0u64);
|
||||
assert_result!(insert_res);
|
||||
let all_certs_res = trust_graph.get_all_certs(issued_peer_id.to_base58());
|
||||
assert_result!(all_certs_res);
|
||||
assert_eq!(all_certs_res.certificates.len(), 1);
|
||||
println!("{:?}", all_certs_res.certificates);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,20 @@ data InsertResult:
|
||||
success: bool
|
||||
error: string
|
||||
|
||||
data IssueCertificateResult:
|
||||
success: bool
|
||||
error: string
|
||||
cert: Certificate
|
||||
|
||||
data IssueTrustResult:
|
||||
success: bool
|
||||
error: string
|
||||
trust: Trust
|
||||
|
||||
data VerifyTrustResult:
|
||||
success: bool
|
||||
error: string
|
||||
|
||||
data WeightResult:
|
||||
success: bool
|
||||
weight: []u32
|
||||
@ -34,7 +48,11 @@ data WeightResult:
|
||||
service TrustGraph("trust-graph"):
|
||||
add_root(peer_id: string, weight: u32) -> AddRootResult
|
||||
get_all_certs(issued_for: string) -> AllCertsResult
|
||||
get_trust_metadata(peer_id: string, expires_at: u64, issued_at: u64) -> GetTrustMetadataResult
|
||||
get_trust_metadata(issued_for_peer_id: string, expires_at: u64, issued_at: u64) -> GetTrustMetadataResult
|
||||
get_weight(peer_id: string) -> WeightResult
|
||||
insert_cert(certificate: Certificate, current_time: u64) -> InsertResult
|
||||
insert_cert_raw(certificate: string, current_time: u64) -> InsertResult
|
||||
issue_certificate_with_trust_checked(cert: Certificate, trust: Trust, issued_by_peer_id: string, cur_time: u64) -> IssueCertificateResult
|
||||
issue_root_certificate_checked(root_trust: Trust, issued_trust: Trust, cur_time: u64) -> IssueCertificateResult
|
||||
issue_trust(issued_for_peer_id: string, expires_at: u64, issued_at: u64, signed_metadata: []u8) -> IssueTrustResult
|
||||
verify_trust(trust: Trust, issuer_peer_id: string, cur_time: u64) -> VerifyTrustResult
|
||||
|
@ -74,6 +74,47 @@ impl Certificate {
|
||||
Self { chain }
|
||||
}
|
||||
|
||||
pub fn new_from_root_trust(root_trust: Trust, issued_trust: Trust, cur_time: Duration) -> Result<Self, CertificateError> {
|
||||
Trust::verify(&root_trust, &root_trust.issued_for, cur_time).map_err(MalformedRoot)?;
|
||||
Trust::verify(&issued_trust, &root_trust.issued_for, cur_time).map_err(|e| VerificationError(1, e))?;
|
||||
|
||||
Ok(Self { chain: vec![root_trust, issued_trust] })
|
||||
}
|
||||
|
||||
pub fn issue_with_trust(issued_by: PublicKey, trust: Trust, extend_cert: &Certificate, cur_time: Duration) -> Result<Self, CertificateError> {
|
||||
if trust.expires_at.lt(&trust.issued_at) {
|
||||
return Err(ExpirationError {
|
||||
expires_at: format!("{:?}", trust.expires_at),
|
||||
issued_at: format!("{:?}", trust.issued_at),
|
||||
});
|
||||
}
|
||||
|
||||
Certificate::verify(extend_cert, &[extend_cert.chain[0].issued_for.clone()], cur_time)?;
|
||||
// check if `issued_by` is allowed to issue a certificate (i.e., there’s a trust for it in a chain)
|
||||
let mut previous_trust_num: i32 = -1;
|
||||
for pk_id in 0..extend_cert.chain.len() {
|
||||
if extend_cert.chain[pk_id].issued_for == issued_by {
|
||||
previous_trust_num = pk_id as i32;
|
||||
}
|
||||
}
|
||||
|
||||
if previous_trust_num == -1 {
|
||||
return Err(KeyInCertificateError);
|
||||
};
|
||||
|
||||
// splitting old chain to add new trust after given public key
|
||||
let mut new_chain = extend_cert
|
||||
.chain
|
||||
.split_at((previous_trust_num + 1) as usize)
|
||||
.0
|
||||
.to_vec();
|
||||
|
||||
new_chain.push(trust);
|
||||
|
||||
Ok(Self { chain: new_chain })
|
||||
}
|
||||
|
||||
|
||||
/// Creates new certificate with root trust (self-signed public key) from a key pair.
|
||||
#[allow(dead_code)]
|
||||
pub fn issue_root(
|
||||
@ -401,7 +442,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(new_cert.is_ok(), true);
|
||||
let new_cert = new_cert.unwrap();
|
||||
|
||||
|
||||
println!("cert is\n{}", new_cert.to_string());
|
||||
|
||||
assert_eq!(new_cert.chain.len(), 3);
|
||||
|
@ -40,7 +40,7 @@ pub use crate::certificate::{Certificate, CertificateError};
|
||||
pub use crate::misc::current_time;
|
||||
pub use crate::public_key_hashable::PublicKeyHashable;
|
||||
pub use crate::revoke::Revoke;
|
||||
pub use crate::trust::Trust;
|
||||
pub use crate::trust::{Trust, TrustError};
|
||||
pub use crate::trust_graph::{TrustGraph, TrustGraphError, Weight};
|
||||
pub use crate::trust_graph_storage::{Storage, StorageError, InMemoryStorage, InMemoryStorageError};
|
||||
pub use crate::trust_node::{Auth, TrustNode};
|
||||
|
Loading…
x
Reference in New Issue
Block a user