From a294c42dec14291aca5869cd1afeeb7deae72569 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Jan 2021 03:57:10 +0300 Subject: [PATCH 1/8] abstract storage --- bin/Cargo.lock | 1593 ++++++++++++++++++++++++++++++++++++ bin/Cargo.toml | 15 + bin/main.rs | 10 + bin/service_api.rs | 0 bin/storage_impl.rs | 3 + src/lib.rs | 1 + src/trust_graph.rs | 105 +-- src/trust_graph_storage.rs | 90 ++ 8 files changed, 1754 insertions(+), 63 deletions(-) create mode 100644 bin/Cargo.lock create mode 100644 bin/Cargo.toml create mode 100644 bin/main.rs create mode 100644 bin/service_api.rs create mode 100644 bin/storage_impl.rs create mode 100644 src/trust_graph_storage.rs diff --git a/bin/Cargo.lock b/bin/Cargo.lock new file mode 100644 index 0000000..e18b23b --- /dev/null +++ b/bin/Cargo.lock @@ -0,0 +1,1593 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55f82cfe485775d02112886f4169bde0c5894d75e79ead7eafe7e40a25e45f7" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + +[[package]] +name = "anyhow" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afddf7f520a80dbf76e6f50a35bca42a2331ef227a28b3b6dc5c2e2338d114b1" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "asn1_der" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fce6b6a0ffdafebd82c87e79e3f40e8d2c523e5fea5566ff6b90509bf98d638" +dependencies = [ + "asn1_der_derive", +] + +[[package]] +name = "asn1_der_derive" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d0864d84b8e07b145449be9a8537db86bf9de5ce03b913214694643b4743502" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding", + "byte-tools", + "byteorder", + "generic-array 0.12.3", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "bs58" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb" + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bumpalo" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "byteorder" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" + +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "cc" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-mac" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5" +dependencies = [ + "generic-array 0.12.3", + "subtle 1.0.0", +] + +[[package]] +name = "curve25519-dalek" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f627126b946c25a4638eec0ea634fc52506dea98db118aae985118ce7c3d723f" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle 2.4.0", + "zeroize", +] + +[[package]] +name = "data-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993a608597367c6377b258c25d7120740f00ed23a2252b729b1932dd7866f908" + +[[package]] +name = "derivative" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaed5874effa6cde088c644ddcdcb4ffd1511391c5be4fdd7a5ccd02c7e4a183" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.3", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.4", +] + +[[package]] +name = "ed25519" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37c66a534cbb46ab4ea03477eae19d5c22c01da8258030280b7bd9d8433fb6ef" +dependencies = [ + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek", + "ed25519", + "rand 0.7.3", + "serde", + "sha2 0.9.2", + "zeroize", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" + +[[package]] +name = "fluence" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27d9a5e4292d7bbd809a0e968e3c3aacac91cbc5acab3e26ee1e1d726f0aab24" +dependencies = [ + "fluence-sdk-macro", + "fluence-sdk-main", +] + +[[package]] +name = "fluence-fork-libp2p-core" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e144c2f2e2d915fcdf1d4a413093e793950da7479603297f97450ac1aedadf" +dependencies = [ + "asn1_der", + "bs58 0.4.0", + "ed25519-dalek", + "either", + "fluence-fork-multistream-select", + "fluence-fork-parity-multiaddr", + "fnv", + "futures", + "futures-timer", + "lazy_static", + "libsecp256k1", + "log", + "multihash", + "parking_lot", + "pin-project 1.0.4", + "prost", + "prost-build", + "rand 0.7.3", + "ring", + "rw-stream-sink", + "serde", + "sha2 0.9.2", + "smallvec", + "thiserror", + "unsigned-varint", + "void", + "zeroize", +] + +[[package]] +name = "fluence-fork-multistream-select" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fe6c01231db8700221a08cdd429575099d8727c2ca0500427b57b1aa9e03bbb" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project 1.0.4", + "smallvec", + "unsigned-varint", +] + +[[package]] +name = "fluence-fork-parity-multiaddr" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee001eadfcb415fbc4a39b73c999d5c39afcf040100807653ea420ca13fbc23a" +dependencies = [ + "arrayref", + "bs58 0.4.0", + "byteorder", + "data-encoding", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "fluence-sdk-macro" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1a7c75a617f827d1ba9a17b4d84e1565ab239915c63f5a85c41f89a9f1d4ba" +dependencies = [ + "fluence-sdk-wit", +] + +[[package]] +name = "fluence-sdk-main" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6edcc983f9517c1b6bf9f851ef27f2894a3159aaa4a2fb6c9deb2ae8ecb603fa" +dependencies = [ + "fluence-sdk-macro", + "log", + "serde", +] + +[[package]] +name = "fluence-sdk-wit" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b75dbdd0275160f3818db3218563d791e6c612b616cd3c5d6e66283f207f648d" +dependencies = [ + "proc-macro2", + "quote", + "serde", + "serde_json", + "syn", + "uuid", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da9052a1a50244d8d5aa9bf55cbc2fb6f357c86cc52e46c62ed390a7180cf150" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2d31b7ec7efab6eefc7c57233bb10b847986139d88cc2f5a02a1ae6871a1846" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e5145dde8da7d1b3892dad07a9c98fc04bc39892b1ecc9692cf53e2b780a65" + +[[package]] +name = "futures-executor" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e59fdc009a4b3096bf94f740a0f2424c082521f20a9b08c5c07c48d90fd9b9" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28be053525281ad8259d47e4de5de657b25e7bac113458555bb4b70bc6870500" + +[[package]] +name = "futures-macro" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c287d25add322d9f9abdcdc5927ca398917996600182178774032e9f8258fedd" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf5c69029bda2e743fddd0582d1083951d65cc9539aebf8812f36c3491342d6" + +[[package]] +name = "futures-task" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13de07eb8ea81ae445aca7b69f5f7bf15d7bf4912d8ca37d6645c77ae8a58d86" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "632a8cd0f2a4b3fdea1657f08bde063848c3bd00f9bbf6e256b8be78802e624b" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4060f4657be78b8e766215b02b18a2e862d83745545de804638e2b545e81aee6" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.10.1+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", +] + +[[package]] +name = "hmac" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695" +dependencies = [ + "crypto-mac", + "digest 0.8.1", +] + +[[package]] +name = "hmac-drbg" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e570451493f10f6581b48cdd530413b63ea9e780f544bfd3bdcaa0d89d1a7b" +dependencies = [ + "digest 0.8.1", + "generic-array 0.12.3", + "hmac", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb1fa934250de4de8aef298d81c729a7d33d8c239daa3a7575e6b92bfc7313b" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "itertools" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[package]] +name = "js-sys" +version = "0.3.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d7383929f7c9c7c2d0fa596f325832df98c3704f2c60553080f7127a58175" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" + +[[package]] +name = "libsecp256k1" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc1e2c808481a63dc6da2074752fdd4336a3c8fcc68b83db6f1fd5224ae7962" +dependencies = [ + "arrayref", + "crunchy", + "digest 0.8.1", + "hmac-drbg", + "rand 0.7.3", + "sha2 0.8.2", + "subtle 2.4.0", + "typenum", +] + +[[package]] +name = "lock_api" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd96ffd135b2fd7b973ac026d28085defbe8983df057ced3eb4f2130b0831312" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "multihash" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dac63698b887d2d929306ea48b63760431ff8a24fac40ddb22f9c7f49fb7cab" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.4", + "multihash-derive", + "sha2 0.9.2", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ee3c48cb9d9b275ad967a0e96715badc13c6029adb92f34fa17b9ff28fd81f" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "multimap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1255076139a83bb467426e7f8d0134968a8118844faa755985e077cf31850333" + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" + +[[package]] +name = "once_cell" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "parking_lot" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccb628cad4f84851442432c60ad8e1f607e29752d0bf072cbd0baf28aa34272" +dependencies = [ + "cfg-if 1.0.0", + "instant", + "libc", + "redox_syscall 0.1.57", + "smallvec", + "winapi", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffbc8e94b38ea3d2d8ba92aea2983b503cd75d0888d75b86bb37970b5698e15" +dependencies = [ + "pin-project-internal 0.4.27", +] + +[[package]] +name = "pin-project" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b70b68509f17aa2857863b6fa00bf21fc93674c7a8893de2f469f6aa7ca2f2" +dependencies = [ + "pin-project-internal 1.0.4", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caa25a6393f22ce819b0f50e0be89287292fda8d425be38ee0ca14c4931d9e71" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "prost" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" +dependencies = [ + "bytes", + "heck", + "itertools", + "log", + "multimap", + "petgraph", + "prost", + "prost-types", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" +dependencies = [ + "bytes", + "prost", +] + +[[package]] +name = "quote" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc 0.2.0", +] + +[[package]] +name = "rand" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18519b42a40024d661e1714153e9ad0c3de27cd495760ceb09710920f1098b1e" +dependencies = [ + "libc", + "rand_chacha 0.3.0", + "rand_core 0.6.1", + "rand_hc 0.3.0", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.1", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c026d7df8b298d90ccbbc5190bd04d85e159eaf5576caeacf8741da93ccbd2e5" +dependencies = [ + "getrandom 0.2.1", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_hc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73" +dependencies = [ + "rand_core 0.6.1", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_syscall" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ref-cast" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300f2a835d808734ee295d45007adacb9ebb29dd3ae2424acfa17930cae541da" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c38e3aecd2b21cb3959637b883bb3714bc7e43f0268b9a29d3743ee3e55cdd2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "ring" +version = "0.16.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "024a1e66fea74c66c66624ee5622a7ff0e4b73a13b4f5c326ddb50c708944226" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + +[[package]] +name = "rw-stream-sink" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4da5fcb054c46f5a5dff833b129285a93d3f0179531735e6c866e8cc307d2020" +dependencies = [ + "futures", + "pin-project 0.4.27", + "static_assertions", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fceb2595057b6891a4ee808f70054bd2d12f0e97f1cbb78689b59f676df325a" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e7aab86fe2149bad8c507606bdb3f4ef5e7b2380eb92350f56122cca72a42a8" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if 1.0.0", + "cpuid-bool", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "signature" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0242b8e50dd9accdd56170e94ca1ebd223b098eb9c83539a6e367d0f36ae68" + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "subtle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" + +[[package]] +name = "subtle" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" + +[[package]] +name = "syn" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc60a3d73ea6594cd712d830cc1f0390fd71542d8c8cd24e70cc54cdfd5e05d5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "rand 0.8.2", + "redox_syscall 0.2.4", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "thiserror" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cc616c6abf8c8928e2fdcc0dbfab37175edd8fb49a4641066ad1364fdab146" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9be73a2caec27583d0046ef3796c3794f868a5bc813db689eed00c7631275cd1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "trust-graph" +version = "0.2.0" +dependencies = [ + "bs58 0.3.1", + "derivative", + "ed25519-dalek", + "failure", + "fluence-fork-libp2p-core", + "log", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "trust-graph-wasm" +version = "0.2.0" +dependencies = [ + "fluence", + "trust-graph", +] + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "unsigned-varint" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fdeedbf205afadfe39ae559b75c3240f24e257d0ca27e85f85cb82aa19ac35" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.1", +] + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.10.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9" + +[[package]] +name = "wasm-bindgen" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd364751395ca0f68cafb17666eee36b63077fb5ecd972bbcd74c90c4bf736e" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1114f89ab1f4106e5b55e688b828c0ab0ea593a1ea7c094b141b14cbaaec2d62" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6ac8995ead1f084a8dea1e65f194d0973800c7f571f6edd70adf06ecf77084" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e7811dd7f9398f14cc76efd356f98f03aa30419dea46aa810d71e819fc97158" + +[[package]] +name = "web-sys" +version = "0.3.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222b1ef9334f92a21d3fb53dc3fd80f30836959a90f9274a626d7e06315ba3c3" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +dependencies = [ + "libc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "zeroize" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] diff --git a/bin/Cargo.toml b/bin/Cargo.toml new file mode 100644 index 0000000..7aeba59 --- /dev/null +++ b/bin/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "trust-graph-wasm" +version = "0.2.0" +authors = ["Fluence Labs"] +edition = "2018" +description = "trust graph wasm" +license = "Apache-2.0" + +[[bin]] +name = "trust-graph" +path = "src/main.rs" + +[dependencies] +trust-graph = { path = "../" } +fluence = { version = "0.2.18", features = ["logger"] } \ No newline at end of file diff --git a/bin/main.rs b/bin/main.rs new file mode 100644 index 0000000..deba21a --- /dev/null +++ b/bin/main.rs @@ -0,0 +1,10 @@ +use fluence::WasmLoggerBuilder; + +pub(crate) type Result = std::result::Result; + +pub fn main() { + WasmLoggerBuilder::new() + .with_log_level(log::Level::Info) + .build() + .unwrap(); +} \ No newline at end of file diff --git a/bin/service_api.rs b/bin/service_api.rs new file mode 100644 index 0000000..e69de29 diff --git a/bin/storage_impl.rs b/bin/storage_impl.rs new file mode 100644 index 0000000..8f6d696 --- /dev/null +++ b/bin/storage_impl.rs @@ -0,0 +1,3 @@ +// store list of trusts +// check if trust is already in list before adding +// if there is an older trust - don't add received trust \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 8118e30..06eab78 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -35,6 +35,7 @@ mod revoke; mod trust; mod trust_graph; mod trust_node; +mod trust_graph_storage; pub(crate) use libp2p_core::identity::ed25519; diff --git a/src/trust_graph.rs b/src/trust_graph.rs index a023298..0025939 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -20,15 +20,14 @@ use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; use crate::trust_node::{Auth, TrustNode}; +use crate::trust_graph_storage::{Storage, InMemoryStorage}; use std::borrow::Borrow; -use std::collections::hash_map::Entry; -use std::collections::hash_map::Entry::Occupied; -use std::collections::{HashMap, HashSet, VecDeque}; +use std::collections::{HashSet, VecDeque}; use std::fmt::Debug; use std::time::Duration; /// for simplicity, we store `n` where Weight = 1/n^2 -type Weight = u32; +pub type Weight = u32; /// Graph to efficiently calculate weights of certificates and get chains of certificates. /// TODO serialization/deserialization @@ -36,33 +35,28 @@ type Weight = u32; #[allow(dead_code)] #[derive(Debug, Default)] pub struct TrustGraph { - // TODO abstract this into a trait with key access methods - // TODO: add docs on fields - nodes: HashMap, - root_weights: HashMap, + storage: InMemoryStorage } #[allow(dead_code)] impl TrustGraph { pub fn new(root_weights: Vec<(PublicKey, Weight)>) -> Self { + let root_weights = root_weights.into_iter() + .map(|(k, w)| (k.into(), w)) + .collect(); Self { - nodes: HashMap::new(), - root_weights: root_weights - .into_iter() - .map(|(k, w)| (k.into(), w)) - .collect(), + storage: InMemoryStorage::new_in_memory(root_weights) } } - /// Insert new root weights - pub fn add_root_weights>(&mut self, weights: Vec<(P, Weight)>) { - self.root_weights - .extend(weights.into_iter().map(|(k, w)| (k.into(), w))) + /// Insert new root weight + pub fn add_root_weight(&mut self, pk: PublicKeyHashable, weight: Weight) { + self.storage.add_root_weight(pk, weight) } /// Get trust by public key pub fn get(&self, pk: PublicKey) -> Option<&TrustNode> { - self.nodes.get(&pk.into()) + self.storage.get(&pk.into()) } // TODO: remove cur_time from api, leave it for tests only @@ -71,7 +65,7 @@ impl TrustGraph { where C: Borrow, { - let roots: Vec = self.root_weights.keys().cloned().map(Into::into).collect(); + let roots: Vec = self.storage.root_keys().iter().cloned().map(Into::into).collect(); // Check that certificate is valid and converges to one of the known roots Certificate::verify(cert.borrow(), roots.as_slice(), cur_time)?; @@ -80,14 +74,14 @@ impl TrustGraph { let root_pk: PublicKeyHashable = root_trust.issued_for.clone().into(); // Insert new TrustNode for this root_pk if there wasn't one - if self.nodes.get_mut(&root_pk).is_none() { + if self.storage.get(&root_pk).is_none() { let mut trust_node = TrustNode::new(root_trust.issued_for.clone(), cur_time); let root_auth = Auth { trust: root_trust.clone(), issued_by: root_trust.issued_for.clone(), }; trust_node.update_auth(root_auth); - self.nodes.insert(root_pk, trust_node); + self.storage.insert(root_pk, trust_node); } // Insert remaining trusts to the graph @@ -100,16 +94,7 @@ impl TrustGraph { issued_by: previous_trust.issued_for.clone(), }; - match self.nodes.get_mut(&pk) { - Some(trust_node) => { - trust_node.update_auth(auth); - } - None => { - let mut trust_node = TrustNode::new(root_trust.issued_for.clone(), cur_time); - trust_node.update_auth(auth); - self.nodes.insert(pk, trust_node); - } - } + self.storage.update_auth(&pk, auth, &root_trust.issued_for, cur_time); previous_trust = trust; } @@ -122,13 +107,14 @@ impl TrustGraph { where P: Borrow, { - if let Some(weight) = self.root_weights.get(pk.borrow().as_ref()) { + if let Some(weight) = self.storage.get_root_weight(pk.borrow().as_ref()) { return Some(*weight); } let roots: Vec = self - .root_weights - .keys() + .storage + .root_keys() + .iter() .map(|pk| pk.clone().into()) .collect(); @@ -157,8 +143,8 @@ impl TrustGraph { let cert = cert.borrow(); let root_weight = *self - .root_weights - .get(cert.chain.first()?.issued_for.as_ref()) + .storage + .get_root_weight(cert.chain.first()?.issued_for.as_ref()) // This panic shouldn't happen // TODO: why? .expect("first trust in chain must be in root_weights"); @@ -200,7 +186,7 @@ impl TrustGraph { .expect("`cur_chain` always has at least one element"); let auths: Vec = self - .nodes + .storage .get(&last.issued_by.clone().into()) .expect( "there cannot be paths without any nodes after adding verified certificates", @@ -244,14 +230,15 @@ impl TrustGraph { P: Borrow, { // get all auths (edges) for issued public key - let issued_for_node = self.nodes.get(issued_for.borrow().as_ref()); + let issued_for_node = self.storage.get(issued_for.borrow().as_ref()); let roots = roots.iter().map(|pk| pk.as_ref()); - let roots = self.root_weights.keys().chain(roots).collect(); + let keys = self.storage.root_keys(); + let roots = keys.iter().chain(roots).collect(); match issued_for_node { Some(node) => self - .bf_search_paths(node, roots) + .bf_search_paths(&node, roots) .iter() .map(|auths| { // TODO: can avoid cloning here by returning &Certificate @@ -279,13 +266,7 @@ impl TrustGraph { let pk: PublicKeyHashable = revoke.pk.clone().into(); - match self.nodes.entry(pk) { - Occupied(mut entry) => { - entry.get_mut().update_revoke(revoke); - Ok(()) - } - Entry::Vacant(_) => Err("There is no trust with such PublicKey".to_string()), - } + self.storage.revoke(&pk, revoke) } /// Check information about new certificates and about revoked certificates. @@ -300,6 +281,7 @@ mod tests { use crate::key_pair::KeyPair; use crate::misc::current_time; use failure::_core::time::Duration; + use std::collections::HashMap; pub fn one_minute() -> Duration { Duration::new(60, 0) @@ -385,7 +367,7 @@ mod tests { let (root, _, cert) = generate_root_cert(); let mut graph = TrustGraph::default(); - graph.root_weights.insert(root.key_pair.public().into(), 0); + graph.add_root_weight(root.key_pair.public().into(), 0); let addition = graph.add(cert, current_time()); assert_eq!(addition.is_ok(), true); @@ -417,8 +399,8 @@ mod tests { let mut graph = TrustGraph::default(); let root1_pk = key_pairs1[0].public_key(); let root2_pk = key_pairs2[0].public_key(); - graph.root_weights.insert(root1_pk.into(), 1); - graph.root_weights.insert(root2_pk.into(), 0); + graph.add_root_weight(root1_pk.into(), 1); + graph.add_root_weight(root2_pk.into(), 0); graph.add(cert1, cur_time).unwrap(); let node2 = graph.get(key_pair2.public_key()).unwrap(); @@ -448,7 +430,7 @@ mod tests { let mut graph = TrustGraph::default(); let root_pk = key_pairs[0].public_key(); - graph.root_weights.insert(root_pk.into(), 1); + graph.add_root_weight(root_pk.into(), 1); graph.add(cert1, current_time()).unwrap(); @@ -491,8 +473,8 @@ mod tests { let mut graph = TrustGraph::default(); let root1_pk = key_pairs1[0].public_key(); let root2_pk = key_pairs2[0].public_key(); - graph.root_weights.insert(root1_pk.into(), 1); - graph.root_weights.insert(root2_pk.into(), 0); + graph.add_root_weight(root1_pk.into(), 1); + graph.add_root_weight(root2_pk.into(), 0); let last_pk1 = cert1.chain[9].issued_for.clone(); let last_pk2 = cert2.chain[9].issued_for.clone(); @@ -525,7 +507,7 @@ mod tests { let mut graph = TrustGraph::default(); let root1_pk = key_pairs[0].public_key(); - graph.root_weights.insert(root1_pk.clone().into(), 1); + graph.add_root_weight(root1_pk.clone().into(), 1); graph.add(cert.clone(), current_time()).unwrap(); @@ -542,14 +524,11 @@ mod tests { let mut graph = TrustGraph::default(); // add first and last trusts as roots graph - .root_weights - .insert(cert.chain[0].clone().issued_for.into(), 1); + .add_root_weight(cert.chain[0].clone().issued_for.into(), 1); graph - .root_weights - .insert(cert.chain[3].clone().issued_for.into(), 1); + .add_root_weight(cert.chain[3].clone().issued_for.into(), 1); graph - .root_weights - .insert(cert.chain[5].clone().issued_for.into(), 1); + .add_root_weight(cert.chain[5].clone().issued_for.into(), 1); graph.add(cert.clone(), current_time()).unwrap(); @@ -590,9 +569,9 @@ mod tests { let root1_pk = key_pairs1[0].public_key(); let root2_pk = key_pairs2[0].public_key(); let root3_pk = key_pairs3[0].public_key(); - graph.root_weights.insert(root1_pk.clone().into(), 1); - graph.root_weights.insert(root2_pk.clone().into(), 0); - graph.root_weights.insert(root3_pk.clone().into(), 0); + graph.add_root_weight(root1_pk.clone().into(), 1); + graph.add_root_weight(root2_pk.clone().into(), 0); + graph.add_root_weight(root3_pk.clone().into(), 0); graph.add(cert1, current_time()).unwrap(); graph.add(cert2, current_time()).unwrap(); diff --git a/src/trust_graph_storage.rs b/src/trust_graph_storage.rs new file mode 100644 index 0000000..36d7ba5 --- /dev/null +++ b/src/trust_graph_storage.rs @@ -0,0 +1,90 @@ +use crate::trust_node::{Auth, TrustNode}; +use crate::public_key_hashable::PublicKeyHashable; +use crate::trust_graph::Weight; +use std::collections::{HashMap}; +use crate::revoke::Revoke; +use std::time::Duration; +use libp2p_core::identity::ed25519::PublicKey; + + +pub trait Storage { + fn new() -> Self; + + fn get(&self, pk: &PublicKeyHashable) -> Option<&TrustNode>; + fn insert(&mut self, pk: PublicKeyHashable, node: TrustNode); + + fn get_root_weight(&self, pk: &PublicKeyHashable) -> Option<&Weight>; + fn add_root_weight(&mut self, pk: PublicKeyHashable, weight: Weight); + fn root_keys(&self) -> Vec; + fn revoke(&mut self, pk: &PublicKeyHashable, revoke: Revoke) -> Result<(), String>; + fn update_auth(&mut self, pk: &PublicKeyHashable, auth: Auth, issued_for: &PublicKey, cur_time: Duration); +} + +#[derive(Debug, Default)] +pub struct InMemoryStorage { + nodes: HashMap, + root_weights: HashMap, +} + +impl InMemoryStorage { + pub fn new_in_memory(root_weights: HashMap) -> Self { + Self { + nodes: HashMap::new(), + root_weights: root_weights, + } + } +} + +impl Storage for InMemoryStorage { + fn new() -> Self { + InMemoryStorage { + nodes: HashMap::new(), + root_weights: HashMap::new() + } + } + + + + fn get(&self, pk: &PublicKeyHashable) -> Option<&TrustNode> { + self.nodes.get(pk) + } + + fn insert(&mut self, pk: PublicKeyHashable, node: TrustNode) { + &self.nodes.insert(pk, node); + } + + fn get_root_weight(&self, pk: &PublicKeyHashable) -> Option<&Weight> { + self.root_weights.get(pk) + } + + fn add_root_weight(&mut self, pk: PublicKeyHashable, weight: Weight) { + &self.root_weights.insert(pk, weight); + } + + fn root_keys(&self) -> Vec { + self.root_weights.keys().cloned().map(Into::into).collect() + } + + fn revoke(&mut self, pk: &PublicKeyHashable, revoke: Revoke) -> Result<(), String> { + match self.nodes.get_mut(&pk) { + Some(trust_node) => { + trust_node.update_revoke(revoke); + Ok(()) + } + None => Err("There is no trust with such PublicKey".to_string()), + } + } + + fn update_auth(&mut self, pk: &PublicKeyHashable, auth: Auth, issued_for: &PublicKey, cur_time: Duration) { + match self.nodes.get_mut(&pk) { + Some(trust_node) => { + trust_node.update_auth(auth); + } + None => { + let mut trust_node = TrustNode::new(issued_for.clone(), cur_time); + trust_node.update_auth(auth); + self.nodes.insert(pk.clone(), trust_node); + } + } + } +} From 2ec1114ec2891e4a97b2210a395fec01e819316e Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Jan 2021 04:29:16 +0300 Subject: [PATCH 2/8] make an abstract Storage for trust_graph --- src/trust_graph.rs | 38 +++++++++++++++++++++----------------- src/trust_graph_storage.rs | 18 +++++++++--------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/src/trust_graph.rs b/src/trust_graph.rs index 0025939..a468ac6 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -20,10 +20,9 @@ use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; use crate::trust_node::{Auth, TrustNode}; -use crate::trust_graph_storage::{Storage, InMemoryStorage}; +use crate::trust_graph_storage::Storage; use std::borrow::Borrow; use std::collections::{HashSet, VecDeque}; -use std::fmt::Debug; use std::time::Duration; /// for simplicity, we store `n` where Weight = 1/n^2 @@ -33,19 +32,15 @@ pub type Weight = u32; /// TODO serialization/deserialization /// TODO export a certificate from graph #[allow(dead_code)] -#[derive(Debug, Default)] pub struct TrustGraph { - storage: InMemoryStorage + storage: Box } #[allow(dead_code)] impl TrustGraph { - pub fn new(root_weights: Vec<(PublicKey, Weight)>) -> Self { - let root_weights = root_weights.into_iter() - .map(|(k, w)| (k.into(), w)) - .collect(); + pub fn new(storage: Box) -> Self { Self { - storage: InMemoryStorage::new_in_memory(root_weights) + storage: storage } } @@ -282,6 +277,7 @@ mod tests { use crate::misc::current_time; use failure::_core::time::Duration; use std::collections::HashMap; + use crate::trust_graph_storage::InMemoryStorage; pub fn one_minute() -> Duration { Duration::new(60, 0) @@ -357,7 +353,8 @@ mod tests { let cur_time = current_time(); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); let addition = graph.add(cert, cur_time); assert_eq!(addition.is_ok(), false); } @@ -366,7 +363,8 @@ mod tests { fn test_add_cert() { let (root, _, cert) = generate_root_cert(); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); graph.add_root_weight(root.key_pair.public().into(), 0); let addition = graph.add(cert, current_time()); @@ -396,7 +394,8 @@ mod tests { let (key_pairs2, cert2) = generate_cert_with(10, chain_keys, far_far_future * 2, far_far_future); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); let root1_pk = key_pairs1[0].public_key(); let root2_pk = key_pairs2[0].public_key(); graph.add_root_weight(root1_pk.into(), 1); @@ -427,7 +426,8 @@ mod tests { let (key_pairs, cert1) = generate_cert_with_len(10, HashMap::new()); let last_trust = cert1.chain[9].clone(); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); let root_pk = key_pairs[0].public_key(); graph.add_root_weight(root_pk.into(), 1); @@ -470,7 +470,8 @@ mod tests { let (key_pairs2, cert2) = generate_cert_with_len(10, chain_keys); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); let root1_pk = key_pairs1[0].public_key(); let root2_pk = key_pairs2[0].public_key(); graph.add_root_weight(root1_pk.into(), 1); @@ -505,7 +506,8 @@ mod tests { fn test_get_one_cert() { let (key_pairs, cert) = generate_cert_with_len(5, HashMap::new()); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); let root1_pk = key_pairs[0].public_key(); graph.add_root_weight(root1_pk.clone().into(), 1); @@ -521,7 +523,8 @@ mod tests { fn test_chain_from_root_to_another_root() { let (_, cert) = generate_cert_with_len(6, HashMap::new()); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); // add first and last trusts as roots graph .add_root_weight(cert.chain[0].clone().issued_for.into(), 1); @@ -565,7 +568,8 @@ mod tests { let (key_pairs3, cert3) = generate_cert_with_len(5, chain_keys); - let mut graph = TrustGraph::default(); + let st = Box::new(InMemoryStorage::new()); + let mut graph = TrustGraph::new(st); let root1_pk = key_pairs1[0].public_key(); let root2_pk = key_pairs2[0].public_key(); let root3_pk = key_pairs3[0].public_key(); diff --git a/src/trust_graph_storage.rs b/src/trust_graph_storage.rs index 36d7ba5..e51d789 100644 --- a/src/trust_graph_storage.rs +++ b/src/trust_graph_storage.rs @@ -6,10 +6,7 @@ use crate::revoke::Revoke; use std::time::Duration; use libp2p_core::identity::ed25519::PublicKey; - pub trait Storage { - fn new() -> Self; - fn get(&self, pk: &PublicKeyHashable) -> Option<&TrustNode>; fn insert(&mut self, pk: PublicKeyHashable, node: TrustNode); @@ -27,24 +24,27 @@ pub struct InMemoryStorage { } impl InMemoryStorage { - pub fn new_in_memory(root_weights: HashMap) -> Self { + #[allow(dead_code)] + pub fn new_in_memory(root_weights: Vec<(PublicKey, Weight)>) -> Self { + let root_weights = root_weights.into_iter() + .map(|(k, w)| (k.into(), w)) + .collect(); Self { nodes: HashMap::new(), root_weights: root_weights, } } -} -impl Storage for InMemoryStorage { - fn new() -> Self { + #[allow(dead_code)] + pub fn new() -> Self { InMemoryStorage { nodes: HashMap::new(), root_weights: HashMap::new() } } +} - - +impl Storage for InMemoryStorage { fn get(&self, pk: &PublicKeyHashable) -> Option<&TrustNode> { self.nodes.get(pk) } From 9e74777fe56560978c7366016cf3863365ac232b Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Jan 2021 18:26:17 +0300 Subject: [PATCH 3/8] fmt --- src/lib.rs | 2 +- src/trust_graph.rs | 30 ++++++++++++++++-------------- src/trust_graph_storage.rs | 29 +++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 06eab78..e338c14 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,8 +34,8 @@ mod public_key_hashable; mod revoke; mod trust; mod trust_graph; -mod trust_node; mod trust_graph_storage; +mod trust_node; pub(crate) use libp2p_core::identity::ed25519; diff --git a/src/trust_graph.rs b/src/trust_graph.rs index a468ac6..44ef933 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -19,8 +19,8 @@ use crate::ed25519::PublicKey; use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; -use crate::trust_node::{Auth, TrustNode}; use crate::trust_graph_storage::Storage; +use crate::trust_node::{Auth, TrustNode}; use std::borrow::Borrow; use std::collections::{HashSet, VecDeque}; use std::time::Duration; @@ -33,15 +33,13 @@ pub type Weight = u32; /// TODO export a certificate from graph #[allow(dead_code)] pub struct TrustGraph { - storage: Box + storage: Box, } #[allow(dead_code)] impl TrustGraph { pub fn new(storage: Box) -> Self { - Self { - storage: storage - } + Self { storage: storage } } /// Insert new root weight @@ -60,7 +58,13 @@ impl TrustGraph { where C: Borrow, { - let roots: Vec = self.storage.root_keys().iter().cloned().map(Into::into).collect(); + let roots: Vec = self + .storage + .root_keys() + .iter() + .cloned() + .map(Into::into) + .collect(); // Check that certificate is valid and converges to one of the known roots Certificate::verify(cert.borrow(), roots.as_slice(), cur_time)?; @@ -89,7 +93,8 @@ impl TrustGraph { issued_by: previous_trust.issued_for.clone(), }; - self.storage.update_auth(&pk, auth, &root_trust.issued_for, cur_time); + self.storage + .update_auth(&pk, auth, &root_trust.issued_for, cur_time); previous_trust = trust; } @@ -275,9 +280,9 @@ mod tests { use super::*; use crate::key_pair::KeyPair; use crate::misc::current_time; + use crate::trust_graph_storage::InMemoryStorage; use failure::_core::time::Duration; use std::collections::HashMap; - use crate::trust_graph_storage::InMemoryStorage; pub fn one_minute() -> Duration { Duration::new(60, 0) @@ -526,12 +531,9 @@ mod tests { let st = Box::new(InMemoryStorage::new()); let mut graph = TrustGraph::new(st); // add first and last trusts as roots - graph - .add_root_weight(cert.chain[0].clone().issued_for.into(), 1); - graph - .add_root_weight(cert.chain[3].clone().issued_for.into(), 1); - graph - .add_root_weight(cert.chain[5].clone().issued_for.into(), 1); + graph.add_root_weight(cert.chain[0].clone().issued_for.into(), 1); + graph.add_root_weight(cert.chain[3].clone().issued_for.into(), 1); + graph.add_root_weight(cert.chain[5].clone().issued_for.into(), 1); graph.add(cert.clone(), current_time()).unwrap(); diff --git a/src/trust_graph_storage.rs b/src/trust_graph_storage.rs index e51d789..aa2eae6 100644 --- a/src/trust_graph_storage.rs +++ b/src/trust_graph_storage.rs @@ -1,10 +1,10 @@ -use crate::trust_node::{Auth, TrustNode}; use crate::public_key_hashable::PublicKeyHashable; -use crate::trust_graph::Weight; -use std::collections::{HashMap}; use crate::revoke::Revoke; -use std::time::Duration; +use crate::trust_graph::Weight; +use crate::trust_node::{Auth, TrustNode}; use libp2p_core::identity::ed25519::PublicKey; +use std::collections::HashMap; +use std::time::Duration; pub trait Storage { fn get(&self, pk: &PublicKeyHashable) -> Option<&TrustNode>; @@ -14,7 +14,13 @@ pub trait Storage { fn add_root_weight(&mut self, pk: PublicKeyHashable, weight: Weight); fn root_keys(&self) -> Vec; fn revoke(&mut self, pk: &PublicKeyHashable, revoke: Revoke) -> Result<(), String>; - fn update_auth(&mut self, pk: &PublicKeyHashable, auth: Auth, issued_for: &PublicKey, cur_time: Duration); + fn update_auth( + &mut self, + pk: &PublicKeyHashable, + auth: Auth, + issued_for: &PublicKey, + cur_time: Duration, + ); } #[derive(Debug, Default)] @@ -26,7 +32,8 @@ pub struct InMemoryStorage { impl InMemoryStorage { #[allow(dead_code)] pub fn new_in_memory(root_weights: Vec<(PublicKey, Weight)>) -> Self { - let root_weights = root_weights.into_iter() + let root_weights = root_weights + .into_iter() .map(|(k, w)| (k.into(), w)) .collect(); Self { @@ -39,7 +46,7 @@ impl InMemoryStorage { pub fn new() -> Self { InMemoryStorage { nodes: HashMap::new(), - root_weights: HashMap::new() + root_weights: HashMap::new(), } } } @@ -75,7 +82,13 @@ impl Storage for InMemoryStorage { } } - fn update_auth(&mut self, pk: &PublicKeyHashable, auth: Auth, issued_for: &PublicKey, cur_time: Duration) { + fn update_auth( + &mut self, + pk: &PublicKeyHashable, + auth: Auth, + issued_for: &PublicKey, + cur_time: Duration, + ) { match self.nodes.get_mut(&pk) { Some(trust_node) => { trust_node.update_auth(auth); From a0261bc3314c1e55e78c3512083a465c8337b083 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Jan 2021 20:08:05 +0300 Subject: [PATCH 4/8] WIP --- Cargo.lock | 1 + Cargo.toml | 5 ++-- bin/Cargo.lock | 2 ++ src/certificate.rs | 2 +- src/key_pair.rs | 52 ++++++++++++++++++++++++-------------- src/public_key_hashable.rs | 52 +++++++++++++++++++++++++++++++++----- src/revoke.rs | 14 ++++------ src/trust.rs | 30 ++++++++++++---------- src/trust_graph.rs | 2 +- src/trust_graph_storage.rs | 2 +- src/trust_node.rs | 2 +- 11 files changed, 110 insertions(+), 54 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 741639c..cf446df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1330,6 +1330,7 @@ dependencies = [ "ref-cast", "serde", "serde_json", + "signature", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index be1dab9..cab4ac2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,5 @@ log = "0.4.11" ref-cast = "1.0.2" derivative = "2.1.1" ed25519-dalek = "1.0.1" - -[dev-dependencies] -rand = "0.7.3" +rand = "0.7.0" +signature = "1.3.0" diff --git a/bin/Cargo.lock b/bin/Cargo.lock index e18b23b..be06a28 100644 --- a/bin/Cargo.lock +++ b/bin/Cargo.lock @@ -1370,9 +1370,11 @@ dependencies = [ "failure", "fluence-fork-libp2p-core", "log", + "rand 0.7.3", "ref-cast", "serde", "serde_json", + "signature", ] [[package]] diff --git a/src/certificate.rs b/src/certificate.rs index 8f1b1a7..e242ac7 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use crate::ed25519::PublicKey; +use ed25519_dalek::PublicKey; use crate::key_pair::KeyPair; use crate::trust::{Trust, TRUST_LEN}; use std::str::FromStr; diff --git a/src/key_pair.rs b/src/key_pair.rs index 0b2f686..41f463c 100644 --- a/src/key_pair.rs +++ b/src/key_pair.rs @@ -14,37 +14,43 @@ * limitations under the License. */ -use crate::ed25519::{Keypair as Libp2pKeyPair, PublicKey, SecretKey}; -use ed25519_dalek::SignatureError; -use libp2p_core::identity::error::DecodingError; -use std::fmt; +extern crate rand; -pub type Signature = Vec; +use crate::ed25519::{Keypair as Libp2pKeyPair}; +use ed25519_dalek::SignatureError; +use ed25519_dalek::{PublicKey, Signer}; +use signature::{Signature as SigSignature}; +use core::fmt::{Debug}; +use std::fmt; +use rand::rngs::OsRng; + +pub type Signature = ed25519_dalek::Signature; /// An Ed25519 keypair. -#[derive(Clone, Debug)] +#[derive(Debug)] pub struct KeyPair { - pub key_pair: Libp2pKeyPair, + pub key_pair: ed25519_dalek::Keypair, } impl KeyPair { /// Generate a new Ed25519 keypair. #[allow(dead_code)] pub fn generate() -> Self { - let kp = Libp2pKeyPair::generate(); + let mut csprng = OsRng { }; + let kp = ed25519_dalek::Keypair::generate(&mut csprng); kp.into() } - pub fn from_bytes(sk_bytes: impl AsMut<[u8]>) -> Result { - let sk = SecretKey::from_bytes(sk_bytes)?; - Ok(Libp2pKeyPair::from(sk).into()) + pub fn from_bytes(sk_bytes: &[u8]) -> Result { + let kp = ed25519_dalek::Keypair::from_bytes(sk_bytes)?; + Ok(KeyPair {key_pair: kp}) } /// Encode the keypair into a byte array by concatenating the bytes /// of the secret scalar and the compressed public point/ #[allow(dead_code)] pub fn encode(&self) -> [u8; 64] { - self.key_pair.encode() + self.key_pair.to_bytes() } /// Decode a keypair from the format produced by `encode`. @@ -52,26 +58,27 @@ impl KeyPair { pub fn decode(kp: &[u8]) -> Result { let kp = ed25519_dalek::Keypair::from_bytes(kp)?; Ok(Self { - key_pair: kp.into(), + key_pair: kp, }) } /// Get the public key of this keypair. #[allow(dead_code)] pub fn public_key(&self) -> PublicKey { - self.key_pair.public() + self.key_pair.public } /// Sign a message using the private key of this keypair. - pub fn sign(&self, msg: &[u8]) -> Vec { + pub fn sign(&self, msg: &[u8]) -> Signature { self.key_pair.sign(msg) } /// Verify the Ed25519 signature on a message using the public key. - pub fn verify(pk: &PublicKey, msg: &[u8], signature: &[u8]) -> Result<(), String> { - if pk.verify(msg, signature) { - return Ok(()); - } + pub fn verify(pk: &PublicKey, msg: &[u8], signature: Signature) -> Result<(), String> { + // let signature = ed25519_dalek::Signature::from_bytes(signature) + // .map_err(|err| format!("Cannot convert bytes to a signature: {:?}", err))?; + let result = pk.verify_strict(msg, &signature) + .map_err(|err| format!("Signature verification failed: {:?}", err))?; Err("Signature is not valid.".to_string()) } @@ -79,6 +86,13 @@ impl KeyPair { impl From for KeyPair { fn from(kp: Libp2pKeyPair) -> Self { + let kp = ed25519_dalek::Keypair::from_bytes(&kp.encode()).unwrap(); + Self { key_pair: kp } + } +} + +impl From for KeyPair { + fn from(kp: ed25519_dalek::Keypair) -> Self { Self { key_pair: kp } } } diff --git a/src/public_key_hashable.rs b/src/public_key_hashable.rs index ddde308..811b337 100644 --- a/src/public_key_hashable.rs +++ b/src/public_key_hashable.rs @@ -14,24 +14,24 @@ * limitations under the License. */ -use crate::ed25519::PublicKey; +use ed25519_dalek::PublicKey; use ref_cast::RefCast; -use serde::Deserialize; use std::{ fmt::{Display, Formatter}, hash::{Hash, Hasher}, }; +use core::fmt; /// Wrapper to use PublicKey in HashMap -#[derive(PartialEq, Eq, Debug, Clone, RefCast, Deserialize)] +#[derive(PartialEq, Eq, Debug, Clone, RefCast)] #[repr(transparent)] pub struct PublicKeyHashable(PublicKey); #[allow(clippy::derive_hash_xor_eq)] impl Hash for PublicKeyHashable { fn hash(&self, state: &mut H) { - state.write(&self.0.encode()); + state.write(&self.0.to_bytes()); state.finish(); } @@ -42,7 +42,7 @@ impl Hash for PublicKeyHashable { // TODO check for overflow let mut bytes: Vec = Vec::with_capacity(data.len() * 32); for d in data { - bytes.extend_from_slice(&d.0.encode()) + bytes.extend_from_slice(&d.0.to_bytes()) } state.write(bytes.as_slice()); state.finish(); @@ -75,6 +75,46 @@ impl AsRef for PublicKey { impl Display for PublicKeyHashable { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", bs58::encode(self.0.encode()).into_string()) + write!(f, "{}", bs58::encode(self.0.to_bytes()).into_string()) + } +} + +impl <'de>serde::Deserialize<'de> for PublicKeyHashable { + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de> { + use serde::de::{Error, Visitor}; + + struct PKVisitor; + + impl<'de> Visitor<'de> for PKVisitor { + type Value = PublicKeyHashable; + + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + formatter.write_str("byte array or base58 string") + } + + fn visit_str(self, s: &str) -> Result + where + E: Error, + { + bs58::decode(s) + .into_vec() + .map_err(|err| Error::custom(format!("Invalid string '{}': {}", s, err))) + .and_then(|v| self.visit_bytes(v.as_slice())) + .map_err(|err: E| Error::custom(format!("Parsed string '{}' as base58, but {}", s, err))) + } + + fn visit_bytes(self, b: &[u8]) -> Result + where + E: Error, + { + let pk = PublicKey::from_bytes(b) + .map_err(|err| Error::custom(format!("Invalid bytes {:?}: {}", b, err)))?; + Ok(PublicKeyHashable::from(pk)) + } + } + + deserializer.deserialize_str(PKVisitor) } } diff --git a/src/revoke.rs b/src/revoke.rs index b35be0e..5927e93 100644 --- a/src/revoke.rs +++ b/src/revoke.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use crate::ed25519::PublicKey; +use ed25519_dalek::PublicKey; use crate::key_pair::KeyPair; use crate::key_pair::Signature; use crate::trust::{EXPIRATION_LEN, PK_LEN}; @@ -61,7 +61,7 @@ impl Revoke { fn signature_bytes(pk: &PublicKey, revoked_at: Duration) -> Vec { let mut msg = Vec::with_capacity(PK_LEN + EXPIRATION_LEN); - msg.extend_from_slice(&pk.encode()); + msg.extend_from_slice(&pk.to_bytes()); msg.extend_from_slice(&(revoked_at.as_secs() as u64).to_le_bytes()); msg @@ -71,14 +71,10 @@ impl Revoke { pub fn verify(revoke: &Revoke) -> Result<(), String> { let msg = Revoke::signature_bytes(&revoke.pk, revoke.revoked_at); - if !revoke + revoke .revoked_by - .verify(msg.as_slice(), revoke.signature.as_slice()) - { - return Err("Revoke has incorrect signature.".to_string()); - } - - Ok(()) + .verify_strict(msg.as_slice(), &revoke.signature) + .map_err(|err| format!("Revoke has incorrect signature: {:?}", err)) } } diff --git a/src/trust.rs b/src/trust.rs index 7f54f11..7794ef0 100644 --- a/src/trust.rs +++ b/src/trust.rs @@ -14,11 +14,12 @@ * limitations under the License. */ -use crate::ed25519::PublicKey; +use ed25519_dalek::{PublicKey}; use crate::key_pair::{KeyPair, Signature}; use derivative::Derivative; use std::convert::TryInto; use std::time::Duration; +use signature::{Signature as SigSignature}; pub const SIG_LEN: usize = 64; pub const PK_LEN: usize = 32; @@ -46,11 +47,11 @@ pub struct Trust { } fn show_pubkey(key: &PublicKey, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - write!(f, "{}", bs58::encode(key.encode()).into_string()) + write!(f, "{}", bs58::encode(&key.to_bytes()).into_string()) } -fn show_sig(sig: &[u8], f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { - write!(f, "{}", bs58::encode(sig).into_string()) +fn show_sig(sig: &ed25519_dalek::Signature, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { + write!(f, "{}", bs58::encode(&sig.to_bytes()).into_string()) } impl Trust { @@ -96,13 +97,13 @@ impl Trust { let msg: &[u8] = &Self::metadata_bytes(&trust.issued_for, trust.expires_at, trust.issued_at); - KeyPair::verify(issued_by, msg, trust.signature.as_slice())?; + KeyPair::verify(issued_by, msg, trust.signature)?; Ok(()) } fn metadata_bytes(pk: &PublicKey, expires_at: Duration, issued_at: Duration) -> [u8; 48] { - let pk_encoded = pk.encode(); + let pk_encoded = pk.to_bytes(); let expires_at_encoded: [u8; EXPIRATION_LEN] = (expires_at.as_secs() as u64).to_le_bytes(); let issued_at_encoded: [u8; ISSUED_LEN] = (issued_at.as_secs() as u64).to_le_bytes(); let mut metadata = [0; METADATA_LEN]; @@ -120,8 +121,8 @@ impl Trust { #[allow(dead_code)] pub fn encode(&self) -> Vec { let mut vec = Vec::with_capacity(TRUST_LEN); - vec.extend_from_slice(&self.issued_for.encode()); - vec.extend_from_slice(&self.signature.as_slice()); + vec.extend_from_slice(&self.issued_for.to_bytes()); + vec.extend_from_slice(&self.signature.to_bytes()); vec.extend_from_slice(&(self.expires_at.as_secs() as u64).to_le_bytes()); vec.extend_from_slice(&(self.issued_at.as_secs() as u64).to_le_bytes()); @@ -137,8 +138,10 @@ impl Trust { ); } - let pk = PublicKey::decode(&arr[0..PK_LEN]).map_err(|err| err.to_string())?; + let pk = PublicKey::from_bytes(&arr[0..PK_LEN]).map_err(|err| err.to_string())?; + let signature = &arr[PK_LEN..PK_LEN + SIG_LEN]; + let signature = Signature::from_bytes(signature).map_err(|err| err.to_string())?; let expiration_bytes = &arr[PK_LEN + SIG_LEN..PK_LEN + SIG_LEN + EXPIRATION_LEN]; let expiration_date = u64::from_le_bytes(expiration_bytes.try_into().unwrap()); @@ -150,7 +153,7 @@ impl Trust { Ok(Self { issued_for: pk, - signature: signature.to_vec(), + signature: signature, expires_at: expiration_date, issued_at: issued_date, }) @@ -183,7 +186,7 @@ impl Trust { ) -> Result { // PublicKey let issued_for_bytes = Self::bs58_str_to_vec(issued_for, "issued_for")?; - let issued_for = PublicKey::decode(issued_for_bytes.as_slice()).map_err(|e| { + let issued_for = PublicKey::from_bytes(issued_for_bytes.as_slice()).map_err(|e| { format!( "Cannot decode the public key: {} in the trust '{}'", issued_for, e @@ -192,6 +195,7 @@ impl Trust { // 64 bytes signature let signature = Self::bs58_str_to_vec(signature, "signature")?; + let signature = Signature::from_bytes(&signature).map_err(|err| err.to_string())?; // Duration let expires_at = Self::str_to_duration(expires_at, "expires_at")?; @@ -205,8 +209,8 @@ impl Trust { impl ToString for Trust { fn to_string(&self) -> String { - let issued_for = bs58::encode(self.issued_for.encode()).into_string(); - let signature = bs58::encode(self.signature.as_slice()).into_string(); + let issued_for = bs58::encode(self.issued_for.to_bytes()).into_string(); + let signature = bs58::encode(self.signature.to_bytes()).into_string(); let expires_at = (self.expires_at.as_secs() as u64).to_string(); let issued_at = (self.issued_at.as_secs() as u64).to_string(); diff --git a/src/trust_graph.rs b/src/trust_graph.rs index 44ef933..3da66aa 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -15,7 +15,7 @@ */ use crate::certificate::Certificate; -use crate::ed25519::PublicKey; +use ed25519_dalek::PublicKey; use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; diff --git a/src/trust_graph_storage.rs b/src/trust_graph_storage.rs index aa2eae6..551e344 100644 --- a/src/trust_graph_storage.rs +++ b/src/trust_graph_storage.rs @@ -2,7 +2,7 @@ use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust_graph::Weight; use crate::trust_node::{Auth, TrustNode}; -use libp2p_core::identity::ed25519::PublicKey; +use ed25519_dalek::PublicKey; use std::collections::HashMap; use std::time::Duration; diff --git a/src/trust_node.rs b/src/trust_node.rs index 4850dfc..8e1675b 100644 --- a/src/trust_node.rs +++ b/src/trust_node.rs @@ -14,7 +14,7 @@ * limitations under the License. */ -use crate::ed25519::PublicKey; +use ed25519_dalek::PublicKey; use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; From 256cf964366959e4c93f412673bb1f7c825c9865 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Jan 2021 20:14:40 +0300 Subject: [PATCH 5/8] non-test code compiles --- src/key_pair.rs | 10 +++------- src/public_key_hashable.rs | 2 +- src/trust_graph.rs | 3 ++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/key_pair.rs b/src/key_pair.rs index 41f463c..0af1529 100644 --- a/src/key_pair.rs +++ b/src/key_pair.rs @@ -14,12 +14,10 @@ * limitations under the License. */ -extern crate rand; - use crate::ed25519::{Keypair as Libp2pKeyPair}; use ed25519_dalek::SignatureError; use ed25519_dalek::{PublicKey, Signer}; -use signature::{Signature as SigSignature}; + use core::fmt::{Debug}; use std::fmt; use rand::rngs::OsRng; @@ -77,10 +75,8 @@ impl KeyPair { pub fn verify(pk: &PublicKey, msg: &[u8], signature: Signature) -> Result<(), String> { // let signature = ed25519_dalek::Signature::from_bytes(signature) // .map_err(|err| format!("Cannot convert bytes to a signature: {:?}", err))?; - let result = pk.verify_strict(msg, &signature) - .map_err(|err| format!("Signature verification failed: {:?}", err))?; - - Err("Signature is not valid.".to_string()) + pk.verify_strict(msg, &signature) + .map_err(|err| format!("Signature verification failed: {:?}", err)) } } diff --git a/src/public_key_hashable.rs b/src/public_key_hashable.rs index 811b337..3f01d11 100644 --- a/src/public_key_hashable.rs +++ b/src/public_key_hashable.rs @@ -90,7 +90,7 @@ impl <'de>serde::Deserialize<'de> for PublicKeyHashable { impl<'de> Visitor<'de> for PKVisitor { type Value = PublicKeyHashable; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("byte array or base58 string") } diff --git a/src/trust_graph.rs b/src/trust_graph.rs index 3da66aa..820fcd2 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -212,7 +212,8 @@ impl TrustGraph { // - that trust must converge to one of the root weights // - there should be more than 1 trust in the chain let self_signed = last.issued_by == last.trust.issued_for; - let converges_to_root = roots.contains(last.issued_by.as_ref()); + let issued_by: &PublicKeyHashable = last.issued_by.as_ref(); + let converges_to_root = roots.contains(issued_by); if self_signed && converges_to_root && cur_chain.len() > 1 { terminated_chains.push(cur_chain); From e8c109df992228a2116fdafd611f14a9d3f7a521 Mon Sep 17 00:00:00 2001 From: DieMyst Date: Mon, 18 Jan 2021 20:27:47 +0300 Subject: [PATCH 6/8] tests work! --- src/certificate.rs | 31 ++++++++++++++++--------------- src/key_pair.rs | 13 ++++++++++++- src/trust_graph.rs | 2 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/certificate.rs b/src/certificate.rs index e242ac7..8b7bfac 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -237,6 +237,7 @@ mod tests { use super::*; use crate::misc::current_time; use std::time::{Duration, SystemTime, UNIX_EPOCH}; + use crate::key_pair::KeyPair; pub fn one_second() -> Duration { Duration::from_secs(1) @@ -260,7 +261,7 @@ mod tests { let new_cert = Certificate::issue( &second_kp, - third_kp.key_pair.public(), + third_kp.key_pair.public, &cert, cur_time.checked_add(one_second()).unwrap(), cur_time, @@ -287,7 +288,7 @@ mod tests { let new_cert = Certificate::issue( &second_kp, - third_kp.key_pair.public(), + third_kp.key_pair.public, &cert, cur_time.checked_add(one_second()).unwrap(), cur_time, @@ -347,7 +348,7 @@ mod tests { let new_cert = Certificate::issue( &second_kp, - third_kp.key_pair.public(), + third_kp.key_pair.public, &cert, cur_time.checked_add(one_year()).unwrap(), cur_time, @@ -358,18 +359,18 @@ mod tests { println!( "root_kp:\n\tprivate: {}\n\tpublic: {}", - bs58::encode(root_kp.key_pair.secret()).into_string(), - bs58::encode(&root_kp.key_pair.public().encode().to_vec()).into_string() + bs58::encode(root_kp.clone().key_pair.secret).into_string(), + bs58::encode(&root_kp.key_pair.public.to_bytes().to_vec()).into_string() ); println!( "second_kp:\n\tprivate: {}\n\tpublic: {}", - bs58::encode(second_kp.key_pair.secret()).into_string(), - bs58::encode(&second_kp.key_pair.public().encode().to_vec()).into_string() + bs58::encode(second_kp.clone().key_pair.secret).into_string(), + bs58::encode(&second_kp.key_pair.public.to_bytes().to_vec()).into_string() ); println!( "third_kp:\n\tprivate: {}\n\tpublic: {}", - bs58::encode(third_kp.key_pair.secret()).into_string(), - bs58::encode(&third_kp.key_pair.public().encode().to_vec()).into_string() + bs58::encode(third_kp.clone().key_pair.secret).into_string(), + bs58::encode(&third_kp.key_pair.public.to_bytes().to_vec()).into_string() ); println!("cert is\n{}", new_cert.to_string()); @@ -390,7 +391,7 @@ mod tests { let new_cert = Certificate::issue( &second_kp, - third_kp.key_pair.public(), + third_kp.key_pair.public, &cert, cur_time.checked_sub(one_second()).unwrap(), cur_time.checked_sub(one_minute()).unwrap(), @@ -412,7 +413,7 @@ mod tests { let new_cert = Certificate::issue( &second_kp, - third_kp.key_pair.public(), + third_kp.key_pair.public, &cert, cur_time.checked_add(one_second()).unwrap(), cur_time, @@ -421,7 +422,7 @@ mod tests { .unwrap(); let new_cert = Certificate::issue( &third_kp, - fourth_kp.key_pair.public(), + fourth_kp.key_pair.public, &new_cert, cur_time.checked_add(one_second()).unwrap(), cur_time, @@ -450,7 +451,7 @@ mod tests { let new_cert = Certificate::issue( &second_kp, - third_kp.key_pair.public(), + third_kp.key_pair.public, &cert, cur_time.checked_add(one_second()).unwrap(), cur_time, @@ -459,7 +460,7 @@ mod tests { .unwrap(); let new_cert = Certificate::issue( &second_kp, - fourth_kp.key_pair.public(), + fourth_kp.key_pair.public, &new_cert, cur_time.checked_add(one_second()).unwrap(), cur_time, @@ -484,7 +485,7 @@ mod tests { let bad_kp = KeyPair::generate(); let new_cert_bad = Certificate::issue( &bad_kp, - bad_kp.key_pair.public(), + bad_kp.key_pair.public, &cert, cur_time.checked_add(one_second()).unwrap(), cur_time, diff --git a/src/key_pair.rs b/src/key_pair.rs index 0af1529..c5a7694 100644 --- a/src/key_pair.rs +++ b/src/key_pair.rs @@ -16,7 +16,7 @@ use crate::ed25519::{Keypair as Libp2pKeyPair}; use ed25519_dalek::SignatureError; -use ed25519_dalek::{PublicKey, Signer}; +use ed25519_dalek::{PublicKey, Signer, SecretKey}; use core::fmt::{Debug}; use std::fmt; @@ -134,3 +134,14 @@ impl<'de> serde::Deserialize<'de> for KeyPair { deserializer.deserialize_str(KeyPairVisitor) } } + +impl Clone for KeyPair { + fn clone(&self) -> KeyPair { + let mut sk_bytes = self.key_pair.secret.to_bytes(); + let secret = SecretKey::from_bytes(&mut sk_bytes) + .expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k"); + let public = PublicKey::from_bytes(&self.key_pair.public.to_bytes()) + .expect("ed25519::PublicKey::from_bytes(to_bytes(k)) != k"); + KeyPair { key_pair: ed25519_dalek::Keypair { secret, public } } + } +} diff --git a/src/trust_graph.rs b/src/trust_graph.rs index 820fcd2..4290a77 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -371,7 +371,7 @@ mod tests { let st = Box::new(InMemoryStorage::new()); let mut graph = TrustGraph::new(st); - graph.add_root_weight(root.key_pair.public().into(), 0); + graph.add_root_weight(root.key_pair.public.into(), 0); let addition = graph.add(cert, current_time()); assert_eq!(addition.is_ok(), true); From dd761dd61c454d7ceb74d3634d14a540eafb681e Mon Sep 17 00:00:00 2001 From: DieMyst Date: Tue, 19 Jan 2021 17:20:44 +0300 Subject: [PATCH 7/8] move identity to separate package --- Cargo.lock | 18 +++++++++++++++++ Cargo.toml | 1 + bin/Cargo.lock | 18 +++++++++++++++++ identity/Cargo.toml | 20 +++++++++++++++++++ {src => identity/src}/key_pair.rs | 0 identity/src/lib.rs | 33 +++++++++++++++++++++++++++++++ src/certificate.rs | 4 ++-- src/lib.rs | 4 ---- src/revoke.rs | 4 ++-- src/trust.rs | 2 +- src/trust_graph.rs | 2 +- src/trust_node.rs | 2 +- 12 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 identity/Cargo.toml rename {src => identity/src}/key_pair.rs (100%) create mode 100644 identity/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index cf446df..d541a94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -356,6 +356,23 @@ dependencies = [ "url", ] +[[package]] +name = "fluence-identity" +version = "0.2.0" +dependencies = [ + "bs58 0.3.1", + "derivative", + "ed25519-dalek", + "failure", + "fluence-fork-libp2p-core", + "log", + "rand 0.7.3", + "ref-cast", + "serde", + "serde_json", + "signature", +] + [[package]] name = "fnv" version = "1.0.7" @@ -1325,6 +1342,7 @@ dependencies = [ "ed25519-dalek", "failure", "fluence-fork-libp2p-core", + "fluence-identity", "log", "rand 0.7.3", "ref-cast", diff --git a/Cargo.toml b/Cargo.toml index cab4ac2..3d17ace 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ license = "Apache-2.0" [dependencies] libp2p-core = { package = "fluence-fork-libp2p-core", version = "0.26.0" } serde = { version = "=1.0.118", features = ["derive"] } +fluence-identity = { path = "identity" } serde_json = "1.0.58" bs58 = "0.3.1" failure = "0.1.6" diff --git a/bin/Cargo.lock b/bin/Cargo.lock index be06a28..8e53f3b 100644 --- a/bin/Cargo.lock +++ b/bin/Cargo.lock @@ -366,6 +366,23 @@ dependencies = [ "url", ] +[[package]] +name = "fluence-identity" +version = "0.2.0" +dependencies = [ + "bs58 0.3.1", + "derivative", + "ed25519-dalek", + "failure", + "fluence-fork-libp2p-core", + "log", + "rand 0.7.3", + "ref-cast", + "serde", + "serde_json", + "signature", +] + [[package]] name = "fluence-sdk-macro" version = "0.2.18" @@ -1369,6 +1386,7 @@ dependencies = [ "ed25519-dalek", "failure", "fluence-fork-libp2p-core", + "fluence-identity", "log", "rand 0.7.3", "ref-cast", diff --git a/identity/Cargo.toml b/identity/Cargo.toml new file mode 100644 index 0000000..f72c77f --- /dev/null +++ b/identity/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "fluence-identity" +version = "0.2.0" +authors = ["Fluence Labs"] +edition = "2018" +description = "identity" +license = "Apache-2.0" + +[dependencies] +libp2p-core = { package = "fluence-fork-libp2p-core", version = "0.26.0" } +serde = { version = "=1.0.118", features = ["derive"] } +serde_json = "1.0.58" +bs58 = "0.3.1" +failure = "0.1.6" +log = "0.4.11" +ref-cast = "1.0.2" +derivative = "2.1.1" +ed25519-dalek = "1.0.1" +rand = "0.7.0" +signature = "1.3.0" diff --git a/src/key_pair.rs b/identity/src/key_pair.rs similarity index 100% rename from src/key_pair.rs rename to identity/src/key_pair.rs diff --git a/identity/src/lib.rs b/identity/src/lib.rs new file mode 100644 index 0000000..9f6f5a8 --- /dev/null +++ b/identity/src/lib.rs @@ -0,0 +1,33 @@ +/* + * Copyright 2020 Fluence Labs Limited + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#![recursion_limit = "512"] +#![warn(rust_2018_idioms)] +#![deny( + dead_code, + nonstandard_style, + unused_imports, + unused_mut, + unused_variables, + unused_unsafe, + unreachable_patterns +)] + +pub mod key_pair; + +pub use key_pair::KeyPair; + +pub(crate) use libp2p_core::identity::ed25519; diff --git a/src/certificate.rs b/src/certificate.rs index 8b7bfac..a2522f9 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -15,7 +15,7 @@ */ use ed25519_dalek::PublicKey; -use crate::key_pair::KeyPair; +use fluence_identity::key_pair::KeyPair; use crate::trust::{Trust, TRUST_LEN}; use std::str::FromStr; use std::time::Duration; @@ -237,7 +237,7 @@ mod tests { use super::*; use crate::misc::current_time; use std::time::{Duration, SystemTime, UNIX_EPOCH}; - use crate::key_pair::KeyPair; + use fluence_identity::key_pair::KeyPair; pub fn one_second() -> Duration { Duration::from_secs(1) diff --git a/src/lib.rs b/src/lib.rs index e338c14..9672dfc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,6 @@ mod certificate; pub mod certificate_serde; -mod key_pair; mod misc; mod public_key_hashable; mod revoke; @@ -37,10 +36,7 @@ mod trust_graph; mod trust_graph_storage; mod trust_node; -pub(crate) use libp2p_core::identity::ed25519; - pub use crate::certificate::Certificate; -pub use crate::key_pair::KeyPair; pub use crate::misc::current_time; pub use crate::public_key_hashable::PublicKeyHashable; pub use crate::trust::Trust; diff --git a/src/revoke.rs b/src/revoke.rs index 5927e93..27acf8d 100644 --- a/src/revoke.rs +++ b/src/revoke.rs @@ -15,8 +15,8 @@ */ use ed25519_dalek::PublicKey; -use crate::key_pair::KeyPair; -use crate::key_pair::Signature; +use fluence_identity::key_pair::KeyPair; +use fluence_identity::key_pair::Signature; use crate::trust::{EXPIRATION_LEN, PK_LEN}; use std::time::Duration; diff --git a/src/trust.rs b/src/trust.rs index 7794ef0..8db00e7 100644 --- a/src/trust.rs +++ b/src/trust.rs @@ -15,7 +15,7 @@ */ use ed25519_dalek::{PublicKey}; -use crate::key_pair::{KeyPair, Signature}; +use fluence_identity::key_pair::{KeyPair, Signature}; use derivative::Derivative; use std::convert::TryInto; use std::time::Duration; diff --git a/src/trust_graph.rs b/src/trust_graph.rs index 4290a77..f947024 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -279,7 +279,7 @@ impl TrustGraph { #[cfg(test)] mod tests { use super::*; - use crate::key_pair::KeyPair; + use fluence_identity::key_pair::KeyPair; use crate::misc::current_time; use crate::trust_graph_storage::InMemoryStorage; use failure::_core::time::Duration; diff --git a/src/trust_node.rs b/src/trust_node.rs index 8e1675b..830299d 100644 --- a/src/trust_node.rs +++ b/src/trust_node.rs @@ -150,7 +150,7 @@ impl TrustNode { mod tests { use std::time::Duration; - use crate::key_pair::KeyPair; + use fluence_identity::key_pair::KeyPair; use super::*; From 37de2ff3364e6dbaefe1181f4fbad8990492edbf Mon Sep 17 00:00:00 2001 From: DieMyst Date: Tue, 19 Jan 2021 17:25:28 +0300 Subject: [PATCH 8/8] fmt, bin sub project for wasm --- bin/Cargo.lock | 1 + bin/Cargo.toml | 1 + bin/{ => src}/main.rs | 4 +--- bin/{ => src}/service_api.rs | 0 bin/{ => src}/storage_impl.rs | 0 identity/src/key_pair.rs | 20 ++++++++++---------- src/certificate.rs | 4 ++-- src/public_key_hashable.rs | 21 ++++++++++++--------- src/revoke.rs | 2 +- src/trust.rs | 11 +++++++---- src/trust_graph.rs | 4 ++-- src/trust_node.rs | 2 +- 12 files changed, 38 insertions(+), 32 deletions(-) rename bin/{ => src}/main.rs (67%) rename bin/{ => src}/service_api.rs (100%) rename bin/{ => src}/storage_impl.rs (100%) diff --git a/bin/Cargo.lock b/bin/Cargo.lock index 8e53f3b..4265d78 100644 --- a/bin/Cargo.lock +++ b/bin/Cargo.lock @@ -1400,6 +1400,7 @@ name = "trust-graph-wasm" version = "0.2.0" dependencies = [ "fluence", + "log", "trust-graph", ] diff --git a/bin/Cargo.toml b/bin/Cargo.toml index 7aeba59..fac534a 100644 --- a/bin/Cargo.toml +++ b/bin/Cargo.toml @@ -12,4 +12,5 @@ path = "src/main.rs" [dependencies] trust-graph = { path = "../" } +log = "0.4.8" fluence = { version = "0.2.18", features = ["logger"] } \ No newline at end of file diff --git a/bin/main.rs b/bin/src/main.rs similarity index 67% rename from bin/main.rs rename to bin/src/main.rs index deba21a..1e07879 100644 --- a/bin/main.rs +++ b/bin/src/main.rs @@ -1,10 +1,8 @@ use fluence::WasmLoggerBuilder; -pub(crate) type Result = std::result::Result; - pub fn main() { WasmLoggerBuilder::new() .with_log_level(log::Level::Info) .build() .unwrap(); -} \ No newline at end of file +} diff --git a/bin/service_api.rs b/bin/src/service_api.rs similarity index 100% rename from bin/service_api.rs rename to bin/src/service_api.rs diff --git a/bin/storage_impl.rs b/bin/src/storage_impl.rs similarity index 100% rename from bin/storage_impl.rs rename to bin/src/storage_impl.rs diff --git a/identity/src/key_pair.rs b/identity/src/key_pair.rs index c5a7694..b4e2dd0 100644 --- a/identity/src/key_pair.rs +++ b/identity/src/key_pair.rs @@ -14,13 +14,13 @@ * limitations under the License. */ -use crate::ed25519::{Keypair as Libp2pKeyPair}; +use crate::ed25519::Keypair as Libp2pKeyPair; use ed25519_dalek::SignatureError; -use ed25519_dalek::{PublicKey, Signer, SecretKey}; +use ed25519_dalek::{PublicKey, SecretKey, Signer}; -use core::fmt::{Debug}; -use std::fmt; +use core::fmt::Debug; use rand::rngs::OsRng; +use std::fmt; pub type Signature = ed25519_dalek::Signature; @@ -34,14 +34,14 @@ impl KeyPair { /// Generate a new Ed25519 keypair. #[allow(dead_code)] pub fn generate() -> Self { - let mut csprng = OsRng { }; + let mut csprng = OsRng {}; let kp = ed25519_dalek::Keypair::generate(&mut csprng); kp.into() } pub fn from_bytes(sk_bytes: &[u8]) -> Result { let kp = ed25519_dalek::Keypair::from_bytes(sk_bytes)?; - Ok(KeyPair {key_pair: kp}) + Ok(KeyPair { key_pair: kp }) } /// Encode the keypair into a byte array by concatenating the bytes @@ -55,9 +55,7 @@ impl KeyPair { #[allow(dead_code)] pub fn decode(kp: &[u8]) -> Result { let kp = ed25519_dalek::Keypair::from_bytes(kp)?; - Ok(Self { - key_pair: kp, - }) + Ok(Self { key_pair: kp }) } /// Get the public key of this keypair. @@ -142,6 +140,8 @@ impl Clone for KeyPair { .expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k"); let public = PublicKey::from_bytes(&self.key_pair.public.to_bytes()) .expect("ed25519::PublicKey::from_bytes(to_bytes(k)) != k"); - KeyPair { key_pair: ed25519_dalek::Keypair { secret, public } } + KeyPair { + key_pair: ed25519_dalek::Keypair { secret, public }, + } } } diff --git a/src/certificate.rs b/src/certificate.rs index a2522f9..882378c 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -14,9 +14,9 @@ * limitations under the License. */ +use crate::trust::{Trust, TRUST_LEN}; use ed25519_dalek::PublicKey; use fluence_identity::key_pair::KeyPair; -use crate::trust::{Trust, TRUST_LEN}; use std::str::FromStr; use std::time::Duration; @@ -236,8 +236,8 @@ impl FromStr for Certificate { mod tests { use super::*; use crate::misc::current_time; - use std::time::{Duration, SystemTime, UNIX_EPOCH}; use fluence_identity::key_pair::KeyPair; + use std::time::{Duration, SystemTime, UNIX_EPOCH}; pub fn one_second() -> Duration { Duration::from_secs(1) diff --git a/src/public_key_hashable.rs b/src/public_key_hashable.rs index 3f01d11..abad57a 100644 --- a/src/public_key_hashable.rs +++ b/src/public_key_hashable.rs @@ -16,12 +16,12 @@ use ed25519_dalek::PublicKey; +use core::fmt; use ref_cast::RefCast; use std::{ fmt::{Display, Formatter}, hash::{Hash, Hasher}, }; -use core::fmt; /// Wrapper to use PublicKey in HashMap #[derive(PartialEq, Eq, Debug, Clone, RefCast)] @@ -79,10 +79,11 @@ impl Display for PublicKeyHashable { } } -impl <'de>serde::Deserialize<'de> for PublicKeyHashable { +impl<'de> serde::Deserialize<'de> for PublicKeyHashable { fn deserialize(deserializer: D) -> Result - where - D: serde::Deserializer<'de> { + where + D: serde::Deserializer<'de>, + { use serde::de::{Error, Visitor}; struct PKVisitor; @@ -95,19 +96,21 @@ impl <'de>serde::Deserialize<'de> for PublicKeyHashable { } fn visit_str(self, s: &str) -> Result - where - E: Error, + where + E: Error, { bs58::decode(s) .into_vec() .map_err(|err| Error::custom(format!("Invalid string '{}': {}", s, err))) .and_then(|v| self.visit_bytes(v.as_slice())) - .map_err(|err: E| Error::custom(format!("Parsed string '{}' as base58, but {}", s, err))) + .map_err(|err: E| { + Error::custom(format!("Parsed string '{}' as base58, but {}", s, err)) + }) } fn visit_bytes(self, b: &[u8]) -> Result - where - E: Error, + where + E: Error, { let pk = PublicKey::from_bytes(b) .map_err(|err| Error::custom(format!("Invalid bytes {:?}: {}", b, err)))?; diff --git a/src/revoke.rs b/src/revoke.rs index 27acf8d..c148d98 100644 --- a/src/revoke.rs +++ b/src/revoke.rs @@ -14,10 +14,10 @@ * limitations under the License. */ +use crate::trust::{EXPIRATION_LEN, PK_LEN}; use ed25519_dalek::PublicKey; use fluence_identity::key_pair::KeyPair; use fluence_identity::key_pair::Signature; -use crate::trust::{EXPIRATION_LEN, PK_LEN}; use std::time::Duration; /// "A document" that cancels trust created before. diff --git a/src/trust.rs b/src/trust.rs index 8db00e7..26fda13 100644 --- a/src/trust.rs +++ b/src/trust.rs @@ -14,12 +14,12 @@ * limitations under the License. */ -use ed25519_dalek::{PublicKey}; -use fluence_identity::key_pair::{KeyPair, Signature}; use derivative::Derivative; +use ed25519_dalek::PublicKey; +use fluence_identity::key_pair::{KeyPair, Signature}; +use signature::Signature as SigSignature; use std::convert::TryInto; use std::time::Duration; -use signature::{Signature as SigSignature}; pub const SIG_LEN: usize = 64; pub const PK_LEN: usize = 32; @@ -50,7 +50,10 @@ fn show_pubkey(key: &PublicKey, f: &mut std::fmt::Formatter<'_>) -> Result<(), s write!(f, "{}", bs58::encode(&key.to_bytes()).into_string()) } -fn show_sig(sig: &ed25519_dalek::Signature, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { +fn show_sig( + sig: &ed25519_dalek::Signature, + f: &mut std::fmt::Formatter<'_>, +) -> Result<(), std::fmt::Error> { write!(f, "{}", bs58::encode(&sig.to_bytes()).into_string()) } diff --git a/src/trust_graph.rs b/src/trust_graph.rs index f947024..46fecd6 100644 --- a/src/trust_graph.rs +++ b/src/trust_graph.rs @@ -15,12 +15,12 @@ */ use crate::certificate::Certificate; -use ed25519_dalek::PublicKey; use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; use crate::trust_graph_storage::Storage; use crate::trust_node::{Auth, TrustNode}; +use ed25519_dalek::PublicKey; use std::borrow::Borrow; use std::collections::{HashSet, VecDeque}; use std::time::Duration; @@ -279,10 +279,10 @@ impl TrustGraph { #[cfg(test)] mod tests { use super::*; - use fluence_identity::key_pair::KeyPair; use crate::misc::current_time; use crate::trust_graph_storage::InMemoryStorage; use failure::_core::time::Duration; + use fluence_identity::key_pair::KeyPair; use std::collections::HashMap; pub fn one_minute() -> Duration { diff --git a/src/trust_node.rs b/src/trust_node.rs index 830299d..7713821 100644 --- a/src/trust_node.rs +++ b/src/trust_node.rs @@ -14,10 +14,10 @@ * limitations under the License. */ -use ed25519_dalek::PublicKey; use crate::public_key_hashable::PublicKeyHashable; use crate::revoke::Revoke; use crate::trust::Trust; +use ed25519_dalek::PublicKey; use failure::_core::time::Duration; use std::collections::HashMap;