diff --git a/Cargo.lock b/Cargo.lock index dc6fb4d7..19ca049a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,14 +3,20 @@ version = 3 [[package]] -name = "aead" -version = "0.4.1" +name = "addr2line" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" +checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd" dependencies = [ - "generic-array", + "gimli", ] +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "ahash" version = "0.4.7" @@ -19,20 +25,29 @@ checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "ahash" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" dependencies = [ - "getrandom 0.2.2", + "getrandom 0.2.3", "once_cell", "version_check", ] +[[package]] +name = "anomaly" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "550632e31568ae1a5f47998c3aa48563030fc49b9ec91913ca337cf64fbc5ccb" +dependencies = [ + "backtrace", +] + [[package]] name = "anyhow" -version = "1.0.40" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" +checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" [[package]] name = "ark-bls12-381" @@ -56,7 +71,6 @@ dependencies = [ "ark-std", "derivative", "num-traits", - "rayon", "zeroize", ] @@ -86,7 +100,6 @@ dependencies = [ "num-bigint", "num-traits", "paste", - "rayon", "rustc_version 0.3.3", "zeroize", ] @@ -113,35 +126,6 @@ dependencies = [ "syn", ] -[[package]] -name = "ark-nonnative-field" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440ad4569974910adbeb84422b7e622b79e08d27142afd113785b7fcfb446186" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-r1cs-std", - "ark-relations", - "ark-std", - "derivative", - "num-bigint", - "num-integer", - "num-traits", - "tracing", -] - -[[package]] -name = "ark-pallas" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e945e1c8d86aa869853944ce6ecf072c2dac623b88c94e68792901b06190e53" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-std", -] - [[package]] name = "ark-poly" version = "0.3.0" @@ -153,54 +137,6 @@ dependencies = [ "ark-std", "derivative", "hashbrown 0.11.2", - "rayon", -] - -[[package]] -name = "ark-poly-commit" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a71ddfa72bad1446cab7bbecb6018dbbdc9abcbc3a0065483ae5186ad2a64dcd" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-nonnative-field", - "ark-poly", - "ark-relations", - "ark-serialize", - "ark-std", - "derivative", - "digest", - "rayon", - "tracing", -] - -[[package]] -name = "ark-r1cs-std" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e8fdacb1931f238a0d866ced1e916a49d36de832fd8b83dc916b718ae72893" -dependencies = [ - "ark-ec", - "ark-ff", - "ark-relations", - "ark-std", - "derivative", - "num-bigint", - "num-traits", - "tracing", -] - -[[package]] -name = "ark-relations" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cba4c1c99792a6834bd97f7fd76578ec2cd58d2afc5139a17e1d1bec65b38f6" -dependencies = [ - "ark-ff", - "ark-std", - "tracing", - "tracing-subscriber", ] [[package]] @@ -233,7 +169,6 @@ checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" dependencies = [ "num-traits", "rand 0.8.4", - "rayon", ] [[package]] @@ -242,12 +177,32 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + [[package]] name = "arrayvec" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "async-trait" +version = "0.1.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -265,6 +220,21 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a905d892734eea339e896738c14b9afce22b5318f64b951e70bf3844419b01" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bincode" version = "1.3.3" @@ -280,34 +250,11 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -[[package]] -name = "bitvec" -version = "0.18.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" -dependencies = [ - "funty", - "radium 0.3.0", - "wyz", -] - -[[package]] -name = "bitvec" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" -dependencies = [ - "funty", - "radium 0.6.2", - "tap", - "wyz", -] - [[package]] name = "blake2" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4" +checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" dependencies = [ "crypto-mac", "digest", @@ -321,7 +268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", - "arrayvec", + "arrayvec 0.5.2", "constant_time_eq", ] @@ -334,22 +281,11 @@ dependencies = [ "generic-array", ] -[[package]] -name = "bls12_381" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c56609cc42c628848e7b18e0baf42a4ef626b8c50442dc08b8094bd21d8ad32" -dependencies = [ - "ff 0.9.0", - "rand_core 0.6.3", - "subtle", -] - [[package]] name = "borsh" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fcabb02816fdadf90866dc9a7824491ccb63d69f55375a266dc03509ac68d36" +checksum = "18dda7dc709193c0d86a1a51050a926dc3df1cf262ec46a23a25dba421ea1924" dependencies = [ "borsh-derive", "hashbrown 0.9.1", @@ -357,9 +293,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd16f0729b89f0a212b0e2e1d19cc6593df63f771161a11863967780e2d033d" +checksum = "684155372435f578c0fa1acd13ebbb182cc19d6b38b64ae7901da4393217d264" dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", @@ -370,9 +306,9 @@ dependencies = [ [[package]] name = "borsh-derive-internal" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e321a130a3ac4b88eb59a6d670bde11eec9721a397b77e0f2079060e2a1b785" +checksum = "2102f62f8b6d3edeab871830782285b64cc1830168094db05c8e458f209bc5c3" dependencies = [ "proc-macro2", "quote", @@ -381,9 +317,9 @@ dependencies = [ [[package]] name = "borsh-schema-derive-internal" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15151a485164b319cc7a5160fe4316dc469a27993f71b73d7617dc9032ff0fd7" +checksum = "196c978c4c9b0b142d446ef3240690bf5a8a33497074a113ff9a337ccb750483" dependencies = [ "proc-macro2", "quote", @@ -392,9 +328,9 @@ dependencies = [ [[package]] name = "bstr" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" dependencies = [ "lazy_static", "memchr", @@ -404,9 +340,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.6.1" +version = "3.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9df67f7bf9ef8498769f994239c45613ef0c5899415fb58e9add412d2c1a538" + +[[package]] +name = "bytemuck" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" [[package]] name = "byteorder" @@ -414,15 +356,27 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +[[package]] +name = "bytes" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" + [[package]] name = "cast" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc38c385bfd7e444464011bb24820f40dd1c76bcdfa1b78611cb7c2e5cafab75" +checksum = "4c24dab4283a142afa2fdca129b80ad2c6284e073930f964c3a1293c225ee39a" dependencies = [ - "rustc_version 0.2.3", + "rustc_version 0.4.0", ] +[[package]] +name = "cc" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" + [[package]] name = "cfg-if" version = "1.0.0" @@ -431,27 +385,27 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chacha20" -version = "0.7.1" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +checksum = "f08493fa7707effc63254c66c6ea908675912493cd67952eda23c09fae2610b1" dependencies = [ "cfg-if", "cipher", "cpufeatures", - "zeroize", ] [[package]] -name = "chacha20poly1305" -version = "0.8.0" +name = "chrono" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" dependencies = [ - "aead", - "chacha20", - "cipher", - "poly1305", - "zeroize", + "libc", + "num-integer", + "num-traits", + "serde", + "time", + "winapi", ] [[package]] @@ -481,25 +435,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] -name = "cpufeatures" -version = "0.1.5" +name = "cpp_demangle" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" dependencies = [ - "libc", + "cfg-if", ] [[package]] -name = "cpuid-bool" -version = "0.1.2" +name = "cpufeatures" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +dependencies = [ + "libc", +] [[package]] name = "criterion" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" +checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10" dependencies = [ "atty", "cast", @@ -523,12 +480,12 @@ dependencies = [ [[package]] name = "criterion-plot" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +checksum = "d00996de9f2f7559f7f4dc286073197f83e92256a59ed395f9aac01fe717da57" dependencies = [ "cast", - "itertools 0.9.0", + "itertools 0.10.1", ] [[package]] @@ -543,9 +500,9 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if", "crossbeam-epoch", @@ -554,9 +511,9 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd" dependencies = [ "cfg-if", "crossbeam-utils", @@ -567,11 +524,10 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "autocfg", "cfg-if", "lazy_static", ] @@ -610,18 +566,26 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" dependencies = [ "byteorder", "digest", "rand_core 0.5.1", - "serde", "subtle", "zeroize", ] +[[package]] +name = "debugid" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" +dependencies = [ + "uuid", +] + [[package]] name = "derivative" version = "2.2.0" @@ -644,9 +608,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +checksum = "4620d40f6d2601794401d6dd95a5cf69b6c157852539470eeda433a99b3c0efc" dependencies = [ "serde", "signature", @@ -683,68 +647,142 @@ dependencies = [ "ark-ec", "ark-ed-on-bls12-381", "ark-ff", - "ark-pallas", "ark-poly", - "ark-poly-commit", "ark-serialize", "ark-std", "bincode", "blake2", "blake2b_simd", "borsh", - "chacha20poly1305", "criterion", - "curve25519-dalek", "digest", "ed25519-dalek", "either", - "ff 0.8.0", + "ferveo-common", "group-threshold-cryptography", "hex", "itertools 0.10.1", "measure_time", "miracl_core", "num", + "pprof", "rand 0.7.3", "rand 0.8.4", - "rand_chacha 0.3.1", - "redjubjub", "serde", "serde_bytes", "serde_json", - "sha2", "subtle", - "x25519-dalek", + "tendermint", "zeroize", ] [[package]] -name = "ff" -version = "0.8.0" +name = "ferveo-common" +version = "0.1.0" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-serialize", + "ark-std", + "bincode", + "serde", + "serde_bytes", + "serde_json", +] + +[[package]] +name = "futures" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" dependencies = [ - "bitvec 0.18.5", - "rand_core 0.5.1", - "subtle", + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", ] [[package]] -name = "ff" -version = "0.9.0" +name = "futures-channel" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a4d941a5b7c2a75222e2d44fcdf634a67133d9db31e177ae5ff6ecda852bfe" +checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ - "bitvec 0.20.4", - "rand_core 0.6.3", - "subtle", + "futures-core", + "futures-sink", ] [[package]] -name = "funty" -version = "1.1.0" +name = "futures-core" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" + +[[package]] +name = "futures-executor" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" + +[[package]] +name = "futures-macro" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +dependencies = [ + "autocfg", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" + +[[package]] +name = "futures-task" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" + +[[package]] +name = "futures-util" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" +dependencies = [ + "autocfg", + "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" @@ -769,9 +807,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ "cfg-if", "libc", @@ -779,16 +817,10 @@ dependencies = [ ] [[package]] -name = "group" -version = "0.9.0" +name = "gimli" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3c1e8b4f1ca07e6605ea1be903a5f6956aec5c8a67fd44d56076631675ed8" -dependencies = [ - "byteorder", - "ff 0.9.0", - "rand_core 0.6.3", - "subtle", -] +checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" [[package]] name = "group-threshold-cryptography" @@ -803,6 +835,7 @@ dependencies = [ "ark-std", "blake2b_simd", "chacha20", + "criterion", "hex", "itertools 0.10.1", "miracl_core", @@ -833,14 +866,14 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ - "ahash 0.7.2", + "ahash 0.7.4", ] [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] @@ -851,6 +884,43 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown 0.11.2", +] + +[[package]] +name = "inferno" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa5bd9a10b38bf5f3c670f9d75c194adbecd2b1573f737668ab8599f41edc87" +dependencies = [ + "ahash 0.7.4", + "atty", + "indexmap", + "itoa", + "lazy_static", + "log", + "num-format", + "quick-xml", + "rgb", + "str_stack", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if", +] + [[package]] name = "itertools" version = "0.9.0" @@ -871,36 +941,22 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "js-sys" -version = "0.3.50" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" +checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" dependencies = [ "wasm-bindgen", ] [[package]] -name = "jubjub" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d7e7fef85ae7b26dd89f34175b7f3c5ace64067a110c2ac86cf92407a6666ca" -dependencies = [ - "bitvec 0.20.4", - "bls12_381", - "ff 0.9.0", - "group", - "rand_core 0.6.3", - "subtle", -] - -[[package]] -name = "keccak" -version = "0.1.0" +name = "keccak" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" @@ -912,9 +968,18 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.98" +version = "0.2.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a5ac8f984bfcf3a823267e5fde638acc3325f6496633a5da6bb6eb2171e103" + +[[package]] +name = "lock_api" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +checksum = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" +dependencies = [ + "scopeguard", +] [[package]] name = "log" @@ -936,15 +1001,25 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] [[package]] name = "memoffset" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" dependencies = [ "autocfg", ] @@ -961,12 +1036,41 @@ dependencies = [ "zeroize", ] +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "miracl_core" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94c7128ba23c81f6471141b90f17654f89ef44a56e14b8a4dd0fddfccd655277" +[[package]] +name = "nix" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8e5e343312e7fbeb2a52139114e9e702991ef9c2aea6817ff2440b35647d56" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + [[package]] name = "num" version = "0.4.0" @@ -983,9 +1087,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512" +checksum = "74e768dff5fb39a41b3bcd30bb25cf989706c90d028d1ad71971987aa309d535" dependencies = [ "autocfg", "num-integer", @@ -1001,6 +1105,27 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-derive" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1053,11 +1178,20 @@ dependencies = [ "libc", ] +[[package]] +name = "object" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" [[package]] name = "oorandom" @@ -1071,6 +1205,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + [[package]] name = "paste" version = "1.0.5" @@ -1092,11 +1251,17 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + [[package]] name = "plotters" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" +checksum = "32a3fd9ec30b9749ce28cd91f255d569591cdf937fe280c312143e3c4bad6f2a" dependencies = [ "num-traits", "plotters-backend", @@ -1107,28 +1272,36 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" +checksum = "d88417318da0eaf0fdcdb51a0ee6c3bed624333bff8f946733049380be67ac1c" [[package]] name = "plotters-svg" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +checksum = "521fa9638fa597e1dc53e9412a4f9cefb01187ee1f7413076f9e6749e2885ba9" dependencies = [ "plotters-backend", ] [[package]] -name = "poly1305" -version = "0.7.0" +name = "pprof" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe800695325da85083cd23b56826fccb2e2dc29b218e7811a6f33bc93f414be" +checksum = "c9fb4eee2f2c4f7d48fe5a33008dececbc405d0e58d2a94afe742d4f175bc401" dependencies = [ - "cpufeatures", - "opaque-debug", - "universal-hash", + "backtrace", + "criterion", + "inferno", + "lazy_static", + "libc", + "log", + "nix", + "parking_lot", + "symbolic-demangle", + "tempfile", + "thiserror", ] [[package]] @@ -1146,35 +1319,77 @@ dependencies = [ "toml", ] +[[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.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" dependencies = [ "unicode-xid", ] [[package]] -name = "quote" -version = "1.0.9" +name = "prost" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "169a15f3008ecb5160cba7d37bcd690a7601b6d30cfb87a117d45e59d52af5d4" +dependencies = [ + "anyhow", + "itertools 0.9.0", "proc-macro2", + "quote", + "syn", ] [[package]] -name = "radium" -version = "0.3.0" +name = "prost-types" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" +checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" +dependencies = [ + "bytes", + "prost", +] [[package]] -name = "radium" -version = "0.6.2" +name = "quick-xml" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" +checksum = "8533f14c8382aaad0d592c812ac3b826162128b65662331e1127b45c3d18536b" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] [[package]] name = "rand" @@ -1236,7 +1451,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.2", + "getrandom 0.2.3", ] [[package]] @@ -1259,9 +1474,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg", "crossbeam-deque", @@ -1271,9 +1486,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel", "crossbeam-deque", @@ -1283,55 +1498,59 @@ dependencies = [ ] [[package]] -name = "redjubjub" -version = "0.4.0" +name = "redox_syscall" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dcf30702f15c157e348b4ccef28b1224fc7da8f8430d553bdc47b2d6599107b" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ - "blake2b_simd", - "byteorder", - "digest", - "funty", - "jubjub", - "rand_core 0.6.3", - "serde", - "thiserror", - "zeroize", + "bitflags", ] [[package]] name = "regex" -version = "1.4.5" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "regex-syntax", ] [[package]] name = "regex-automata" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" -dependencies = [ - "byteorder", -] +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi", +] + +[[package]] +name = "rgb" +version = "0.8.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0" dependencies = [ - "semver 0.9.0", + "bytemuck", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc_version" version = "0.3.3" @@ -1341,6 +1560,15 @@ dependencies = [ "semver 0.11.0", ] +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.4", +] + [[package]] name = "ryu" version = "1.0.5" @@ -1362,29 +1590,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser 0.7.0", -] - [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ - "semver-parser 0.10.2", + "semver-parser", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "semver" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" [[package]] name = "semver-parser" @@ -1397,9 +1616,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.125" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" dependencies = [ "serde_derive", ] @@ -1415,9 +1634,9 @@ dependencies = [ [[package]] name = "serde_cbor" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ "half", "serde", @@ -1425,9 +1644,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b" dependencies = [ "proc-macro2", "quote", @@ -1436,24 +1655,35 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "sha2" -version = "0.9.3" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ "block-buffer", "cfg-if", - "cpuid-bool", + "cpufeatures", "digest", "opaque-debug", ] @@ -1464,17 +1694,73 @@ version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335" +[[package]] +name = "slab" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + [[package]] name = "subtle" -version = "2.4.0" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "subtle-encoding" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dcb1ed7b8330c5eed5441052651dd7a12c75e2ed88f2ec024ae1fa3a5e59945" +dependencies = [ + "zeroize", +] + +[[package]] +name = "symbolic-common" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348885c332e7d0784d661844b13b198464144a5ebcd3bfc047a6c441867ea467" +dependencies = [ + "debugid", + "memmap", + "stable_deref_trait", + "uuid", +] + +[[package]] +name = "symbolic-demangle" +version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" +checksum = "6780c62bfbd609bffaa13d6959715850578aa43caaae7aee14f1f24ceb64f433" +dependencies = [ + "cpp_demangle", + "rustc-demangle", + "symbolic-common", +] [[package]] name = "syn" -version = "1.0.69" +version = "1.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" +checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" dependencies = [ "proc-macro2", "quote", @@ -1483,9 +1769,9 @@ dependencies = [ [[package]] name = "synstructure" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +checksum = "474aaa926faa1603c40b7885a9eaea29b444d1cb2850cb7c0e37bb1a4182f4fa" dependencies = [ "proc-macro2", "quote", @@ -1494,10 +1780,66 @@ dependencies = [ ] [[package]] -name = "tap" -version = "1.0.1" +name = "tempfile" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "tendermint" +version = "0.18.0" +source = "git+https://github.com/heliaxdev/tendermint-rs#1a6629046035e5e504f3609725a93b35cf0eab1b" +dependencies = [ + "anomaly", + "async-trait", + "bytes", + "chrono", + "ed25519", + "ed25519-dalek", + "futures", + "num-traits", + "once_cell", + "prost", + "prost-types", + "serde", + "serde_bytes", + "serde_json", + "serde_repr", + "sha2", + "signature", + "subtle", + "subtle-encoding", + "tendermint-proto", + "thiserror", + "toml", + "zeroize", +] + +[[package]] +name = "tendermint-proto" +version = "0.18.0" +source = "git+https://github.com/heliaxdev/tendermint-rs#1a6629046035e5e504f3609725a93b35cf0eab1b" +dependencies = [ + "anomaly", + "bytes", + "chrono", + "num-derive", + "num-traits", + "prost", + "prost-types", + "serde", + "serde_bytes", + "subtle-encoding", + "thiserror", +] [[package]] name = "textwrap" @@ -1510,24 +1852,34 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.26" +version = "1.0.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" dependencies = [ "proc-macro2", "quote", "syn", ] +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "tinytemplate" version = "1.2.1" @@ -1547,52 +1899,11 @@ dependencies = [ "serde", ] -[[package]] -name = "tracing" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab69019741fca4d98be3c62d2b75254528b5432233fd8a4d2739fec20278de48" -dependencies = [ - "tracing-core", -] - [[package]] name = "typenum" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec" [[package]] name = "ucd-trie" @@ -1602,25 +1913,21 @@ checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" [[package]] name = "unicode-width" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] -name = "universal-hash" -version = "0.4.0" +name = "uuid" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" -dependencies = [ - "generic-array", - "subtle", -] +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" [[package]] name = "version_check" @@ -1653,9 +1960,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.73" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1663,9 +1970,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.73" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" dependencies = [ "bumpalo", "lazy_static", @@ -1678,9 +1985,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.73" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1688,9 +1995,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.73" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" dependencies = [ "proc-macro2", "quote", @@ -1701,15 +2008,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.73" +version = "0.2.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" +checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" [[package]] name = "web-sys" -version = "0.3.50" +version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" dependencies = [ "js-sys", "wasm-bindgen", @@ -1746,38 +2053,20 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "wyz" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" - -[[package]] -name = "x25519-dalek" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" -dependencies = [ - "curve25519-dalek", - "rand_core 0.5.1", - "serde", - "zeroize", -] - [[package]] name = "zeroize" -version = "1.2.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a974bcdd357f0dca4d41677db03436324d45a4c9ed2d0b873a5a360ce41c36" +checksum = "bf68b08513768deaa790264a7fac27a58cbf2705cfcdc9448362229217d7e970" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.0.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3f369ddb18862aba61aa49bf31e74d29f0f162dec753063200e1dc084345d16" +checksum = "bdff2024a851a322b08f179173ae2ba620445aef1e838f0c196820eade4ae0c7" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0247a2e9..891e26a0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,97 +1,23 @@ -[package] -name = "ferveo" -version = "0.1.0" -edition = "2018" -license = "AGPL-3.0" -repository = "https://gitlab.com/metastatedev/ferveo" -readme = "README.md" -description = "An implementation of a DKG protocol for front-running protection on public blockchains." -keywords = ["DKG"] -categories = ["cryptography"] -authors = ["Heliax AG "] +[workspace] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ark-poly-commit = "0.3" -ark-std = "0.3" -ark-pallas = "0.3" -ark-bls12-381 = "0.3" -ark-ec = "0.3" -ark-ff = "0.3" -ark-serialize = "0.3" -ark-poly = "0.3" -rand = "0.8" -rand_old = { package = "rand", version = "0.7" } -either = "1.6.1" -ff = "0.8" -hex = "0.4.2" -miracl_core = "2.3.0" -num = "0.4" -sha2 = "0.9.1" -ed25519-dalek = { version = "1", features = ["serde", "batch"] } -x25519-dalek = { version = "1.1", features = ["serde"] } -curve25519-dalek = { version = "3.0", features = ["serde"] } -serde = { version = "1.0", features = ["derive"] } -blake2 = "0.9.1" -rand_chacha = "0.3.0" -blake2b_simd = "0.5.11" -zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] } -chacha20poly1305 = "0.8" -serde_bytes = { version = "0.11" } -bincode = "1.3" -anyhow = "1.0" -serde_json = "1.0" -borsh = "0.9" -subtle = "2.4" -itertools = "0.10.1" -measure_time = "0.7" -redjubjub = "0.4.0" -ark-ed-on-bls12-381 = "0.3.0" -group-threshold-cryptography = {path = "./tpke/"} - -[dependencies.digest] -version = "0.9.0" -features = ["alloc"] - -[dev-dependencies] -criterion = "=0.3.4" -pprof = { version = "0.4", features = ["flamegraph", "criterion"] } - -# local override for bls12-381 -#[patch.crates-io] -#bls12_381 = { git = 'https://github.com/A-Manning/bls12_381.git', branch = "ash/scalar-traits" } +members = [ + "ferveo", + "ferveo-common", + "tpke" +] [profile.bench] opt-level = 3 debug = true +lto = true +codegen-units = 1 # Optimizations are needed such that the tests run in a reasonable timeframe -#[profile.test] -#opt-level = 3 - -[profile.release] +[profile.test] +opt-level = 3 debug = true -#[[bench]] -#name = "benchmarks" -#harness = false -#debug = true - -[[example]] -name = "pvdkg" +[profile.release] debug = true - -#[[bench]] -#name = "pairing" -#harness = false -#debug = false - -#[[bench]] -#name = "bench_main" -#harness = false - -[[bench]] -name = "pvdkg" -path = "benches/benchmarks/pvdkg.rs" -harness = false +lto = true +codegen-units = 1 diff --git a/benches/benchmarks/pvdkg.rs b/benches/benchmarks/pvdkg.rs deleted file mode 100644 index 7782b2b6..00000000 --- a/benches/benchmarks/pvdkg.rs +++ /dev/null @@ -1,120 +0,0 @@ -use criterion::{criterion_group, criterion_main, Criterion}; -use ferveo::*; - -pub fn dkgs(c: &mut Criterion) { - // use a fixed seed for reproducability - use rand::SeedableRng; - let mut rng = rand::rngs::StdRng::seed_from_u64(0); - - let mut group = c.benchmark_group("compare DKGs with 8192 shares"); - group.sample_size(10); - - //Benchmarking compare DKGs with 8192 shares/Pedersen Pallas: Collecting 10 sample compare DKGs with 8192 shares/Pedersen Pallas - //time: [95.895 s 97.154 s 98.507 s] - /*group.bench_function("Pedersen Pallas", |b| { - b.iter(|| pedersen::()) - }); - group.measurement_time(core::time::Duration::new(30, 0));*/ - // Benchmarking compare DKGs with 8192 shares/Pedersen BLS12-381: Collecting 10 sam compare DKGs with 8192 shares/Pedersen BLS12-381 - //time: [177.12 s 178.73 s 180.47 s] - /*group.bench_function("Pedersen BLS12-381", |b| { - b.iter(|| pedersen::()) - });*/ - // 2130.7 seconds per iteration to verify pairwise - group.measurement_time(core::time::Duration::new(60, 0)); - group.bench_function("PVDKG BLS12-381", |b| { - b.iter(|| pvdkg::()) - }); -} - -use pprof::criterion::{Output, PProfProfiler}; - -criterion_group!{ - name = pvdkg_bls; - config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); - targets = dkgs -} - -criterion_main!(pvdkg_bls); - -pub fn pvdkg() { - use ark_ec::{AffineCurve, ProjectiveCurve}; - let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); - - let params = Params { - tau: 0u64, - security_threshold: 300 / 3, - total_weight: 300, - }; - - for _ in 0..1 { - let mut contexts = vec![]; - for _ in 0..10 { - contexts.push( - PubliclyVerifiableDKG::::new( - ed25519_dalek::Keypair::generate(ed_rng), - params.clone(), - rng, - ) - .unwrap(), - ); - } - use std::collections::VecDeque; - let mut messages = VecDeque::new(); - - let stake = (0..150u64).map(|i| i).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec>, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); - - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); - - let mut dealt_weight = 0u32; - let mut pvss = vec![]; - for participant in contexts.iter_mut() { - if dealt_weight < params.total_weight - params.security_threshold { - let msg = participant.share(rng).unwrap(); - let msg: PubliclyVerifiableMessage = msg; //.verify().unwrap().1; - pvss.push((participant.ed_key.public.clone(), msg)); - //messages.push_back(msg); - dealt_weight += participant.participants[participant.me].weight; - } - } - for msg in pvss.iter() { - for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); - } - } - msg_loop(&mut contexts, &mut messages); - - contexts[0].final_key(); - } -} diff --git a/book/src/dkg.md b/book/src/dkg.md index 6f3b62bf..e8e92ea9 100644 --- a/book/src/dkg.md +++ b/book/src/dkg.md @@ -14,21 +14,22 @@ Some Publicly Verifiable DKG schemes, such as Groth21, produce field private key In addition to the two independent generators \\(G \in \mathbb{G}_1\\) and \\(H \in \mathbb{G}_2\\), a third independent generator \\(\hat{u}_1 \in \mathbb{G}_2\\) is selected. -## Session keys +## Epoch keys -Each validator \\(i\\) generates a **session keypair** for the lifetime of the DKG: a decryption key \\(dk_i \in \mathbb{F}_r\\), and a signing key \\(sk_i\in \mathbb{F}_r \\). - -The signing key is used for a signature of knowledge in the DKG and is independent of the Ed25519 identity used for signing messages in the protocol. - -The public session keypair consists of an **encryption key** \\(ek_i \in \mathbb{G}_2\\) and a verification key \\(sk_i \in \mathbb{G}_1\\): +Each validator \\(i\\) generates a **epoch keypair**: a private decryption key \\(dk_i \in \mathbb{F}_r\\), and a public encryption key \\(ek_i\in \mathbb{G}_2 \\). The encryption key is derived from the decryption key: \\[ek_i = [dk_i] H \\] -\\[vk_i = [sk_i] G \\] + +Each validator is required to generate an epoch keypair at genesis, or upon joining the validator set. Each validator should generate and announce a new epoch public key once per epoch, but in the event that a validator does not announce a new epoch public key during an epoch, the last announced epoch public key should be used in the DKG. For this reason, each validator should persist their latest epoch private key on disk. ## Publicly Verifiable Secret Sharing -The validators, in decreasing order of number of key shares, each act as a dealer for exactly one PVSS instance until at least 2/3 by weight of key shares have successfully posted a verified correct PVSS instance to the blockchain. In case a dealer's PVSS instance does not verify as correct, that instance is discarded (and penalties may be imposed) and additional validators act as dealers until the 2/3 threshold is reached. +The validators should each generate exactly one PVSS instance as a dealer, and include that instance as a VoteExtension to a specially designated DKG block. The next block proposer is responsible for verifying and aggregating at least 2/3 by weight of PVSS instances, and including the aggregation in the next block. + +For performance reasons, the aggregating validator may sort the PVSS instances by decreasing validator weight, and only include sufficient instances to reach the necessary 2/3 total weight. PVSS instances above the 2/3 weight threshold are ignored. + +In case a dealer's PVSS instance does not verify as correct, that instance is discarded (and penalties may be imposed). ## Output -Once 2/3 by weight of dealers have posted correct PVSS instances, all of the correct instances are aggregated into a single PVSS instance. The commitment to the constant term of the aggregated PVSS instance, \\(F_0\\), is the public key output \\(Y\\) from the PVDKG, and each validators aggregated private key shares \\(Z_{i,\omega_j} \\) are the private key shares associated with \\(Y\\) \ No newline at end of file +Once 2/3 by weight of correct PVSS instances have been aggregated into a single PVSS instance, the commitment to the constant term of the aggregated PVSS instance, \\(F_0\\), is the public key output \\(Y\\) from the PVDKG, and each validators aggregated private key shares \\(Z_{i,\omega_j} \\) are the private key shares associated with \\(Y\\) \ No newline at end of file diff --git a/book/src/tpke-concrete.md b/book/src/tpke-concrete.md index d8cadf5a..cc48bb8d 100644 --- a/book/src/tpke-concrete.md +++ b/book/src/tpke-concrete.md @@ -6,23 +6,49 @@ There are optimizations that can be done to increase decryption throughput when The DKG and TPKE schemes support the following key operations: -* `DKG.KeyGen(tau, total_weight, {(s_i, ek_i)})` -* `DKG.Announce() -> (ek, dk)` -* `DKG.PartitionDomain() ` -* `DKG.Share` -* `TPKE.Blind(Z_i)` inputs a validators private key shares and outputs a -* `TPKE.VerifyBlinding()` +* `DKG.GenerateEpochKeypair() -> (ek, dk)` +* `DKG.PartitionDomain({ek_i, s_i}) -> {(ek_i, Omega_i)} ` +* `DKG.GeneratePVSS(tau, total_weight, {(s_i, ek_i)})` +* `DKG.VerifyPVSS(tau, PVSS) -> bool` +* `DKG.AggregatePVSS({PVSS_i}) -> PVSS` +* `DKG.VerifyAggregatedPVSS({PVSS_i}, PVSS) -> bool` And supports the following ciphertext operations: -* `TPKE.Encrypt(Y)` inputs a public threshold key \\(Y\\) and outputs a random ciphertext \\((U,W)\\) encrypted to that public key +* `TPKE.Encrypt(Y, aad)` inputs a public threshold key \\(Y\\) and outputs a random ciphertext \\((U,W)\\) encrypted to that public key * `TPKE.CiphertextValidity(U,W)` tests if $\\((U,W)\\) is a valid ciphertext -* `TPKE.CreateDecryptionShare()` -* `TPKE.VerifyDecryptionShares` -* `TPKE.BatchVerifyDecryptionShares` -* `TPKE.CombineDecryptionShares` combines decryption shares +* `TPKE.CreateDecryptionShare(dk_j, U_i,W_i) -> D_{i,j}` +* `TPKE.VerifyDecryptionShares(ek_i, { U_j }, { D_{i,j} }) -> bool` +* `TPKE.BatchVerifyDecryptionShares({ek_i}, { U_j }, { D_{i,j} }) -> bool` +* `TPKE.CombineDecryptionShares( {U_j}, {D_{i,j}) -> {S_j}` combines decryption shares * `TPKE.VerifyCombination` verifies a combination for many -* `TPKE.DeriveSymmetricKey` +* `TPKE.DeriveSymmetricKey(S_j) -> k_j` + +## `DKG.GenerateEpochKeypair() -> (ek, dk)` + +Choose a uniformly random scalar \\(dk \in \mathbb{F}_r \\) and compute \\( ek = [dk] H \\) + +## `DKG.PartitionDomain({ek_i, s_i}) -> {(ek_i, Omega_i)}` + +## `DKG.GeneratePVSS(tau, total_weight, {(ek_i, Omega_i)}) -> PVSS` + +1. Choose a uniformly random polynomial \\(f(x) = \sum^p_i a_i x^i \\) of degree \\(t\\). +2. Let \\(F_0, \ldots, F_t \leftarrow = [a_0] G, \ldots, [a_t] G \\) +3. For each validator \\(i\\), for each \\(\omega_j \in \Omega_i\\), encrypt the evaluation \\( Z_{i, \omega_j} \leftarrow [f(\omega_j)] ek_i \\) +4. \\(\sigma = [a_0] H_{\mathbb{G}_2}(tau,F_0) \\) + +Output PVSS = \\( ((F_0, sigma), (F_1, ldots, F_t), {Z_{i,\omega_j}}) \\) + +## `DKG.VerifyPVSS(tau, PVSS) -> bool` + +0. Decode \\( ((F_0, sigma), (F_1, ldots, F_t), {Z_{i,\omega_j}}) \leftarrow \\) PVSS +1. Compute by FFT \\(A_1, \ldots, A_W \leftarrow \operatorname{FFT}(F_0, \ldots, F_t) \\) +2. Compute \\(W\\) random scalars \\(\alpha_i \\) +3. Check \\(\mathcal{O} = \prod_i e(-G_1, Z_{i,\omega_j})e(A_{i,\omega_j}, ek_i) \\) + +## `DKG.AggregatePVSS({PVSS_i}) -> PVSS` + +## `DKG.VerifyAggregatedPVSS({PVSS_i}, PVSS) -> bool` ## Lagrange Coefficients @@ -30,7 +56,11 @@ Given a validator subset \\(\{i\}\\), the Lagrange coefficients \\(\lambda_{\ome Total cost: \\( O(p \log p) \\) -## `TPKE.Encrypt(Y)` +## `DKG.GenerateEpochKeypair() -> (ek, dk)` + +The validator generates a random scalar \\(dk \in \mathbb{F}_r \\) and computes the public key \\( ek = [dk] H \\) + +## `TPKE.Encrypt(Y, aad) -> (U,W)` `TPKE.Encrypt(Y, aad)` creates a new, random ciphertext \\((U,W)\\) encrypted to the public key \\(Y\\), and a corresponding ephemeral shared secret \\(S\\) such that the private key associated with \\(Y\\) can efficiently compute \\(S\\) from the ciphertext \\((U,W)\\). Additional authenticated data `aad` may be attached to the ciphertext. @@ -43,29 +73,7 @@ The ephemeral shared secret \\(S\\) can be used to derive a shared symmetric enc Then \\((U,W)\\) is the ciphertext and \\(S\\) is the ephemeral shared secret. -## `TPKE.Blind` - -On input private key shares \\( Z_{i, \omega_j} \\), generate a random scalar \\(b\\) and output - -\\[ B_{i, \omega_j} = [b] Z_{i, \omega_j} \\] - -\\[ P_i = [b] H \\] - -Total cost: -* 1 \\(\mathbb{G}_1\\) multiply per key share -* 1 \\(\mathbb{G}_1\\) multiply - -## `TPKE.VerifyBlinding()` - -On input \\([b_i] Z_{i_\omega}\\) and \\([b_i] H \\) - -\\[ e(A_i + [\alpha] G, [b_i] H) = e(G, [b_i]Z_i + [\alpha * b] H) \\] - -Total cost: -* 1 `G2Prepared` per key share -* 1 `G2Prepared` per validator - -## `TPKE.CiphertextValidity(U,W)` +## `TPKE.CiphertextValidity(U,W) -> bool` To provide chosen ciphertext security, ciphertext validity must be checked for each ciphertext \\((U,W)\\) separately. The ciphertext can be checked by: @@ -74,8 +82,9 @@ To provide chosen ciphertext security, ciphertext validity must be checked for e Total cost: * 1 \\(\mathbb{G}_1\\) and 1 \\(\mathbb{G}_2\\) deserialize per ciphertext * 1 product of pairings -* -## `TPKE.BatchCiphertextValidity( {U,W} )` + + +## `TPKE.BatchCiphertextValidity( {U,W} ) -> bool` Once a block proposer has verified ciphertext validity, the entire block can be optimistically verified: @@ -85,37 +94,35 @@ Total cost: * 1 \\(\mathbb{G}_1\\) and 1 \\(\mathbb{G}_2\\) deserialize per ciphertext * 1 product of pairings -## `TPKE.CreateDecryptionShare` - -\\[D_{i,j} = [b_i^{-1}] U_j\\] +## `TPKE.CreateDecryptionShare(dk_i, U_j) -> D_{i,j}` +\\[D_{i,j} = [dk_i^{-1}] U_j\\] -## `TPKE.VerifyDecryptionShares` +## `TPKE.VerifyDecryptionShares(ek_i, { U_j }, { D_{i,j} }) -> bool` -Given many valid ciphertexts \\((U_j,W_j)\\), on input potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\) from a single validator \\(i\\) with blinded public key \\(B_i\\), the validity of those shares can be checked by: +Given many valid ciphertexts \\((U_j,W_j)\\), on input potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\) from a single validator \\(i\\) with epoch public key \\(ek_i\\), the validity of those shares can be checked by: -\\[D_{i,j} = [b_i^{-1}] U_j\\] -\\[P_i = [b_i] H \\] +\\[D_{i,j} = [dk_i^{-1}] U_j\\] -\\[ e(\sum_j [\alpha_j] D_{i,j}, P_i) = e(\sum_j [\alpha_j] U_j, H) \\] +\\[ e(\sum_j [\alpha_j] D_{i,j}, ek_i) = e(\sum_j [\alpha_j] U_j, H) \\] Total cost: * 1 \\(\mathbb{G}_1\\) deserialize per validator per ciphertext * 2 pairings per validator * 1 \\(\mathbb{G}_1\\) multiply and 1 \\(\mathbb{G}_2\\) multiply per ciphertext. -## `TPKE.BatchVerifyDecryptionShares` +## `TPKE.BatchVerifyDecryptionShares({ek_i}, { U_j }, { D_{i,j} }) -> bool` -Given many valid ciphertexts \\((U_j,W_j)\\), on input 2/3 weight of potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\), corresponding to validator set \\(\{i\}\\) with blinded public keys \\(B_i\\), the validity of those shares can be checked: +Given many valid ciphertexts \\((U_j,W_j)\\), on input 2/3 weight of potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\), corresponding to validator set \\(\{i\}\\) with epoch public keys \\(ek_i\\), the validity of those shares can be checked: -\\[ \prod_i e(\sum_{j} [\alpha_{i,j}] D_{i,j}, P_i) = e([\sum_{i,j} \alpha_{i,j}] U_j, H) \\] +\\[ \prod_i e(\sum_{j} [\alpha_{i,j}] D_{i,j}, ek_i) = e([\sum_{i,j} \alpha_{i,j}] U_j, H) \\] Total cost: * 1 G1 deserialize per validator * V+1 pairings * 1 \\(\mathbb{G}_1\\) multiply and 1 \\(\mathbb{G}_2\\) multiply, per ciphertext. -## `TPKE.AggregateDecryptionShares` +## `TPKE.AggregateDecryptionShares( {U_j}, {D_{i,j}} ) -> {\hat{D}_i} ` Given many valid ciphertexts \\((U_j,W_j)\\), on input 2/3 weight of potential decryption shares for each ciphertext \\(\{D_{i,j}\}\\) sharing the same validator set, if decryption shares are only needed to check the validity of the decryption process, the decryption shares of many ciphertexts can be aggregated into one decryption share set. @@ -128,7 +135,7 @@ which can be used to compute the aggregated decryption share for validator \\(i\ \\[\hat{D}_i = \sum_j \rho_j D_{i,j} \\] -## `TPKE.VerifyAggregatedDecryptionShares` +## `TPKE.VerifyAggregatedDecryptionShares({U_j}, {\hat{D}_i}) -> bool` Given many valid ciphertexts \\((U_j,W_j)\\) and an aggregated decryption share set for those ciphertexts, the validity of the aggregation can be checked by computing the publicly known coefficients: \\[ \rho_j = H(U_1, \ldots, U_k, j) \\] @@ -137,14 +144,13 @@ and checking the pairing equation: \\[ \prod_i e(\sum_{j} [\rho_i] \hat{D}_{i}, P_i) = e([\sum_{i,j} \rho_i] U_j, H) \\] - -## `TPKE.CombineDecryptionShares()` +## `TPKE.CombineDecryptionShares( {U_j}, {D_{i,j}) -> {S_j}` For a given ciphertext \\((U_j,W_j)\\), on input 2/3 weight of valid decryption shares \\(\{D_{i,j}\}\\) as checked by ``TPKE.VerifyDecryptionShares`, corresponding to validator set \\(\{i\}\\). Then a partial combined share \\(S_{i,j}\\) for that ciphertext can be computed with one pairing: -\\[ S_{i,j} = e( D_{i,j}, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] [b] Z_{i,\omega_j} ) \\] +\\[ S_{i,j} = e( D_{i,j}, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] Z_{i,\omega_j} ) \\] and combined to get the final combined share \\(S_j = \prod_i S_{i,j}\\). @@ -163,7 +169,7 @@ computed using unknown \\(D_{i,j}\\) but with the publicly known coefficients: can be used to compute an aggregated partial combined share \\(\hat{S}_i \\): -\\[ \hat{S}_i = e( \hat{D}_i, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] [b] Z_{i,\omega_j} ) \\] +\\[ \hat{S}_i = e( \hat{D}_i, [\sum_{\omega_j \in \Omega_i} \lambda_{\omega_j}(0)] Z_{i,\omega_j} ) \\] and combined to get an aggregated final combined share \\( \hat{S} = \prod_i \hat{S}_i\\) which can be checked against the computed \\(\{S_j\}\\) by: @@ -172,3 +178,7 @@ and combined to get an aggregated final combined share \\( \hat{S} = \prod_i \ha Total cost: * 1 pairing and 1 \\(\mathbb{G}_T\\) multiply per validator * 1 \\(\mathbb{G}_1\\) multiply and 1 \\(\mathbb{G}_T\\) multiply per ciphertext. + +## `TPKE.DeriveSymmetricKey(S_j) -> k_j` + +Use HKDF(S_j) \ No newline at end of file diff --git a/book/src/tpke.md b/book/src/tpke.md index 88f63430..519838d4 100644 --- a/book/src/tpke.md +++ b/book/src/tpke.md @@ -4,7 +4,7 @@ Based on [A Simple and Efficient Threshold Cryptosystem from the Gap Diffie-Hell ## Overview -The threshold encryption scheme allows the encrypter to derive a **shared secret** \\(s\\) from the threshold public key \\(Y\\), such that sufficient threshold of validators holding private key shares \\(Z_i\\) associated with \\(Y\\) can also derive the shared secret. Both encrypter and decrypter can use the shared secret to derive a ChaCha20 symmetric key via HKDF. +The threshold encryption scheme allows the encrypter to derive a **shared secret** \\(s\\) from the threshold public key \\(Y\\), such that sufficient threshold of validators holding private key shares \\(Z_i\\) associated with \\(Y\\) can also derive the shared secret. Both encrypter and decrypter use the shared secret to derive a symmetric key for a key-committing AEAD via HKDF. ### To encrypt @@ -31,7 +31,6 @@ Check that \\(e(U, H_{\mathbb{G}_2} (U))= e(G, W)\\) for ciphertext validity. 2. Each decryption share is \\(C_i = e(U, Z_i)\\). 3. To combine decryption shares, s = \\(\prod C_i^{\lambda_i(0)}\\) where \\(\lambda_i(0)\\) is the lagrange coefficient over the appropriate size domain. - ### Threshold Decryption (fast method) Thanks to Kobi Gurkan for this approach. diff --git a/book/src/tx.md b/book/src/tx.md index 7db391c0..ca91c1b8 100644 --- a/book/src/tx.md +++ b/book/src/tx.md @@ -7,26 +7,36 @@ Transactions sent to the mempool should be encrypted to this public key, and blo An encrypted transaction consists of: - The public key ciphertext \\(U, W\\) associated with this transaction -- The ChaCha20 encrypted payload of the transaction, with symmetric key derived from \\(U, W\\) -- A BLAKE2b hash of the transaction payload +- The key-committing AEAD encrypted payload of the transaction, with symmetric key derived from \\(U, W\\) - Transaction fee payment details +- The epoch number that the tx is being encrypted to. The inclusion of fee payment outside of the payload ensures that the network is not saturated with invalid transactions. +The encryption method is then ran roughly as: +1. Sample private key `k`. +2. Compute Ciphertext as `CT = KC_AEAD.Encrypt(key=Hash(k * threshold_pubkey), msg={state machine tx}, additional_data={empty})` +3. Run Threshold Encryption as `TE.Encrypt(private_key=k, threshold_pubkey, ciphertext=ct, additional_data={tx fee details, epoch number})` + ## Block proposal A block proposal, therefore, consists of: 1. Validator-selected encrypted transactions (likely ordered by fee) -2. Combined decryption shares for all transactions in the previous block -3. Decryptions of transactions from the previous block. - -Availability of decryption shares for those transactions is guaranteed by new block finalization rules, and it is the block proposer's responsibility to combine the decryption shares to derive each transaction's symmetric key, and to compute the ChaCha20 decryption of each encrypted transaction's payload. +2. Decryption data for all transactions in the previous block + +Availability of decryption shares for those transactions is guaranteed by new block finalization rules, and it is the block proposer's responsibility to combine the decryption shares to derive each transaction's symmetric key, and to compute the AEAD decryption of each encrypted transaction's payload. + +The decryption data for a tx is oneof (`encryption_private_key`, `list of decryption shares`). For a validly constructed transaction, the decryption shares can be combined to get the symmetric key. The combined share can then be included within the block, and every node can check its validity by correctness of the key-committing AEAD. + +If the tx was invalidly constructed, then all of the constituent decryption shares must get posted on-chain for verifyability.** Constructing a valid block proposal therefore executes 1 `TPKE.CombineDecryptionShares` operation per transaction per block signer in the previous block. Verifying the validity of a block proposal therefore executes 1 `TPKE.VerifyCombination` operation per block signer in the previous block. +** There is an optimization where we only need one list of 'cross-tx combined' decryption shares, for all invalid txs per block. + ## Block finalization In addition to the standard 2/3 weight requirements for block finalization, Ferveo adds an additional requirement: every validator signature on a block must include valid, signed decryption shares corresponsing to that validator, for every encrypted transaction committed to in that block, totaling at least 2/3 weight of decryption shares. diff --git a/examples/noserialize.rs b/examples/noserialize.rs deleted file mode 100644 index 676b4807..00000000 --- a/examples/noserialize.rs +++ /dev/null @@ -1,92 +0,0 @@ -use ferveo::*; - -pub fn main() { - pvdkg::(); -} - -pub fn pvdkg() { - use ark_ec::{AffineCurve, ProjectiveCurve}; - let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); - - let params = Params { - tau: 0u64, - security_threshold: 8192 / 3, - total_weight: 8192, - }; - - for _ in 0..1 { - let mut contexts = vec![]; - for _ in 0..25 { - contexts.push( - PubliclyVerifiableDKG::::new( - ed25519_dalek::Keypair::generate(ed_rng), - params.clone(), - rng, - ) - .unwrap(), - ); - } - use std::collections::VecDeque; - let mut messages = VecDeque::new(); - - let stake = (0..150u64).map(|i| i).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec>, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); - - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); - - let mut dealt_weight = 0u32; - let mut pvss = vec![]; - for participant in contexts.iter_mut() { - if dealt_weight < params.total_weight - params.security_threshold { - let msg = participant.share(rng).unwrap(); - pvss.push((participant.ed_key.public.clone(), msg)); - dealt_weight += participant.participants[participant.me].weight; - } - } - for msg in pvss.iter() { - for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); - } - } - msg_loop(&mut contexts, &mut messages); - let agg = contexts[0].aggregate(); - let agg_signer = contexts[0].ed_key.public.clone(); - for participant in contexts.iter_mut() { - participant - .handle_message(&agg_signer, agg.clone()) - .unwrap(); - //assert_eq!(participant.state, DKGState::Success); - } - contexts[0].final_key(); - } -} diff --git a/examples/pvdkg.rs b/examples/pvdkg.rs deleted file mode 100644 index 7bfd3112..00000000 --- a/examples/pvdkg.rs +++ /dev/null @@ -1,93 +0,0 @@ -use ferveo::*; - -pub fn main() { - pvdkg::(); -} - -pub fn pvdkg() { - use ark_ec::{AffineCurve, ProjectiveCurve}; - let rng = &mut ark_std::test_rng(); - use rand_old::SeedableRng; - let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); - - let params = Params { - tau: 0u64, - security_threshold: 512 / 3, - total_weight: 512, - }; - - for _ in 0..1 { - let mut contexts = vec![]; - for _ in 0..10 { - contexts.push( - PubliclyVerifiableDKG::::new( - ed25519_dalek::Keypair::generate(ed_rng), - params.clone(), - rng, - ) - .unwrap(), - ); - } - use std::collections::VecDeque; - let mut messages = VecDeque::new(); - - let stake = (0..150u64).map(|i| i).collect::>(); - - for (participant, stake) in contexts.iter_mut().zip(stake.iter()) { - let announce = participant.announce(*stake); - messages.push_back(announce); - } - - let msg_loop = - |contexts: &mut Vec>, - messages: &mut VecDeque| loop { - if messages.is_empty() { - break; - } - let signed_message = messages.pop_front().unwrap(); - for node in contexts.iter_mut() { - let (_, message) = signed_message.verify().unwrap(); - let new_msg = node - .handle_message(&signed_message.signer, message) - .unwrap(); - if let Some(new_msg) = new_msg { - messages.push_back(new_msg); - } - } - }; - - msg_loop(&mut contexts, &mut messages); - - for participant in contexts.iter_mut() { - participant.finish_announce().unwrap(); - } - - msg_loop(&mut contexts, &mut messages); - - let mut dealt_weight = 0u32; - let mut pvss = vec![]; - for participant in contexts.iter_mut() { - if dealt_weight < params.total_weight - params.security_threshold { - let msg = participant.share(rng).unwrap(); - pvss.push((participant.ed_key.public.clone(), msg)); - dealt_weight += participant.participants[participant.me].weight; - } - } - for msg in pvss.iter() { - for node in contexts.iter_mut() { - node.handle_message(&msg.0, msg.1.clone()).unwrap(); - } - } - msg_loop(&mut contexts, &mut messages); - let agg = contexts[0].aggregate(); - let agg_signer = contexts[0].ed_key.public.clone(); - for participant in contexts.iter_mut() { - participant - .handle_message(&agg_signer, agg.clone()) - .unwrap(); - //assert_eq!(participant.state, DKGState::Success); - } - - contexts[0].final_key(); - } -} diff --git a/ferveo-common/Cargo.toml b/ferveo-common/Cargo.toml new file mode 100644 index 00000000..ac02996b --- /dev/null +++ b/ferveo-common/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "ferveo-common" +version = "0.1.0" +edition = "2018" +authors = ["Heliax AG "] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ark-std = "0.3" +ark-ec = "0.3" +serde = { version = "1.0", features = ["derive"] } +ark-serialize = "0.3" +serde_bytes = "0.11" + +[dev-dependencies] +ark-bls12-381 = "0.3" +serde_json = "1.0" +bincode = "1.0" \ No newline at end of file diff --git a/ferveo-common/src/keypair.rs b/ferveo-common/src/keypair.rs new file mode 100644 index 00000000..1a344a72 --- /dev/null +++ b/ferveo-common/src/keypair.rs @@ -0,0 +1,55 @@ +use ark_ec::PairingEngine; +use ark_ec::{AffineCurve, ProjectiveCurve}; +use serde::*; + +#[derive(Copy, Clone, Debug)] +pub struct PreparedPublicKey { + pub encryption_key: E::G2Prepared, +} + +impl From> for PreparedPublicKey { + fn from(value: PublicKey) -> Self { + PreparedPublicKey:: { + encryption_key: E::G2Prepared::from(value.encryption_key), + } + } +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct PublicKey { + #[serde(with = "crate::ark_serde")] + pub encryption_key: E::G2Affine, +} + +impl Default for PublicKey { + fn default() -> Self { + Self { + encryption_key: E::G2Affine::prime_subgroup_generator(), + } + } +} + +#[derive(Clone, Copy, PartialEq, Serialize, Deserialize)] +pub struct Keypair { + #[serde(with = "crate::ark_serde")] + pub decryption_key: E::Fr, +} + +impl Keypair { + /// Returns the public session key for the publicly verifiable DKG participant + pub fn public(&self) -> PublicKey { + PublicKey:: { + encryption_key: E::G2Affine::prime_subgroup_generator() + .mul(self.decryption_key) + .into_affine(), + } + } + + /// Creates a new ephemeral session key for participating in the DKG + pub fn new(rng: &mut R) -> Self { + use ark_std::UniformRand; + Self { + decryption_key: E::Fr::rand(rng), + } + } +} diff --git a/src/msg.rs b/ferveo-common/src/lib.rs similarity index 53% rename from src/msg.rs rename to ferveo-common/src/lib.rs index 91876c44..23568eaf 100644 --- a/src/msg.rs +++ b/ferveo-common/src/lib.rs @@ -1,8 +1,20 @@ -use ed25519_dalek as ed25519; -use ed25519_dalek::Signer; +use ark_ec::PairingEngine; + +pub mod keypair; +pub use keypair::*; + +#[derive(Clone, Debug)] +pub struct Validator { + pub key: PublicKey, + pub weight: u32, + pub share_start: usize, + pub share_end: usize, +} + +impl Rng for ark_std::rand::prelude::StdRng {} + +pub trait Rng: ark_std::rand::CryptoRng + ark_std::rand::RngCore {} -use crate::*; -use ark_std::{end_timer, start_timer}; use serde::{Deserialize, Serialize}; pub mod ark_serde { @@ -32,49 +44,16 @@ pub mod ark_serde { } } -impl SignedMessage { - pub fn sign(tau: u64, msg: &M, key: &ed25519::Keypair) -> SignedMessage - where - M: Serialize, - { - print_time!("Signing Message"); - let msg_bytes = bincode::serialize(&(tau, msg)).unwrap(); - let signature = key.sign(&msg_bytes); - SignedMessage { - msg_bytes, - signature, - signer: key.public, - } - } - pub fn verify<'de, M>(&'de self) -> Result<(u64, M)> - where - M: Deserialize<'de>, - { - print_time!("Verifying Message"); - self.signer - .verify_strict(&self.msg_bytes, &self.signature)?; - bincode::deserialize::<'de, _>(&self.msg_bytes).map_err(|e| e.into()) //TODO: handle error - } -} - -#[derive(Serialize, Deserialize, Clone)] -pub struct SignedMessage { - msg_bytes: Vec, - signature: ed25519::Signature, - pub signer: ed25519::PublicKey, -} - #[test] fn test_ark_serde() { - use ark_pallas::Affine; - //use ark_serialize::{CanonicalDeserialize, CanonicalSerialize}; + use ark_bls12_381::G1Affine; #[derive(Serialize, Deserialize)] struct Test { #[serde(with = "ark_serde")] - pub p: Affine, + pub p: G1Affine, } use ark_ec::AffineCurve; - let p = Affine::prime_subgroup_generator(); + let p = G1Affine::prime_subgroup_generator(); let t = Test { p }; let m = serde_json::to_string(&t).unwrap(); let _t2: Test = serde_json::from_str(&m).unwrap(); diff --git a/ferveo/Cargo.lock b/ferveo/Cargo.lock new file mode 100644 index 00000000..6838c84f --- /dev/null +++ b/ferveo/Cargo.lock @@ -0,0 +1,2121 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a2e47a1fbe209ee101dd6d61285226744c6c8d3c21c8dc878ba6cb9f467f3a" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922b33332f54fc0ad13fa3e514601e8d30fb54e1f3eadc36643f6526db645621" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ahash" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" + +[[package]] +name = "ahash" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796540673305a66d127804eef19ad696f1f204b8c1025aaca4958c17eab32877" +dependencies = [ + "getrandom 0.2.2", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957" +dependencies = [ + "getrandom 0.2.2", + "once_cell", + "version_check", +] + +[[package]] +name = "anyhow" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b" + +[[package]] +name = "ark-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65be532f9dd1e98ad0150b037276cde464c6f371059e6dd02c0222395761f6aa" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dea978406c4b1ca13c2db2373b05cc55429c3575b8b21f1b9ee859aa5b03dd42" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "num-traits", + "rayon", + "zeroize", +] + +[[package]] +name = "ark-ed-on-bls12-381" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b7ada17db3854f5994e74e60b18e10e818594935ee7e1d329800c117b32970" +dependencies = [ + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-ff" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b3235cc41ee7a12aaaf2c575a2ad7b46713a8a50bda2fc3b003a04845c05dd6" +dependencies = [ + "ark-ff-asm", + "ark-ff-macros", + "ark-serialize", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "paste", + "rayon", + "rustc_version 0.3.3", + "zeroize", +] + +[[package]] +name = "ark-ff-asm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db02d390bf6643fb404d3d22d31aee1c4bc4459600aef9113833d17e786c6e44" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "ark-ff-macros" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fd794a08ccb318058009eefdf15bcaaaaf6f8161eb3345f907222bac38b20" +dependencies = [ + "num-bigint", + "num-traits", + "quote", + "syn", +] + +[[package]] +name = "ark-nonnative-field" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440ad4569974910adbeb84422b7e622b79e08d27142afd113785b7fcfb446186" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-r1cs-std", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-integer", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-pallas" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e945e1c8d86aa869853944ce6ecf072c2dac623b88c94e68792901b06190e53" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-std", +] + +[[package]] +name = "ark-poly" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b0f78f47537c2f15706db7e98fe64cc1711dbf9def81218194e17239e53e5aa" +dependencies = [ + "ark-ff", + "ark-serialize", + "ark-std", + "derivative", + "hashbrown 0.11.2", + "rayon", +] + +[[package]] +name = "ark-poly-commit" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a71ddfa72bad1446cab7bbecb6018dbbdc9abcbc3a0065483ae5186ad2a64dcd" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-nonnative-field", + "ark-poly", + "ark-relations", + "ark-serialize", + "ark-std", + "derivative", + "digest", + "rayon", + "tracing", +] + +[[package]] +name = "ark-r1cs-std" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e8fdacb1931f238a0d866ced1e916a49d36de832fd8b83dc916b718ae72893" +dependencies = [ + "ark-ec", + "ark-ff", + "ark-relations", + "ark-std", + "derivative", + "num-bigint", + "num-traits", + "tracing", +] + +[[package]] +name = "ark-relations" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cba4c1c99792a6834bd97f7fd76578ec2cd58d2afc5139a17e1d1bec65b38f6" +dependencies = [ + "ark-ff", + "ark-std", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "ark-serialize" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6c2b318ee6e10f8c2853e73a83adc0ccb88995aa978d8a3408d492ab2ee671" +dependencies = [ + "ark-serialize-derive", + "ark-std", + "digest", +] + +[[package]] +name = "ark-serialize-derive" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd4e5f0bf8285d5ed538d27fab7411f3e297908fd93c62195de8bee3f199e82" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ark-std" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1df2c09229cbc5a028b1d70e00fdb2acee28b1055dfb5ca73eea49c5a25c4e7c" +dependencies = [ + "num-traits", + "rand 0.8.4", + "rayon", +] + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd9fd44efafa8690358b7408d253adf110036b88f55672a933f01d616ad9b1b9" +dependencies = [ + "nodrop", +] + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[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.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bitvec" +version = "0.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fcd36dda4e17b7d7abc64cb549bf0201f4ab71e00700c798ca7e62ed3761fa" +dependencies = [ + "funty", + "radium 0.3.0", + "wyz", +] + +[[package]] +name = "bitvec" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" +dependencies = [ + "funty", + "radium 0.6.2", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a5720225ef5daecf08657f23791354e1685a8c91a4c60c7f3d3b2892f978f4" +dependencies = [ + "crypto-mac", + "digest", + "opaque-debug", +] + +[[package]] +name = "blake2b_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bls12_381" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c56609cc42c628848e7b18e0baf42a4ef626b8c50442dc08b8094bd21d8ad32" +dependencies = [ + "ff 0.9.0", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "borsh" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fcabb02816fdadf90866dc9a7824491ccb63d69f55375a266dc03509ac68d36" +dependencies = [ + "borsh-derive", + "hashbrown 0.9.1", +] + +[[package]] +name = "borsh-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bd16f0729b89f0a212b0e2e1d19cc6593df63f771161a11863967780e2d033d" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate", + "proc-macro2", + "syn", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e321a130a3ac4b88eb59a6d670bde11eec9721a397b77e0f2079060e2a1b785" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15151a485164b319cc7a5160fe4316dc469a27993f71b73d7617dc9032ff0fd7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bstr" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "bumpalo" +version = "3.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe" + +[[package]] +name = "bytemuck" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72957246c41db82b8ef88a5486143830adeb8227ef9837740bdec67724cf2c5b" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cast" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc38c385bfd7e444464011bb24820f40dd1c76bcdfa1b78611cb7c2e5cafab75" +dependencies = [ + "rustc_version 0.2.3", +] + +[[package]] +name = "cc" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chacha20" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee7ad89dc1128635074c268ee661f90c3f7e83d9fd12910608c36b47d6c3412" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1580317203210c517b6d44794abfbe600698276db18127e37ad3e69bf5e848e5" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "bitflags", + "textwrap", + "unicode-width", +] + +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "cpp_demangle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea47428dc9d2237f3c6bc134472edfd63ebba0af932e783506dcfd66f10d18a" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c99696f6c9dd7f35d486b9d04d7e6e202aa3e8c40d553f2fdf5e7e0c6a71ef" +dependencies = [ + "libc", +] + +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "criterion" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab327ed7354547cc2ef43cbe20ef68b988e70b4b593cbd66a2a61733123a3d23" +dependencies = [ + "atty", + "cast", + "clap", + "criterion-plot", + "csv", + "itertools 0.10.1", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_cbor", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d" +dependencies = [ + "cast", + "itertools 0.9.0", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2584f639eb95fea8c798496315b297cf81b9b58b6d30ab066a75455333cf4b12" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "curve25519-dalek" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639891fde0dbea823fc3d798a0fdf9d2f9440a42d64a78ab3488b0ca025117b3" +dependencies = [ + "byteorder", + "digest", + "rand_core 0.5.1", + "serde", + "subtle", + "zeroize", +] + +[[package]] +name = "debugid" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91cf5a8c2f2097e2a32627123508635d47ce10563d999ec1a95addf08b502ba" +dependencies = [ + "uuid", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "ed25519" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d0860415b12243916284c67a9be413e044ee6668247b99ba26d94b2bc06c8f6" +dependencies = [ + "serde", + "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", + "merlin", + "rand 0.7.3", + "serde", + "serde_bytes", + "sha2", + "zeroize", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "ferveo" +version = "0.1.0" +dependencies = [ + "anyhow", + "ark-bls12-381", + "ark-ec", + "ark-ed-on-bls12-381", + "ark-ff", + "ark-pallas", + "ark-poly", + "ark-poly-commit", + "ark-serialize", + "ark-std", + "bincode", + "blake2", + "blake2b_simd", + "borsh", + "chacha20poly1305", + "criterion", + "curve25519-dalek", + "digest", + "ed25519-dalek", + "either", + "ff 0.8.0", + "group-threshold-cryptography", + "hex", + "itertools 0.10.1", + "measure_time", + "miracl_core", + "num", + "pprof", + "rand 0.7.3", + "rand 0.8.4", + "rand_chacha 0.3.1", + "redjubjub", + "serde", + "serde_bytes", + "serde_json", + "sha2", + "subtle", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "ff" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01646e077d4ebda82b73f1bca002ea1e91561a77df2431a9e79729bcc31950ef" +dependencies = [ + "bitvec 0.18.5", + "rand_core 0.5.1", + "subtle", +] + +[[package]] +name = "ff" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72a4d941a5b7c2a75222e2d44fcdf634a67133d9db31e177ae5ff6ecda852bfe" +dependencies = [ + "bitvec 0.20.4", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "funty" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" + +[[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", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.10.2+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189" + +[[package]] +name = "group" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b3c1e8b4f1ca07e6605ea1be903a5f6956aec5c8a67fd44d56076631675ed8" +dependencies = [ + "byteorder", + "ff 0.9.0", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "group-threshold-cryptography" +version = "0.1.0" +dependencies = [ + "anyhow", + "ark-bls12-381", + "ark-ec", + "ark-ff", + "ark-poly", + "ark-serialize", + "ark-std", + "blake2b_simd", + "chacha20", + "hex", + "itertools 0.10.1", + "miracl_core", + "rand 0.8.4", + "rand_core 0.6.3", + "rayon", + "thiserror", +] + +[[package]] +name = "half" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62aca2aba2d62b4a7f5b33f3712cb1b0692779a56fb510499d5c0aa594daeaf3" + +[[package]] +name = "hashbrown" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +dependencies = [ + "ahash 0.4.7", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash 0.7.2", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown 0.11.2", +] + +[[package]] +name = "inferno" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c3cbcc228d2ad2e99328c2b19f38d80ec387ca6a29f778e40e32ca9f25448c3" +dependencies = [ + "ahash 0.6.3", + "atty", + "indexmap", + "itoa", + "lazy_static", + "log", + "num-format", + "quick-xml", + "rgb", + "str_stack", +] + +[[package]] +name = "instant" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf" +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.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d99f9e3e84b8f67f846ef5b4cbbc3b1c29f6c759fcbce6f01aa0e73d932a24c" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jubjub" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d7e7fef85ae7b26dd89f34175b7f3c5ace64067a110c2ac86cf92407a6666ca" +dependencies = [ + "bitvec 0.20.4", + "bls12_381", + "ff 0.9.0", + "group", + "rand_core 0.6.3", + "subtle", +] + +[[package]] +name = "keccak" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" + +[[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.101" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cb00336871be5ed2c8ed44b60ae9959dc5b9f08539422ed43f09e34ecaeba21" + +[[package]] +name = "lock_api" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "measure_time" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68c8a1703dd54ab3307c03401e8b6c42121b67501dd6c6deb5077914ccb8085" +dependencies = [ + "log", +] + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "memoffset" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83fb6581e8ed1f85fd45c116db8405483899489e38406156c25eb743554361d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "miracl_core" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94c7128ba23c81f6471141b90f17654f89ef44a56e14b8a4dd0fddfccd655277" + +[[package]] +name = "nix" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8e5e343312e7fbeb2a52139114e9e702991ef9c2aea6817ff2440b35647d56" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nodrop" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" + +[[package]] +name = "num" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d047c1062aa51e256408c560894e5251f08925980e53cf1aa5bd00eec6512" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26873667bbbb7c5182d4a37c1add32cdf09f841af72da53318fdb81543c15085" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[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.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "plotters" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45ca0ae5f169d0917a7c7f5a9c1a3d3d9598f18f529dd2b8373ed988efea307a" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07fffcddc1cb3a1de753caa4e4df03b79922ba43cf882acc1bdd7e8df9f4590" + +[[package]] +name = "plotters-svg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b38a02e23bd9604b842a812063aec4ef702b57989c37b655254bb61c471ad211" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "poly1305" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fe800695325da85083cd23b56826fccb2e2dc29b218e7811a6f33bc93f414be" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "pprof" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7600124d694d855283caf9f333befe2abce090833bb638009aeddd9e156dee" +dependencies = [ + "backtrace", + "criterion", + "inferno", + "lazy_static", + "libc", + "log", + "nix", + "parking_lot", + "symbolic-demangle", + "tempfile", + "thiserror", +] + +[[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-macro2" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quick-xml" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26aab6b48e2590e4a64d1ed808749ba06257882b461d01ca71baeb747074a6dd" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "def50a86306165861203e7f84ecffbbdfdea79f0e51039b33de1e952358c47ac" + +[[package]] +name = "radium" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.3", + "rand_hc 0.3.1", +] + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.3", +] + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +dependencies = [ + "getrandom 0.2.2", +] + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" +dependencies = [ + "rand_core 0.6.3", +] + +[[package]] +name = "rayon" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redjubjub" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dcf30702f15c157e348b4ccef28b1224fc7da8f8430d553bdc47b2d6599107b" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest", + "funty", + "jubjub", + "rand_core 0.6.3", + "serde", + "thiserror", + "zeroize", +] + +[[package]] +name = "redox_syscall" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", +] + +[[package]] +name = "regex-syntax" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" + +[[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 = "rgb" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fddb3b23626145d1776addfc307e1a1851f60ef6ca64f376bcb889697144cf0" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_bytes" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ae07dd2f88a366f15bd0632ba725227018c69a1c8550a927324f8eb8368bb9" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_cbor" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622" +dependencies = [ + "half", + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.125" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +dependencies = [ + "block-buffer", + "cfg-if", + "cpuid-bool", + "digest", + "opaque-debug", +] + +[[package]] +name = "signature" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19772be3c4dd2ceaacf03cb41d5885f2a02c4d8804884918e3a258480803335" + +[[package]] +name = "smallvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "str_stack" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb" + +[[package]] +name = "subtle" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2" + +[[package]] +name = "symbolic-common" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "348885c332e7d0784d661844b13b198464144a5ebcd3bfc047a6c441867ea467" +dependencies = [ + "debugid", + "memmap", + "stable_deref_trait", + "uuid", +] + +[[package]] +name = "symbolic-demangle" +version = "8.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6780c62bfbd609bffaa13d6959715850578aa43caaae7aee14f1f24ceb64f433" +dependencies = [ + "cpp_demangle", + "rustc-demangle", + "symbolic-common", +] + +[[package]] +name = "syn" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" +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 = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tempfile" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +dependencies = [ + "cfg-if", + "libc", + "rand 0.8.4", + "redox_syscall", + "remove_dir_all", + "winapi", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42e6fa53307c8a17e4ccd4dc81cf5ec38db9209f59b222210375b54ee40d1e2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab69019741fca4d98be3c62d2b75254528b5432233fd8a4d2739fec20278de48" +dependencies = [ + "tracing-core", +] + +[[package]] +name = "typenum" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" + +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "universal-hash" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[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.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + +[[package]] +name = "wasm-bindgen" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83240549659d187488f91f33c0f8547cbfef0b2088bc470c116d1d260ef623d9" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae70622411ca953215ca6d06d3ebeb1e915f0f6613e3b495122878d7ebec7dae" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e734d91443f177bfdb41969de821e15c516931c3c3db3d318fa1b68975d0f6f" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53739ff08c8a68b0fdbcd54c372b8ab800b1449ab3c9d706503bc7dd1621b2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9a543ae66aa233d14bb765ed9af4a33e81b8b58d1584cf1b47ff8cd0b9e4489" + +[[package]] +name = "web-sys" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a905d57e488fec8861446d3393670fb50d27a262344013181c2cdf9fff5481be" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[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-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[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 = "wyz" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek", + "rand_core 0.5.1", + "serde", + "zeroize", +] + +[[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/ferveo/Cargo.toml b/ferveo/Cargo.toml new file mode 100644 index 00000000..5fc756ec --- /dev/null +++ b/ferveo/Cargo.toml @@ -0,0 +1,89 @@ +[package] +name = "ferveo" +version = "0.1.0" +edition = "2018" +license = "AGPL-3.0" +repository = "https://gitlab.com/anoma/ferveo" +readme = "README.md" +description = "An implementation of a DKG protocol for front-running protection on public blockchains." +keywords = ["DKG"] +categories = ["cryptography"] +authors = ["Heliax AG "] + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +#ark-poly-commit = "0.3" +ark-std = "0.3" +#ark-pallas = "0.3" +ark-bls12-381 = "0.3" +ark-ec = "0.3" +ark-ff = "0.3" +ark-serialize = "0.3" +ark-poly = "0.3" +rand = "0.8" +rand_old = { package = "rand", version = "0.7" } +either = "1.6.1" +#ff = "0.8" +hex = "0.4.2" +miracl_core = "2.3.0" +num = "0.4" +#sha2 = "0.9.1" +ed25519-dalek = { version = "1", features = ["serde", "batch"] } +#x25519-dalek = { version = "1.1", features = ["serde"] } +#curve25519-dalek = { version = "3.0", features = ["serde"] } +serde = { version = "1.0", features = ["derive"] } +blake2 = "0.9.1" +#rand_chacha = "0.3.0" +blake2b_simd = "0.5.11" +zeroize = { version = "1", default-features = false, features = ["zeroize_derive"] } +#chacha20poly1305 = "0.8" +serde_bytes = { version = "0.11" } +bincode = "1.3" +anyhow = "1.0" +serde_json = "1.0" +borsh = "0.9" +subtle = "2.4" +itertools = "0.10.1" +measure_time = "0.7" +#redjubjub = "0.4.0" +ark-ed-on-bls12-381 = "0.3.0" +group-threshold-cryptography = { path = "../tpke" } +#tendermint = { path = "../../tendermint-rs/tendermint" } +tendermint = { git = "https://github.com/heliaxdev/tendermint-rs" } +ferveo-common = { path = "../ferveo-common" } + +[dependencies.digest] +version = "0.9.0" +features = ["alloc"] + +[dev-dependencies] +criterion = "0.3" +pprof = { version = "0.5", features = ["flamegraph", "criterion"] } + +# local override for bls12-381 +#[patch.crates-io] +#bls12_381 = { git = 'https://github.com/A-Manning/bls12_381.git', branch = "ash/scalar-traits" } + +#[[bench]] +#name = "benchmarks" +#harness = false +#debug = true + +[[example]] +name = "pvdkg" +path = "examples/pvdkg.rs" + +#[[bench]] +#name = "pairing" +#harness = false +#debug = false + +#[[bench]] +#name = "bench_main" +#harness = false + +[[bench]] +name = "pvdkg" +path = "benches/benchmarks/pvdkg.rs" +harness = false \ No newline at end of file diff --git a/benches/bench_main.rs b/ferveo/benches/bench_main.rs similarity index 100% rename from benches/bench_main.rs rename to ferveo/benches/bench_main.rs diff --git a/benches/benchmarks/block_proposer.rs b/ferveo/benches/benchmarks/block_proposer.rs similarity index 100% rename from benches/benchmarks/block_proposer.rs rename to ferveo/benches/benchmarks/block_proposer.rs diff --git a/benches/benchmarks/mod.rs b/ferveo/benches/benchmarks/mod.rs similarity index 100% rename from benches/benchmarks/mod.rs rename to ferveo/benches/benchmarks/mod.rs diff --git a/benches/benchmarks/pairing.rs b/ferveo/benches/benchmarks/pairing.rs similarity index 99% rename from benches/benchmarks/pairing.rs rename to ferveo/benches/benchmarks/pairing.rs index ad78c1e1..a8c962e6 100644 --- a/benches/benchmarks/pairing.rs +++ b/ferveo/benches/benchmarks/pairing.rs @@ -1,7 +1,7 @@ use ark_bls12_381::*; use ark_ec::*; use criterion::{black_box, criterion_group, criterion_main, Criterion}; -use redjubjub::*; +//use redjubjub::*; use std::convert::TryFrom; use ark_bls12_381::*; @@ -260,7 +260,7 @@ pub fn pairing(c: &mut Criterion) { }) }); } - +/* enum Item { SpendAuth { vk_bytes: VerificationKeyBytes, @@ -326,7 +326,7 @@ pub fn redjubjub(c: &mut Criterion) { ); } group.finish(); -} +}*/ fn ed25519_batch(c: &mut Criterion) { let mut group = c.benchmark_group("Ed25519 Batch Verification"); @@ -383,7 +383,7 @@ pub fn bench_batch_inverse(c: &mut Criterion) { criterion_group!( ec, pairing, - redjubjub, + //redjubjub, ed25519_batch, lagrange, bench_batch_inverse diff --git a/ferveo/benches/benchmarks/pvdkg.rs b/ferveo/benches/benchmarks/pvdkg.rs new file mode 100644 index 00000000..42a8c7cf --- /dev/null +++ b/ferveo/benches/benchmarks/pvdkg.rs @@ -0,0 +1,107 @@ +use criterion::{criterion_group, criterion_main, Criterion}; +use ferveo::*; + +pub fn dkgs(c: &mut Criterion) { + // use a fixed seed for reproducability + use rand::SeedableRng; + let _rng = rand::rngs::StdRng::seed_from_u64(0); + + let mut group = c.benchmark_group("compare DKGs with 8192 shares"); + group.sample_size(10); + + //Benchmarking compare DKGs with 8192 shares/Pedersen Pallas: Collecting 10 sample compare DKGs with 8192 shares/Pedersen Pallas + //time: [95.895 s 97.154 s 98.507 s] + /*group.bench_function("Pedersen Pallas", |b| { + b.iter(|| pedersen::()) + }); + group.measurement_time(core::time::Duration::new(30, 0));*/ + // Benchmarking compare DKGs with 8192 shares/Pedersen BLS12-381: Collecting 10 sam compare DKGs with 8192 shares/Pedersen BLS12-381 + //time: [177.12 s 178.73 s 180.47 s] + /*group.bench_function("Pedersen BLS12-381", |b| { + b.iter(|| pedersen::()) + });*/ + // 2130.7 seconds per iteration to verify pairwise + group.measurement_time(core::time::Duration::new(60, 0)); + group.bench_function("PVDKG BLS12-381", |b| { + b.iter(pvdkg::) + }); +} + +use pprof::criterion::{Output, PProfProfiler}; + +criterion_group! { + name = pvdkg_bls; + config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); + targets = dkgs +} + +criterion_main!(pvdkg_bls); + +fn create_info(vp: u64) -> tendermint::validator::Info { + use std::convert::TryFrom; + tendermint::validator::Info::new( + tendermint::public_key::PublicKey::from_raw_ed25519(&vec![ + 48, 163, 55, 132, 231, 147, 230, 163, 56, 158, 127, 218, 179, 139, + 212, 103, 218, 89, 122, 126, 229, 88, 84, 48, 32, 0, 185, 174, 63, + 72, 203, 52, + ]) + .unwrap(), + tendermint::vote::Power::try_from(vp).unwrap(), + ) +} + +pub fn pvdkg() { + use ark_ec::{AffineCurve, ProjectiveCurve}; + let rng = &mut ark_std::test_rng(); + //use rand_old::SeedableRng; + //let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + + let params = Params { + tau: 0u64, + security_threshold: 300 / 3, + total_weight: 300, + }; + let validator_set = tendermint::validator::Set::without_proposer( + (1..11u64).map(|vp| create_info(vp)).collect::>(), + ); + + let validator_keys = (0..10) + .map(|_| { + ferveo_common::PublicKey::::default() + }) + .collect::>(); + + // for _ in 0..1 { + let mut contexts = vec![]; + for me in 0..10 { + contexts.push( + PubliclyVerifiableDkg::::new( + &validator_set, + &validator_keys, + params.clone(), + me, + rng, + ) + .unwrap(), + ); + } + use std::collections::VecDeque; + let mut messages = VecDeque::new(); + + let mut dealt_weight = 0u32; + for participant in contexts.iter_mut() { + if dealt_weight < params.total_weight - params.security_threshold { + let msg = participant.share(rng).unwrap(); + let msg: Message = msg; //.verify().unwrap().1; + messages.push_back((participant.me, msg)); + dealt_weight += participant.validators[participant.me].weight; + } + } + for msg in messages.iter() { + for node in contexts.iter_mut() { + node.handle_message(msg.0 as u32, msg.1.clone()).unwrap(); + } + } + + let tpke_pubkey = contexts[0].final_key(); +} diff --git a/ferveo/examples/pvdkg.rs b/ferveo/examples/pvdkg.rs new file mode 100644 index 00000000..e342ff78 --- /dev/null +++ b/ferveo/examples/pvdkg.rs @@ -0,0 +1,74 @@ +use ferveo::*; + +pub fn main() { + pvdkg::(); +} + +fn create_info(vp: u64) -> tendermint::validator::Info { + use std::convert::TryFrom; + tendermint::validator::Info::new( + tendermint::public_key::PublicKey::from_raw_ed25519(&vec![ + 48, 163, 55, 132, 231, 147, 230, 163, 56, 158, 127, 218, 179, 139, + 212, 103, 218, 89, 122, 126, 229, 88, 84, 48, 32, 0, 185, 174, 63, + 72, 203, 52, + ]) + .unwrap(), + tendermint::vote::Power::try_from(vp).unwrap(), + ) +} + +pub fn pvdkg() { + use ark_ec::{AffineCurve, ProjectiveCurve}; + let rng = &mut ark_std::test_rng(); + //use rand_old::SeedableRng; + //let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + + let params = Params { + tau: 0u64, + security_threshold: 300 / 3, + total_weight: 300, + }; + let validator_set = tendermint::validator::Set::without_proposer( + (1..11u64).map(|vp| create_info(vp)).collect::>(), + ); + + let validator_keys = (0..10) + .map(|_| { + ferveo_common::PublicKey::::default() + }) + .collect::>(); + + // for _ in 0..1 { + let mut contexts = vec![]; + for me in 0..10 { + contexts.push( + PubliclyVerifiableDkg::::new( + &validator_set, + &validator_keys, + params.clone(), + me, + rng, + ) + .unwrap(), + ); + } + use std::collections::VecDeque; + let mut messages = VecDeque::new(); + + let mut dealt_weight = 0u32; + for participant in contexts.iter_mut() { + if dealt_weight < params.total_weight - params.security_threshold { + let msg = participant.share(rng).unwrap(); + let msg: Message = msg; //.verify().unwrap().1; + messages.push_back((participant.me, msg)); + dealt_weight += participant.validators[participant.me].weight; + } + } + for msg in messages.iter() { + for node in contexts.iter_mut() { + node.handle_message(msg.0 as u32, msg.1.clone()).unwrap(); + } + } + + let tpke_pubkey = contexts[0].final_key(); +} diff --git a/src/dkg.rs b/ferveo/src/dkg.rs similarity index 71% rename from src/dkg.rs rename to ferveo/src/dkg.rs index 16248c88..0f43c7b9 100644 --- a/src/dkg.rs +++ b/ferveo/src/dkg.rs @@ -2,8 +2,6 @@ #![allow(non_snake_case)] #![allow(unused_imports)] -//use ark_poly_commit::kzg10::{Powers, VerifierKey}; - use crate::*; use anyhow::anyhow; use ark_ec::{AffineCurve, PairingEngine, ProjectiveCurve}; @@ -14,7 +12,6 @@ use ark_poly::{ EvaluationDomain, Polynomial, }; use ed25519_dalek as ed25519; -use serde::*; pub mod common; pub mod pv; @@ -30,13 +27,11 @@ pub struct Params { } #[derive(Debug, Clone)] -pub enum DKGState { - Init { - announce_messages: Vec>, - }, - Sharing { - finalized_weight: u32, - }, +pub enum DkgState { + Init, + Dealt, + Shared, + Aggregated { finalized_weight: u32 }, Success, - Failure, + Invalid, } diff --git a/src/dkg/common.rs b/ferveo/src/dkg/common.rs similarity index 57% rename from src/dkg/common.rs rename to ferveo/src/dkg/common.rs index 5ac9f6f2..281cc944 100644 --- a/src/dkg/common.rs +++ b/ferveo/src/dkg/common.rs @@ -1,4 +1,5 @@ use crate::*; +use itertools::izip; /// partition_domain takes as input a vector of Announcement messages from /// participants in the DKG, containing their total stake amounts @@ -10,31 +11,24 @@ use crate::*; /// the same relative size as the staked weight. /// /// partition_domain returns a vector of DKG participants -pub fn partition_domain( +pub fn partition_domain( params: &Params, - announce_messages: &mut Vec>, -) -> Result>> -where - E: ark_ec::PairingEngine, -{ + validator_set: &tendermint::validator::Set, + validator_keys: &[ferveo_common::PublicKey], +) -> Result>> { + let validators = validator_set.validators(); // Sort participants from greatest to least stake - announce_messages.sort_by(|a, b| b.stake.cmp(&a.stake)); + // Compute the total amount staked - let total_stake: f64 = announce_messages - .iter() - .map(|p| p.stake as f64) - .sum::() - .into(); + let total_voting_power = params.total_weight as f64 + / validator_set.total_voting_power().value() as f64; // Compute the weight of each participant rounded down - let mut weights = announce_messages + let mut weights = validators .iter() - .map(|p| { - ((params.total_weight as f64) * p.stake as f64 / total_stake) - .floor() as u32 - }) - .collect::>(); - //dbg!(&weights); + .map(|p| (p.power() as f64 * total_voting_power).floor() as u32) + .collect::>(); + // Add any excess weight to the largest weight participants let adjust_weight = params .total_weight @@ -50,17 +44,17 @@ where let mut allocated_weight = 0usize; let mut participants = vec![]; - for (announcement, weight) in announce_messages.iter().zip(weights) { - let share_range = allocated_weight..allocated_weight + weight as usize; - - participants.push(PubliclyVerifiableParticipant:: { - ed_key: announcement.signer, - session_key: announcement.session_key, - weight, - share_range, + for (validator, weight, key) in + izip!(validators.iter(), weights.iter(), validator_keys.iter()) + { + participants.push(ferveo_common::Validator:: { + key: *key, + weight: *weight, + share_start: allocated_weight, + share_end: allocated_weight + *weight as usize, }); allocated_weight = allocated_weight - .checked_add(weight as usize) + .checked_add(*weight as usize) .ok_or_else(|| anyhow!("allocated weight overflow"))?; } Ok(participants) diff --git a/ferveo/src/dkg/pv.rs b/ferveo/src/dkg/pv.rs new file mode 100644 index 00000000..0423c0e6 --- /dev/null +++ b/ferveo/src/dkg/pv.rs @@ -0,0 +1,375 @@ +use crate::*; +use ark_ec::PairingEngine; +use ark_ff::Field; +use ark_std::{end_timer, start_timer}; +use std::collections::BTreeMap; + +/// The DKG context that holds all of the local state for participating in the DKG +pub struct PubliclyVerifiableDkg { + //pub ed_key: ed25519::Keypair, + pub params: Params, + pub pvss_params: PubliclyVerifiableParams, + pub session_keypair: ferveo_common::Keypair, + pub validators: Vec>, + pub vss: BTreeMap>, + pub domain: ark_poly::Radix2EvaluationDomain, + pub state: DkgState, + pub me: usize, + pub validator_set: tendermint::validator::Set, + //pub local_shares: Vec, + //pub announce_messages: Vec>, +} + +impl PubliclyVerifiableDkg { + /// Create a new DKG context to participate in the DKG + /// Every identity in the DKG is linked to an ed25519 public key; + /// `ed_key` is the local identity. + /// `params` contains the parameters of the DKG such as number of shares + /// `rng` is a cryptographic random number generator + pub fn new( + validator_set: &tendermint::validator::Set, + validator_keys: &[ferveo_common::PublicKey], + params: Params, + me: usize, + rng: &mut R, + ) -> Result { + use ark_std::UniformRand; + let domain = ark_poly::Radix2EvaluationDomain::::new( + params.total_weight as usize, + ) + .ok_or_else(|| anyhow!("unable to construct domain"))?; + + Ok(Self { + session_keypair: ferveo_common::Keypair::::new(rng), + params, + pvss_params: PubliclyVerifiableParams:: { + g: E::G1Projective::prime_subgroup_generator(), + h: E::G2Projective::prime_subgroup_generator(), + }, + //participants: vec![], + vss: BTreeMap::new(), + domain, + state: DkgState::Init, + me, + validator_set: validator_set.clone(), + validators: partition_domain( + ¶ms, + validator_set, + validator_keys, + )?, + //me: 0, // TODO: invalid value + //final_state: None, + //local_shares: vec![], + // TODO: Validators don't announce themselves through DKG + // TODO: Instead, we read stakes from storage + }) + } + /// Create a new PVSS instance within this DKG session, contributing to the final key + /// `rng` is a cryptographic random number generator + /// Returns a PVSS dealing message to post on-chain + pub fn share(&mut self, rng: &mut R) -> Result> { + use ark_std::UniformRand; + print_time!("PVSS Sharing"); + + let vss = + PubliclyVerifiableSS::::new(&E::Fr::rand(rng), &self, rng)?; + + let sharing = vss.clone(); + self.vss.insert(self.me as u32, vss); + + Ok(Message::Deal(sharing)) + } + /// Aggregate all received PVSS messages into a single message, prepared to post on-chain + pub fn aggregate(&mut self) -> Message { + let pvss = PubliclyVerifiableSS::::aggregate(self, &self.vss); + Message::Aggregate(pvss) + } + + /// Converts an ed25519 key to the index of that participant + //TODO: this is not a good workaround for finding dealer from ed_key + //pub fn find_by_key(&self, ed_key: &ed25519::PublicKey) -> Option { + // self.participants.iter().position(|p| p.ed_key == *ed_key) + //} + + /// Returns the public key generated by the DKG + pub fn final_key(&self) -> E::G1Affine { + self.vss + .iter() + .map(|(_, vss)| vss.coeffs[0].into_projective()) + .sum::() + .into_affine() + } + + /// Handle a DKG related message posted on chain + /// `sender` is the validator id of the sender of the message + /// `payload` is the content of the message + pub fn handle_message( + &mut self, + sender: u32, + payload: Message, + ) -> Result> { + match payload { + Message::Deal(sharing) => { + if let DkgState::Init = self.state { + /*let dealer = self.find_by_key(signer).ok_or_else(|| { + anyhow!("received dealing from unknown dealer") + })? as u32;*/ + if sender != self.me as u32 { + if self.vss.contains_key(&sender) { + return Err(anyhow!("Repeat dealer {}", sender)); + } + self.vss.insert(sender, sharing); + } + // TODO: Shall we add here a check whether enough dealers (> 66%) have shared their PVSS? If so, we'd move to a Dealt state. + // Once we are in a dealt state, we'd trigger the generation of the transcript and share the decryption keys + } + Ok(None) + } + Message::Aggregate(vss) => { + if let DkgState::Shared = self.state { + let minimum_weight = self.params.total_weight + - self.params.security_threshold; + let verified_weight = vss.verify_aggregation(&self)?; + if verified_weight >= minimum_weight { + //self.local_shares = local_shares; + self.state = DkgState::Success; + } else { + self.state = DkgState::Aggregated { + finalized_weight: verified_weight, + }; + } + } + Ok(None) + } //_ => Err(anyhow!("Unknown message type for this DKG engine")), + } + } +} + +#[derive(Serialize, Deserialize, Clone, Debug)] +#[serde(bound = "")] +pub enum Message { + #[serde(with = "ferveo_common::ark_serde")] + Deal(PubliclyVerifiableSS), + #[serde(with = "ferveo_common::ark_serde")] + Aggregate(PubliclyVerifiableSS), +} + +#[derive(Debug, Clone)] +pub struct PubliclyVerifiableAnnouncement { + pub session_key: ferveo_common::PublicKey, + pub stake: u64, +} + +#[cfg(test)] +mod tests { + + use crate::dkg::PubliclyVerifiableDkg; + use crate::*; + use ark_bls12_381::G1Affine; + use ark_ec::{bls12::Bls12, PairingEngine}; + use ark_std::{end_timer, start_timer}; + use group_threshold_cryptography::{ + decrypt_with_shared_secret, encrypt, setup, Ciphertext, + DecryptionShare, PrivateDecryptionContext, PrivateKeyShare, + PublicDecryptionContext, PublicKeyShares, + }; + use itertools::izip; + + fn create_info(vp: u64) -> tendermint::validator::Info { + use std::convert::TryFrom; + tendermint::validator::Info::new( + tendermint::public_key::PublicKey::from_raw_ed25519(&vec![ + 48, 163, 55, 132, 231, 147, 230, 163, 56, 158, 127, 218, 179, + 139, 212, 103, 218, 89, 122, 126, 229, 88, 84, 48, 32, 0, 185, + 174, 63, 72, 203, 52, + ]) + .unwrap(), + tendermint::vote::Power::try_from(vp).unwrap(), + ) + } + + #[test] + pub fn test_pvdkg_tpke() { + use ark_ec::{AffineCurve, ProjectiveCurve}; + let rng = &mut ark_std::test_rng(); + //use rand_old::SeedableRng; + //let ed_rng = &mut rand_old::rngs::StdRng::from_seed([0u8; 32]); + + let params = Params { + tau: 0u64, + security_threshold: 300 / 3, + total_weight: 300, + }; + let validator_set = tendermint::validator::Set::without_proposer( + (1..11u64).map(|vp| create_info(vp)).collect::>(), + ); + + let validator_keys = (0..10) + .map(|_| { + ferveo_common::PublicKey::::default() + }) + .collect::>(); + + // for _ in 0..1 { + let mut contexts = vec![]; + for me in 0..10 { + contexts.push( + PubliclyVerifiableDkg::::new( + &validator_set, + &validator_keys, + params.clone(), + me, + rng, + ) + .unwrap(), + ); + } + use std::collections::VecDeque; + let mut messages = VecDeque::new(); + + let mut dealt_weight = 0u32; + for participant in contexts.iter_mut() { + if dealt_weight < params.total_weight - params.security_threshold { + let msg = participant.share(rng).unwrap(); + let msg: Message = msg; //.verify().unwrap().1; + messages.push_back((participant.me, msg)); + dealt_weight += participant.validators[participant.me].weight; + } + } + for msg in messages.iter() { + for node in contexts.iter_mut() { + node.handle_message(msg.0 as u32, msg.1.clone()).unwrap(); + } + } + + let tpke_pubkey = contexts[0].final_key(); + /* + ///////////////////////////////////////// TPKE ///////////////////////////////////////// + let threshold = contexts[0].params.security_threshold as usize; //16 * 2 / 3; + let shares_num = contexts[0].params.total_weight as usize; //16; + let num_entities = contexts.len(); + let msg: &[u8] = "abc".as_bytes(); + + // let (_, privkey, tpke_contexts) = setup::( + // threshold, + // shares_num, + // num_entities, + // ); + + use ark_std::UniformRand; + let rng = &mut ark_std::test_rng(); + + let window_size = FixedBaseMSM::get_mul_window_size(100); + let scalar_bits = as PairingEngine>::Fr::size_in_bits(); + let g = as PairingEngine>::G1Affine::prime_subgroup_generator(); + let h = as PairingEngine>::G2Affine::prime_subgroup_generator(); + + let mut private_contexts = vec![]; + let mut public_contexts = vec![]; + + // pub struct PubliclyVerifiableDKG + // { + // pub ed_key: ed25519::Keypair, + // pub params: Params, + // pub pvss_params: PubliclyVerifiableParams, + // pub session_keypair: PubliclyVerifiableKeypair, + // pub participants: Vec>, + // pub vss: BTreeMap>, + // pub domain: ark_poly::Radix2EvaluationDomain, + // pub state: DKGState, + // pub me: usize, + // pub local_shares: Vec, + // } + + let fft_domain = ark_poly::Radix2EvaluationDomain::< + as PairingEngine>::Fr, + >::new(shares_num) + .unwrap(); + let mut domain_points = Vec::with_capacity(shares_num); + let mut point = + as PairingEngine>::Fr::one(); + let mut domain_points_inv = Vec::with_capacity(shares_num); + let mut point_inv = + as PairingEngine>::Fr::one(); + + for _ in 0..shares_num { + domain_points.push(point); + point *= fft_domain.group_gen; + domain_points_inv.push(point_inv); + point_inv *= fft_domain.group_gen_inv; + } + + // let pubkey_shares: Vec< + // as PairingEngine>::G1Affine, + // > = vec![]; + + // for context in contexts { + for (_, (context, domain, domain_inv, public)) in izip!( + contexts, + domain_points.chunks(shares_num / num_entities), + domain_points_inv.chunks(shares_num / num_entities), + pubkey_shares.chunks(shares_num / num_entities), + ) + .enumerate() + { + let b = + as PairingEngine>::Fr::rand( + rng, + ); + let private_key_share = PrivateKeyShare:: { + private_key_shares: context.local_shares, + }; + let mut blinded_key_shares = private_key_share.blind(b.clone()); + blinded_key_shares.multiply_by_omega_inv(domain_inv); + + private_contexts.push(PrivateDecryptionContext:: { + index: 0,//context.me, + b, + b_inv: b.inverse().unwrap(), + private_key_share, + public_decryption_contexts: vec![], + g, + g_inv: as PairingEngine>::G1Prepared::from(-g), + h_inv: as PairingEngine>::G2Prepared::from(-h), + scalar_bits, + window_size, + }); + let mut lagrange_n_0 = domain.iter().product::< as PairingEngine>::Fr>(); + if domain.len() % 2 == 1 { + lagrange_n_0 = -lagrange_n_0; + } + public_contexts.push(PublicDecryptionContext::< + ark_bls12_381::Bls12_381, + > { + domain: domain.to_vec(), + public_key_shares: PublicKeyShares:: { + public_key_shares: public.to_vec(), + }, + blinded_key_shares, + lagrange_n_0, + }); + } + for private in private_contexts.iter_mut() { + private.public_decryption_contexts = public_contexts.clone(); + } + + let ciphertext = + encrypt::<_, ark_bls12_381::Bls12_381>(msg, tpke_pubkey, rng); + + // create Decryption Shares + let mut shares: Vec> = vec![]; + for context in private_contexts.iter() { + shares.push(context.create_share(&ciphertext)); + } + + let prepared_blinded_key_shares = + private_contexts[0].prepare_combine(&shares); + let s = private_contexts[0] + .share_combine(&shares, &prepared_blinded_key_shares); + + let plaintext = decrypt_with_shared_secret(&ciphertext, &s); + assert!(plaintext == msg) + + // }*/ + } +} diff --git a/src/lib.rs b/ferveo/src/lib.rs similarity index 52% rename from src/lib.rs rename to ferveo/src/lib.rs index 6d4efad0..c2867405 100644 --- a/src/lib.rs +++ b/ferveo/src/lib.rs @@ -1,41 +1,36 @@ +#![allow(unused_imports)] pub mod dkg; pub mod msg; pub mod vss; -pub use msg::ark_serde; - -impl Rng for ark_std::rand::prelude::StdRng {} - -pub trait Rng: ark_std::rand::CryptoRng + ark_std::rand::RngCore {} - pub mod primitives; pub use primitives::*; +use ferveo_common::Rng; + use crate::dkg::*; use crate::msg::*; -use ark_ec::AffineCurve; -use ark_ec::ProjectiveCurve; -use ark_ff::Zero; -use ark_ff::{FftField, Field, One}; +use ark_ec::{AffineCurve, ProjectiveCurve}; +use ark_ff::{Field, One, Zero}; use ark_poly::{ polynomial::univariate::DensePolynomial, polynomial::UVPolynomial, - EvaluationDomain, Polynomial, + EvaluationDomain, }; use ed25519_dalek as ed25519; use serde::*; -use num::integer::div_ceil; -use std::collections::{BTreeMap, BTreeSet, HashMap}; +use ark_std::{end_timer, start_timer}; +//use num::integer::div_ceil; use std::rc::Rc; use anyhow::{anyhow, Result}; -use chacha20poly1305::aead::Aead; pub use dkg::*; pub use msg::*; pub use vss::*; use ark_ec::msm::FixedBaseMSM; +use ark_ec::PairingEngine; use ark_ff::PrimeField; use measure_time::print_time; diff --git a/src/main.rs b/ferveo/src/main.rs similarity index 100% rename from src/main.rs rename to ferveo/src/main.rs diff --git a/ferveo/src/msg.rs b/ferveo/src/msg.rs new file mode 100644 index 00000000..8c53d387 --- /dev/null +++ b/ferveo/src/msg.rs @@ -0,0 +1,36 @@ +use ed25519_dalek as ed25519; +use ed25519_dalek::Signer; + +use crate::*; + +impl SignedMessage { + pub fn sign(tau: u64, msg: &M, key: &ed25519::Keypair) -> SignedMessage + where + M: Serialize, + { + print_time!("Signing Message"); + let msg_bytes = bincode::serialize(&(tau, msg)).unwrap(); + let signature = key.sign(&msg_bytes); + SignedMessage { + msg_bytes, + signature, + signer: key.public, + } + } + pub fn verify<'de, M>(&'de self) -> Result<(u64, M)> + where + M: Deserialize<'de>, + { + print_time!("Verifying Message"); + self.signer + .verify_strict(&self.msg_bytes, &self.signature)?; + bincode::deserialize::<'de, _>(&self.msg_bytes).map_err(|e| e.into()) //TODO: handle error + } +} + +#[derive(Serialize, Deserialize, Clone)] +pub struct SignedMessage { + msg_bytes: Vec, + signature: ed25519::Signature, + pub signer: ed25519::PublicKey, +} diff --git a/src/primitives.rs b/ferveo/src/primitives.rs similarity index 96% rename from src/primitives.rs rename to ferveo/src/primitives.rs index 935a9f2b..7e181b0f 100644 --- a/src/primitives.rs +++ b/ferveo/src/primitives.rs @@ -1,12 +1,8 @@ use crate::*; -pub mod keypair; -pub use keypair::*; - pub mod subproductdomain; pub use subproductdomain::*; - /// Compute a fast multiexp of many scalars times the same base /// Only convenient for when called once with given base; if called /// more than once, it's faster to save the generated window table diff --git a/src/primitives/subproductdomain.rs b/ferveo/src/primitives/subproductdomain.rs similarity index 99% rename from src/primitives/subproductdomain.rs rename to ferveo/src/primitives/subproductdomain.rs index 6d1a9f80..ca454a5e 100644 --- a/src/primitives/subproductdomain.rs +++ b/ferveo/src/primitives/subproductdomain.rs @@ -283,7 +283,7 @@ pub fn build_circulant( circulant } /// Computes the Toeplitz matrix of polynomial times the vector v -pub fn toeplitz_mul( +pub fn toeplitz_mul( polynomial: &Poly, v: &[E::G1Affine], size: usize, diff --git a/src/vss.rs b/ferveo/src/vss.rs similarity index 92% rename from src/vss.rs rename to ferveo/src/vss.rs index 7589df5c..1584d140 100644 --- a/src/vss.rs +++ b/ferveo/src/vss.rs @@ -7,7 +7,7 @@ pub use pvss::*; /// The possible States of a VSS instance #[derive(Clone, Debug)] -pub enum VSSState { +pub enum VssState { /// The VSS is currently in a Sharing state with weight_ready /// of participants signaling Ready for this VSS Sharing { weight_ready: u32 }, diff --git a/src/vss/pvss.rs b/ferveo/src/vss/pvss.rs similarity index 68% rename from src/vss/pvss.rs rename to ferveo/src/vss/pvss.rs index e34867f7..9678f2a5 100644 --- a/src/vss/pvss.rs +++ b/ferveo/src/vss/pvss.rs @@ -2,9 +2,9 @@ use crate::*; use ark_ec::PairingEngine; use ark_serialize::*; use itertools::Itertools; -use serde::*; +use std::collections::BTreeMap; -pub type ShareEncryptions = Vec; +pub type ShareEncryptions = Vec<::G2Affine>; /// The dealer posts the Dealing to the blockchain to initiate the VSS #[derive(CanonicalSerialize, CanonicalDeserialize, Clone, Debug)] @@ -12,9 +12,6 @@ pub struct PubliclyVerifiableSS { /// Feldman commitment to the VSS polynomial, F = g^{\phi} pub coeffs: Vec, - // \hat{u}_2 = \hat{u}_1^{a_0} - pub u_hat_2: E::G2Affine, - // ek_i^{f(\omega_j)} pub shares: Vec>, @@ -27,14 +24,11 @@ pub struct PubliclyVerifiableSS { #[derive(Clone)] pub struct PubliclyVerifiableParams { - pub g_1: E::G1Projective, - pub u_hat_1: E::G2Affine, + pub g: E::G1Projective, + pub h: E::G2Projective, } -impl PubliclyVerifiableSS -where - E: PairingEngine, -{ +impl PubliclyVerifiableSS { /// Verify that this PVSS instance is a valid aggregation of /// the PVSS instances, produced by `aggregate`, /// and received by the DKG context `dkg` @@ -42,11 +36,11 @@ where /// and the local private keyshares pub fn verify_aggregation( &self, - dkg: &PubliclyVerifiableDKG, - ) -> Result<(u32, Vec)> { + dkg: &PubliclyVerifiableDkg, + ) -> Result { print_time!("PVSS verify_aggregation"); - let local_shares = self.verify(dkg)?; - let mut Y = E::G1Projective::zero(); + self.verify(dkg); + let mut y = E::G1Projective::zero(); let mut weight = 0u32; for (dealer, pvss) in dkg.vss.iter() { let c = pvss.coeffs[0].into_projective(); @@ -58,11 +52,11 @@ where { return Err(anyhow!("PVSS sigma verification")); } - Y += c; - weight += dkg.participants[*dealer as usize].weight; + y += c; + weight += dkg.validators[*dealer as usize].weight; } - if Y.into_affine() == self.coeffs[0] { - Ok((weight, local_shares)) + if y.into_affine() == self.coeffs[0] { + Ok(weight) } else { Err(anyhow!( "aggregation does not match received PVSS instances" @@ -73,15 +67,13 @@ where /// Aggregate the PVSS instances in `pvss` from DKG session `dkg` ] /// into a new PVSS instance pub fn aggregate( - dkg: &PubliclyVerifiableDKG, + dkg: &PubliclyVerifiableDkg, pvss: &BTreeMap>, ) -> Self { let mut pvss_iter = pvss.iter(); let (_, first_pvss) = pvss_iter.next().unwrap(); //TODO: unwrap? let mut coeffs = batch_to_projective(&first_pvss.coeffs); - let mut u_hat_2 = first_pvss.u_hat_2.into_projective(); - let mut shares = first_pvss .shares .iter() @@ -91,7 +83,6 @@ where for (a, b) in coeffs.iter_mut().zip_eq(next.coeffs.iter()) { *a += b.into_projective(); } - u_hat_2 += next.u_hat_2.into_projective(); for (a, b) in shares.iter_mut().zip_eq(next.shares.iter()) { for (c, d) in a.iter_mut().zip_eq(b.iter()) { *c += d.into_projective(); @@ -112,7 +103,6 @@ where } Self { coeffs: E::G1Projective::batch_normalization_into_affine(&coeffs), - u_hat_2: u_hat_2.into_affine(), shares, sigma, commitment: E::G1Projective::batch_normalization_into_affine( @@ -126,7 +116,7 @@ where /// `rng` a cryptographic random number generator pub fn new( s: &E::Fr, - dkg: &PubliclyVerifiableDKG, + dkg: &PubliclyVerifiableDkg, rng: &mut R, ) -> Result { let mut phi = DensePolynomial::::rand( @@ -138,30 +128,25 @@ where let evals = phi.evaluate_over_domain_by_ref(dkg.domain); // commitment to coeffs - let coeffs = fast_multiexp(&phi.coeffs, dkg.pvss_params.g_1); + let coeffs = fast_multiexp(&phi.coeffs, dkg.pvss_params.g); let shares = dkg - .participants + .validators .iter() - .map(|participant| { - let share_range = participant.share_range.clone(); - + .map(|validator| { fast_multiexp( - &evals.evals[share_range], - participant.session_key.encryption_key.into_projective(), + &evals.evals[validator.share_start..validator.share_end], + validator.key.encryption_key.into_projective(), ) }) .collect::>>(); //phi.zeroize(); // TODO zeroize? - let u_hat_2 = dkg.pvss_params.u_hat_1.mul(*s).into_affine(); //TODO: new base - let sigma = E::G2Affine::prime_subgroup_generator().mul(*s).into(); //todo hash to curve let vss = Self { coeffs, - u_hat_2, shares, sigma, commitment: vec![], // Optimistically avoid computing the commitment @@ -171,62 +156,38 @@ where } /// Verify the PVSS instance `self` is a valid PVSS instance for the DKG context `dkg` - pub fn verify( - &self, - dkg: &PubliclyVerifiableDKG, - ) -> Result> { + pub fn verify(&self, dkg: &PubliclyVerifiableDkg) -> bool { print_time!("PVSS verify"); - let me = &dkg.participants[dkg.me as usize]; - - if self.shares.len() != dkg.participants.len() { - return Err(anyhow!("wrong vss length")); + if self.shares.len() != dkg.validators.len() { + return false; //Err(anyhow!("wrong vss length")); } - //let pairings = vec![]; - //let random_coefficients = vec![]; - // check e(F_0, u_hat_1) == e(g_1, u_hat_2) - if E::pairing(self.coeffs[0], dkg.pvss_params.u_hat_1) - != E::pairing(dkg.pvss_params.g_1, self.u_hat_2) - { - return Err(anyhow!("invalid")); - } { print_time!("check encryptions"); //check e() - dkg.participants.iter().zip(self.shares.iter()).all( - |(participant, shares)| { - let share_range = participant.share_range.clone(); - let ek = participant.session_key.encryption_key; + dkg.validators.iter().zip(self.shares.iter()).all( + |(validator, shares)| { + let ek = validator.key.encryption_key; let alpha = E::Fr::one(); //TODO: random number! let mut powers_of_alpha = alpha; - let mut Y = E::G2Projective::zero(); - let mut A = E::G1Projective::zero(); - for (Y_i, A_i) in shares - .iter() - .zip_eq(self.commitment[share_range].iter()) - { - Y += Y_i.mul(powers_of_alpha); - A += A_i.mul(powers_of_alpha); + let mut y = E::G2Projective::zero(); + let mut a = E::G1Projective::zero(); + for (y_i, a_i) in shares.iter().zip_eq( + self.commitment + [validator.share_start..validator.share_end] + .iter(), + ) { + y += y_i.mul(powers_of_alpha); + a += a_i.mul(powers_of_alpha); powers_of_alpha *= alpha; } - E::pairing(dkg.pvss_params.g_1, Y) == E::pairing(A, ek) + E::pairing(dkg.pvss_params.g, y) == E::pairing(a, ek) }, ); } - - let local_shares = { - print_time!("decrypt shares"); - - self.shares[dkg.me] - .iter() - .map(|p| p.mul(dkg.session_keypair.decryption_key)) - .collect::>() - }; - Ok(E::G2Projective::batch_normalization_into_affine( - &local_shares, - )) + true } } /* @@ -278,14 +239,14 @@ fn test_pvss() { #[test] fn test_pvss() { - let rng = &mut ark_std::test_rng(); + let mut rng = &mut ark_std::test_rng(); use ark_bls12_381::Bls12_381; type Fr = ::Fr; type G1 = ::G1Affine; type G2 = ::G2Affine; - let mut phi = DensePolynomial::::rand(8192 / 3, rng); - use ark_std::UniformRand; + let mut phi = DensePolynomial::::rand(2 * 128 / 3, &mut rng); + //use ark_std::UniformRand; let domain = ark_poly::Radix2EvaluationDomain::::new(8192) .ok_or_else(|| anyhow!("unable to construct domain")) .unwrap(); @@ -294,12 +255,10 @@ fn test_pvss() { let g_1 = G1::prime_subgroup_generator(); // commitment to coeffs - let coeffs = fast_multiexp(&phi.coeffs, g_1.into_projective()); + let _coeffs = fast_multiexp(&phi.coeffs, g_1.into_projective()); - use itertools::Itertools; - - let weight = 8192 / 150; - let shares = (0..150) + let weight = 128 / 4; + let shares = (0..4) .map(|participant| { let share_range = (participant * weight)..((participant + 1) * weight); @@ -310,4 +269,19 @@ fn test_pvss() { ) }) .collect::>(); + + // use group_threshold_cryptography::*; + // // let mut rng = test_rng + // let shares_num = 8192;(); + // let threshold = shares_num*2/3; + // let num_entities = 150; + + // let msg: &[u8] = "abc".as_bytes(); + + // // let (pubkey, privkey, _) = setup::(threshold, shares_num, num_entities); + + // let ciphertext = encrypt::(msg, pubkey, &mut rng); + // let plaintext = decrypt(&ciphertext, privkey); + + // assert!(msg == plaintext) } diff --git a/rust-toolchain b/rust-toolchain new file mode 100644 index 00000000..870bbe4e --- /dev/null +++ b/rust-toolchain @@ -0,0 +1 @@ +stable \ No newline at end of file diff --git a/src/dkg/pv.rs b/src/dkg/pv.rs deleted file mode 100644 index c8364a92..00000000 --- a/src/dkg/pv.rs +++ /dev/null @@ -1,214 +0,0 @@ -use crate::*; -use ark_ec::PairingEngine; -use ark_std::{end_timer, start_timer}; - -/// The DKG context that holds all of the local state for participating in the DKG -pub struct PubliclyVerifiableDKG -where - E: PairingEngine, -{ - pub ed_key: ed25519::Keypair, - pub params: Params, - pub pvss_params: PubliclyVerifiableParams, - pub session_keypair: PubliclyVerifiableKeypair, - pub participants: Vec>, - pub vss: BTreeMap>, - pub domain: ark_poly::Radix2EvaluationDomain, - pub state: DKGState, - pub me: usize, - pub local_shares: Vec, -} - -impl PubliclyVerifiableDKG -where - E: PairingEngine, -{ - /// Create a new DKG context to participate in the DKG - /// Every identity in the DKG is linked to an ed25519 public key; - /// `ed_key` is the local identity. - /// `params` contains the parameters of the DKG such as number of shares - /// `rng` is a cryptographic random number generator - pub fn new( - ed_key: ed25519::Keypair, - params: Params, - rng: &mut R, - ) -> Result { - use ark_std::UniformRand; - let domain = ark_poly::Radix2EvaluationDomain::::new( - params.total_weight as usize, - ) - .ok_or_else(|| anyhow!("unable to construct domain"))?; - - Ok(Self { - ed_key, - session_keypair: PubliclyVerifiableKeypair::::new(rng), - params, - pvss_params: PubliclyVerifiableParams:: { - g_1: E::G1Projective::prime_subgroup_generator(), - u_hat_1: E::G2Affine::prime_subgroup_generator(), - }, - participants: vec![], - vss: BTreeMap::new(), - domain, - state: DKGState::::Init { - announce_messages: vec![], - }, - me: 0, // TODO: invalid value - //final_state: None, - local_shares: vec![], - }) - } - /// Create a new PVSS instance within this DKG session, contributing to the final key - /// `rng` is a cryptographic random number generator - /// Returns a PVSS sharing message to post on-chain - pub fn share( - &mut self, - rng: &mut R, - ) -> Result> { - use ark_std::UniformRand; - print_time!("PVSS Sharing"); - - let vss = - PubliclyVerifiableSS::::new(&E::Fr::rand(rng), &self, rng)?; - - let sharing = vss.clone(); - self.vss.insert(self.me as u32, vss); - - Ok(PubliclyVerifiableMessage::Sharing(sharing)) - } - /// Aggregate all received PVSS messages into a single message, prepared to post on-chain - pub fn aggregate(&mut self) -> PubliclyVerifiableMessage { - let pvss = PubliclyVerifiableSS::::aggregate(self, &self.vss); - PubliclyVerifiableMessage::Aggregate(pvss) - } - - /// Converts an ed25519 key to the index of that participant - //TODO: this is not a good workaround for finding dealer from ed_key - pub fn find_by_key(&self, ed_key: &ed25519::PublicKey) -> Option { - self.participants.iter().position(|p| p.ed_key == *ed_key) - } - - /// Call `finish_announce` once the Announcement phase is complete - /// Partitions the share domain among the announced participants - /// and begins the sharing phase of the DKG - pub fn finish_announce(&mut self) -> Result<()> { - if let DKGState::Init { announce_messages } = &mut self.state { - self.participants = - partition_domain(&self.params, announce_messages)?; - self.me = self - .find_by_key(&self.ed_key.public) - .ok_or_else(|| anyhow!("self not found"))?; - self.state = DKGState::Sharing { - finalized_weight: 0u32, - }; - } - Ok(()) - } - /// Returns the public key generated by the DKG - pub fn final_key(&self) -> E::G1Affine { - self.vss - .iter() - .map(|(_, vss)| vss.coeffs[0].into_projective()) - .sum::() - .into_affine() - } - - /// Create an `Announce` message - /// `stake`: the amount staked by this participant in the DKG - /// Returns an Announcement nessage to post on chain - pub fn announce(&mut self, stake: u64) -> SignedMessage { - SignedMessage::sign( - self.params.tau, - &PubliclyVerifiableMessage::Announce { - stake, - session_key: self.session_keypair.public(), - }, - &self.ed_key, - ) - } - - /// Handle a DKG related message posted on chain - /// `signer` is the ed25519 public key of the sender of the message - /// `payload` is the content of the message - pub fn handle_message( - &mut self, - signer: &ed25519::PublicKey, - payload: PubliclyVerifiableMessage, - ) -> Result> { - match payload { - PubliclyVerifiableMessage::Announce { stake, session_key } => { - if let DKGState::Init { announce_messages } = &mut self.state { - announce_messages.push( - PubliclyVerifiableAnnouncement:: { - stake, - session_key, - signer: *signer, - }, - ); - } - Ok(None) - } - PubliclyVerifiableMessage::Sharing(sharing) => { - if let DKGState::Sharing { finalized_weight } = self.state { - let dealer = self.find_by_key(signer).ok_or_else(|| { - anyhow!("received dealing from unknown dealer") - })? as u32; - if dealer != self.me as u32 { - if self.vss.contains_key(&dealer) { - return Err(anyhow!("Repeat dealer {}", dealer)); - } - self.vss.insert(dealer, sharing); - } - } - Ok(None) - } - PubliclyVerifiableMessage::Aggregate(vss) => { - if let DKGState::Sharing { finalized_weight } = self.state { - let minimum_weight = self.params.total_weight - //- self.params.failure_threshold - - self.params.security_threshold; - let (verified_weight, local_shares) = - vss.verify_aggregation(&self)?; - if verified_weight >= minimum_weight { - self.local_shares = local_shares; - self.state = DKGState::Success; - } else { - self.state = DKGState::Sharing { - finalized_weight: verified_weight, - }; - } - } - Ok(None) - } - _ => Err(anyhow!("Unknown message type for this DKG engine")), - } - } -} - -#[derive(Serialize, Deserialize, Clone, Debug)] -#[serde(bound = "")] -pub enum PubliclyVerifiableMessage { - Announce { - stake: u64, - session_key: PubliclyVerifiablePublicKey, - }, - #[serde(with = "ark_serde")] - Sharing(PubliclyVerifiableSS), - #[serde(with = "ark_serde")] - Aggregate(PubliclyVerifiableSS), -} - -#[derive(Clone, Debug)] -pub struct PubliclyVerifiableParticipant { - pub ed_key: ed25519::PublicKey, - pub session_key: PubliclyVerifiablePublicKey, - pub weight: u32, - pub share_range: std::ops::Range, -} - -#[derive(Debug, Clone)] -pub struct PubliclyVerifiableAnnouncement { - pub signer: ed25519::PublicKey, - pub session_key: PubliclyVerifiablePublicKey, - pub stake: u64, -} diff --git a/src/primitives/keypair.rs b/src/primitives/keypair.rs deleted file mode 100644 index 8a7ede30..00000000 --- a/src/primitives/keypair.rs +++ /dev/null @@ -1,43 +0,0 @@ -use crate::*; -use chacha20poly1305::aead::{generic_array::GenericArray, Aead, NewAead}; - -use ark_ec::PairingEngine; - -#[derive(Serialize, Deserialize, Copy, Clone, Debug)] -pub struct PubliclyVerifiablePublicKey -where - E: PairingEngine, -{ - #[serde(with = "crate::ark_serde")] - pub encryption_key: E::G2Affine, -} - -#[derive(Clone)] -pub struct PubliclyVerifiableKeypair -where - E: PairingEngine, -{ - pub decryption_key: E::Fr, -} - -impl PubliclyVerifiableKeypair -where - E: PairingEngine, -{ - /// Returns the public session key for the publicly verifiable DKG participant - pub fn public(&self) -> PubliclyVerifiablePublicKey { - PubliclyVerifiablePublicKey:: { - encryption_key: E::G2Affine::prime_subgroup_generator() - .mul(self.decryption_key) - .into_affine(), - } - } - - /// Creates a new ephemeral session key for participating in the DKG - pub fn new(rng: &mut R) -> Self { - use ark_std::UniformRand; - Self { - decryption_key: E::Fr::rand(rng), - } - } -} diff --git a/tpke/Cargo.toml b/tpke/Cargo.toml index 79b45f7b..6b71d6d5 100644 --- a/tpke/Cargo.toml +++ b/tpke/Cargo.toml @@ -12,8 +12,8 @@ readme = "README.md" hex = "=0.4.3" rand_core = "0.6" rand = "0.8" -rayon = "=1.5.0" -thiserror = "=1.0.26" +rayon = "1.5" +thiserror = "=1.0.29" anyhow = "=1.0" blake2b_simd = "=0.5.11" @@ -28,16 +28,9 @@ ark-bls12-381 = "0.3" itertools="0.10" [dev-dependencies] -criterion = "=0.3.4" - -[profile.test] -opt-level = 3 +criterion = "0.3" [[bench]] name = "benchmarks" harness = false -[profile.bench] -opt-level = 3 -debug = true - diff --git a/tpke/benches/benchmarks.rs b/tpke/benches/benchmarks.rs index d428951b..0a93cc50 100644 --- a/tpke/benches/benchmarks.rs +++ b/tpke/benches/benchmarks.rs @@ -5,101 +5,110 @@ pub fn bench_decryption(c: &mut Criterion) { use rand::SeedableRng; use rand_core::RngCore; + #[allow(dead_code)] const NUM_OF_TX: usize = 1000; - fn share_combine_bench(num_msg: usize, num_shares: usize, num_entities: usize, msg_size: usize) -> impl Fn() { + fn share_combine_bench( + num_msg: usize, + num_shares: usize, + num_entities: usize, + msg_size: usize, + ) -> impl Fn() { let rng = &mut rand::rngs::StdRng::seed_from_u64(0); type E = ark_bls12_381::Bls12_381; let threshold = num_shares * 2 / 3; - let (pubkey, _, contexts) = setup::(threshold, num_shares, num_entities); + let (pubkey, _, contexts) = + setup::(threshold, num_shares, num_entities); // let mut messages: Vec<[u8; NUM_OF_TX]> = vec![]; let mut messages: Vec> = vec![]; let mut ciphertexts: Vec> = vec![]; - let mut dec_shares: Vec>> = Vec::with_capacity(ciphertexts.len()); + let mut dec_shares: Vec>> = + Vec::with_capacity(ciphertexts.len()); for j in 0..num_msg { // let mut msg: [u8; NUM_OF_TX] = [0u8; NUM_OF_TX]; - let mut msg: Vec = vec![]; - for _ in 0..msg_size { - msg.push(0u8); - } + let mut msg: Vec = vec![0u8; msg_size]; rng.fill_bytes(&mut msg[..]); messages.push(msg.clone()); ciphertexts.push(encrypt::<_, E>(&messages[j], pubkey, rng)); dec_shares.push(Vec::with_capacity(threshold)); - for i in 0..num_entities { - dec_shares[j].push(contexts[i].create_share(&ciphertexts[j])); + for ctx in contexts.iter().take(num_entities) { + dec_shares[j].push(ctx.create_share(&ciphertexts[j])); } } - let prepared_blinded_key_shares = contexts[0].prepare_combine(&dec_shares[0]); + let prepared_blinded_key_shares = + contexts[0].prepare_combine(&dec_shares[0]); - let share_combine_prepared = move || { + move || { let c: Vec> = ciphertexts.clone(); let shares: Vec>> = dec_shares.clone(); for i in 0..ciphertexts.len() { - black_box(contexts[0].share_combine( - &c[i], - &shares[i], - &prepared_blinded_key_shares, - )); + black_box( + contexts[0].share_combine( + &shares[i], + &prepared_blinded_key_shares, + ), + ); } - }; - - share_combine_prepared + } } - fn block_propose_bench(num_msg: usize, num_shares: usize, num_entities: usize, msg_size: usize) -> impl Fn() { + fn block_propose_bench( + num_msg: usize, + num_shares: usize, + num_entities: usize, + msg_size: usize, + ) -> impl Fn() { let rng = &mut rand::rngs::StdRng::seed_from_u64(0); type E = ark_bls12_381::Bls12_381; let threshold = num_shares * 2 / 3; - let (pubkey, _, contexts) = setup::(threshold, num_shares, num_entities); + let (pubkey, _, contexts) = + setup::(threshold, num_shares, num_entities); // let mut messages: Vec<[u8; NUM_OF_TX]> = vec![]; let mut messages: Vec> = vec![]; let mut ciphertexts: Vec> = vec![]; - let mut dec_shares: Vec>> = Vec::with_capacity(ciphertexts.len()); + let mut dec_shares: Vec>> = + Vec::with_capacity(ciphertexts.len()); for j in 0..num_msg { // let mut msg: [u8; NUM_OF_TX] = [0u8; NUM_OF_TX]; - let mut msg: Vec = vec![]; - for _ in 0..msg_size { - msg.push(0u8); - } + let mut msg: Vec = vec![0u8; msg_size]; rng.fill_bytes(&mut msg); messages.push(msg.clone()); ciphertexts.push(encrypt::<_, E>(&messages[j], pubkey, rng)); dec_shares.push(Vec::with_capacity(threshold)); - for i in 0..num_entities { - dec_shares[j].push(contexts[i].create_share(&ciphertexts[j])); + for ctx in contexts.iter().take(num_entities) { + dec_shares[j].push(ctx.create_share(&ciphertexts[j])); } } - let block_proposer_prepared = move || { + move || { let rng = &mut ark_std::test_rng(); let c: Vec> = ciphertexts.clone(); let shares: Vec>> = dec_shares.clone(); contexts[0].batch_verify_decryption_shares(&c, &shares, rng); - let prepared_blinded_key_shares = contexts[0].prepare_combine(&dec_shares[0]); + let prepared_blinded_key_shares = + contexts[0].prepare_combine(&dec_shares[0]); for i in 0..ciphertexts.len() { - black_box(contexts[0].share_combine( - &c[i], - &shares[i], - &prepared_blinded_key_shares, - )); + black_box( + contexts[0].share_combine( + &shares[i], + &prepared_blinded_key_shares, + ), + ); } - }; - - block_proposer_prepared + } } let mut group = c.benchmark_group("TPKE"); diff --git a/tpke/src/ciphertext.rs b/tpke/src/ciphertext.rs index ace4abda..72b806a5 100644 --- a/tpke/src/ciphertext.rs +++ b/tpke/src/ciphertext.rs @@ -1,6 +1,10 @@ -use crate::*; +use ark_ec::{AffineCurve, PairingEngine}; +use ark_ff::{One, ToBytes, UniformRand}; use chacha20::cipher::{NewCipher, StreamCipher}; use chacha20::{ChaCha20, Key, Nonce}; +use rand_core::RngCore; + +use crate::{construct_tag_hash, hash_to_g2}; #[derive(Clone, Debug)] pub struct Ciphertext { @@ -19,7 +23,6 @@ impl Ciphertext { ]) == E::Fqk::one() } fn construct_tag_hash(&self) -> E::G2Affine { - use ark_ff::ToBytes; let mut hash_input = Vec::::new(); self.nonce.write(&mut hash_input).unwrap(); hash_input.extend_from_slice(&self.ciphertext); @@ -57,7 +60,10 @@ pub fn encrypt( pub fn check_ciphertext_validity(c: &Ciphertext) -> bool { let g_inv = E::G1Prepared::from(-E::G1Affine::prime_subgroup_generator()); - let hash_g2 = E::G2Prepared::from(construct_tag_hash::(c.nonce, &c.ciphertext[..])); + let hash_g2 = E::G2Prepared::from(construct_tag_hash::( + c.nonce, + &c.ciphertext[..], + )); E::product_of_pairings(&[ (E::G1Prepared::from(c.nonce), hash_g2), @@ -65,7 +71,10 @@ pub fn check_ciphertext_validity(c: &Ciphertext) -> bool { ]) == E::Fqk::one() } -pub fn decrypt(ciphertext: &Ciphertext, privkey: E::G2Affine) -> Vec { +pub fn decrypt( + ciphertext: &Ciphertext, + privkey: E::G2Affine, +) -> Vec { let s = E::product_of_pairings(&[( E::G1Prepared::from(ciphertext.nonce), E::G2Prepared::from(privkey), diff --git a/tpke/src/combine.rs b/tpke/src/combine.rs index 84ed2cc2..700c3ff3 100644 --- a/tpke/src/combine.rs +++ b/tpke/src/combine.rs @@ -1,26 +1,33 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] use crate::*; use ark_ec::ProjectiveCurve; impl PrivateDecryptionContext { - pub fn prepare_combine(&self, shares: &[DecryptionShare]) -> Vec { + pub fn prepare_combine( + &self, + shares: &[DecryptionShare], + ) -> Vec { let mut domain = vec![]; - let mut N_0 = E::Fr::one(); - for D_i in shares.iter() { + let mut n_0 = E::Fr::one(); + for d_i in shares.iter() { domain.extend( - self.public_decryption_contexts[D_i.decryptor_index] + self.public_decryption_contexts[d_i.decryptor_index] .domain .iter(), ); - N_0 *= self.public_decryption_contexts[D_i.decryptor_index].lagrange_N_0; + n_0 *= self.public_decryption_contexts[d_i.decryptor_index] + .lagrange_n_0; } let s = SubproductDomain::::new(domain); let mut lagrange = s.inverse_lagrange_coefficients(); - ark_ff::batch_inversion_and_mul(&mut lagrange, &N_0); + ark_ff::batch_inversion_and_mul(&mut lagrange, &n_0); let mut start = 0usize; shares .iter() - .map(|D_i| { - let decryptor = &self.public_decryption_contexts[D_i.decryptor_index]; + .map(|d_i| { + let decryptor = + &self.public_decryption_contexts[d_i.decryptor_index]; let end = start + decryptor.domain.len(); let lagrange_slice = &lagrange[start..end]; start = end; @@ -29,7 +36,9 @@ impl PrivateDecryptionContext { lagrange_slice.iter(), decryptor.blinded_key_shares.blinded_key_shares.iter() //decryptor.blinded_key_shares.window_tables.iter() ) - .map(|(lambda, blinded_key_share)| blinded_key_share.mul(*lambda)) + .map(|(lambda, blinded_key_share)| { + blinded_key_share.mul(*lambda) + }) /*.map(|(lambda, base_table)| { FixedBaseMSM::multi_scalar_mul::( self.scalar_bits, @@ -46,16 +55,17 @@ impl PrivateDecryptionContext { } pub fn share_combine( &self, - ciphertext: &Ciphertext, shares: &[DecryptionShare], prepared_key_shares: &[E::G2Prepared], ) -> E::Fqk { let mut pairing_product: Vec<(E::G1Prepared, E::G2Prepared)> = vec![]; - for (D_i, blinded_key_share) in izip!(shares, prepared_key_shares.iter()) { + for (d_i, blinded_key_share) in + izip!(shares, prepared_key_shares.iter()) + { // e(D_i, [b*omega_i^-1] Z_{i,omega_i}) pairing_product.push(( - E::G1Prepared::from(D_i.decryption_share), + E::G1Prepared::from(d_i.decryption_share), blinded_key_share.clone(), )); } @@ -66,15 +76,14 @@ impl PrivateDecryptionContext { #[cfg(test)] mod tests { - type E = ark_bls12_381::Bls12_381; type Fr = ::Fr; #[test] fn test_lagrange() { - use ark_ff; use ark_poly::EvaluationDomain; use ark_std::One; - let fft_domain = ark_poly::Radix2EvaluationDomain::::new(500).unwrap(); + let fft_domain = + ark_poly::Radix2EvaluationDomain::::new(500).unwrap(); let mut domain = Vec::with_capacity(500); let mut point = Fr::one(); @@ -82,13 +91,13 @@ mod tests { domain.push(point); point *= fft_domain.group_gen; } - let mut N_0 = Fr::one(); - let mut lagrange_N_0 = domain.iter().product::(); + + let mut lagrange_n_0 = domain.iter().product::(); if domain.len() % 2 == 1 { - lagrange_N_0 = -lagrange_N_0; + lagrange_n_0 = -lagrange_n_0; } let s = crate::subproductdomain::SubproductDomain::::new(domain); let mut lagrange = s.inverse_lagrange_coefficients(); - ark_ff::batch_inversion_and_mul(&mut lagrange, &lagrange_N_0); + ark_ff::batch_inversion_and_mul(&mut lagrange, &lagrange_n_0); } } diff --git a/tpke/src/context.rs b/tpke/src/context.rs index 299993fd..d5c79b7f 100644 --- a/tpke/src/context.rs +++ b/tpke/src/context.rs @@ -1,14 +1,15 @@ use crate::*; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PublicDecryptionContext { pub domain: Vec, pub public_key_shares: PublicKeyShares, pub blinded_key_shares: BlindedKeyShares, // This decrypter's contribution to N(0), namely (-1)^|domain| * \prod_i omega_i - pub lagrange_N_0: E::Fr, + pub lagrange_n_0: E::Fr, } +#[derive(Debug)] pub struct PrivateDecryptionContext { pub index: usize, pub b: E::Fr, diff --git a/tpke/src/decryption.rs b/tpke/src/decryption.rs index 2bb33ca2..d694fd7a 100644 --- a/tpke/src/decryption.rs +++ b/tpke/src/decryption.rs @@ -1,3 +1,5 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] use crate::*; use ark_ec::ProjectiveCurve; @@ -8,7 +10,10 @@ pub struct DecryptionShare { } impl PrivateDecryptionContext { - pub fn create_share(&self, ciphertext: &Ciphertext) -> DecryptionShare { + pub fn create_share( + &self, + ciphertext: &Ciphertext, + ) -> DecryptionShare { let decryption_share = ciphertext.nonce.mul(self.b_inv).into_affine(); DecryptionShare { @@ -29,8 +34,8 @@ impl PrivateDecryptionContext { // Get [b_i] H for each of the decryption shares let blinding_keys = shares[0] .iter() - .map(|D| { - self.public_decryption_contexts[D.decryptor_index] + .map(|d| { + self.public_decryption_contexts[d.decryptor_index] .blinded_key_shares .blinding_key_prepared .clone() @@ -51,7 +56,7 @@ impl PrivateDecryptionContext { .collect::>(); // Compute \sum_j [ \sum_i \alpha_{i,j} ] U_j - let sum_U_j = E::G1Prepared::from( + let sum_u_j = E::G1Prepared::from( izip!(ciphertexts.iter(), sum_alpha_i.iter()) .map(|(c, alpha_j)| c.nonce.mul(*alpha_j)) .sum::() @@ -59,20 +64,23 @@ impl PrivateDecryptionContext { ); // e(\sum_j [ \sum_i \alpha_{i,j} ] U_j, -H) - pairings.push((sum_U_j, self.h_inv.clone())); + pairings.push((sum_u_j, self.h_inv.clone())); - let mut sum_D_j = vec![E::G1Projective::zero(); num_shares]; + let mut sum_d_j = vec![E::G1Projective::zero(); num_shares]; // sum_D_j = { [\sum_j \alpha_{i,j} ] D_i } - for (D, alpha_j) in izip!(shares.iter(), alpha_ij.iter()) { - for (sum_alpha_D_i, Dij, alpha) in izip!(sum_D_j.iter_mut(), D.iter(), alpha_j.iter()) { - *sum_alpha_D_i += Dij.decryption_share.mul(*alpha); + for (d, alpha_j) in izip!(shares.iter(), alpha_ij.iter()) { + for (sum_alpha_d_i, d_ij, alpha) in + izip!(sum_d_j.iter_mut(), d.iter(), alpha_j.iter()) + { + *sum_alpha_d_i += d_ij.decryption_share.mul(*alpha); } } // e([\sum_j \alpha_{i,j} ] D_i, B_i) - for (D_i, B_i) in izip!(sum_D_j.iter(), blinding_keys.iter()) { - pairings.push((E::G1Prepared::from(D_i.into_affine()), B_i.clone())); + for (d_i, b_i) in izip!(sum_d_j.iter(), blinding_keys.iter()) { + pairings + .push((E::G1Prepared::from(d_i.into_affine()), b_i.clone())); } E::product_of_pairings(&pairings) == E::Fqk::one() diff --git a/tpke/src/hash_to_curve.rs b/tpke/src/hash_to_curve.rs index ecdbfad1..d158bde5 100644 --- a/tpke/src/hash_to_curve.rs +++ b/tpke/src/hash_to_curve.rs @@ -1,6 +1,7 @@ #![allow(non_snake_case)] #![allow(clippy::many_single_char_names)] #![allow(clippy::zero_prefixed_literal)] +#![allow(dead_code)] use ark_serialize::CanonicalDeserialize; use miracl_core::bls12381::big::BIG; @@ -17,6 +18,7 @@ fn ceil(a: usize, b: usize) -> usize { (a - 1) / b + 1 } +#[allow(dead_code)] fn hash_to_field_bls12381( hash: usize, hlen: usize, @@ -80,6 +82,7 @@ fn hash_to_field2_bls12381( u } +#[allow(dead_code)] pub fn htp_bls12381_g1(msg: &[u8]) -> ark_bls12_381::G1Affine { let dst = "QUUX-V01-CS02-with-BLS12381G1_XMD:SHA-256_SSWU_RO_".as_bytes(); let u = hash_to_field_bls12381(hmac::MC_SHA2, ecp::HASH_TYPE, dst, msg, 2); @@ -136,11 +139,13 @@ mod tests { hex::decode_to_slice(expected_hex_string, &mut expected_compressed) .expect("Failed to decode hex"); - let mut expected_compressed_rev = expected_compressed.clone(); + let mut expected_compressed_rev = expected_compressed; expected_compressed_rev[0] &= (1 << 5) - 1; expected_compressed_rev.reverse(); - let expected = ark_bls12_381::G1Affine::deserialize(&expected_compressed_rev[..]).unwrap(); + let expected = + ark_bls12_381::G1Affine::deserialize(&expected_compressed_rev[..]) + .unwrap(); let res = htp_bls12381_g1(msg); @@ -152,11 +157,13 @@ mod tests { hex::decode_to_slice(expected_hex_string, &mut expected_compressed) .expect("Failed to decode hex"); - let mut expected_compressed_rev = expected_compressed.clone(); + let mut expected_compressed_rev = expected_compressed; expected_compressed_rev[0] &= (1 << 5) - 1; expected_compressed_rev.reverse(); - let expected = ark_bls12_381::G2Affine::deserialize(&expected_compressed_rev[..]).unwrap(); + let expected = + ark_bls12_381::G2Affine::deserialize(&expected_compressed_rev[..]) + .unwrap(); let res = htp_bls12381_g2(msg); diff --git a/tpke/src/key_share.rs b/tpke/src/key_share.rs index fa092649..9c9e05f9 100644 --- a/tpke/src/key_share.rs +++ b/tpke/src/key_share.rs @@ -1,17 +1,20 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] + use crate::*; use ark_ec::ProjectiveCurve; use itertools::Itertools; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PublicKeyShares { pub public_key_shares: Vec, // A_{i, \omega_i} } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct BlindedKeyShares { - pub blinding_key: E::G2Affine, // [b] H - pub blinding_key_prepared: E::G2Prepared, // [b] H - pub blinded_key_shares: Vec, // [b] Z_{i, \omega_i} + pub blinding_key: E::G2Affine, // [b] H + pub blinding_key_prepared: E::G2Prepared, // [b] H + pub blinded_key_shares: Vec, // [b] Z_{i, \omega_i} pub window_tables: Vec>, // [b*omega_i^-1] Z_{i, \omega_i} } @@ -22,10 +25,13 @@ impl BlindedKeyShares { rng: &mut R, ) -> bool { let g = E::G1Affine::prime_subgroup_generator(); - let alpha = E::Fr::rand(rng); - let alpha_i = generate_random::<_, E>(public_key_shares.public_key_shares.len(), rng); + let _alpha = E::Fr::rand(rng); + let alpha_i = generate_random::<_, E>( + public_key_shares.public_key_shares.len(), + rng, + ); - let alpha_A_i = E::G1Prepared::from( + let alpha_a_i = E::G1Prepared::from( g + public_key_shares .public_key_shares .iter() @@ -35,7 +41,7 @@ impl BlindedKeyShares { .into_affine(), ); - let alpha_Z_i = E::G2Prepared::from( + let alpha_z_i = E::G2Prepared::from( self.blinding_key + self .blinded_key_shares @@ -47,10 +53,11 @@ impl BlindedKeyShares { ); E::product_of_pairings(&[ - (E::G1Prepared::from(-g), alpha_Z_i), - (alpha_A_i, E::G2Prepared::from(self.blinding_key)), + (E::G1Prepared::from(-g), alpha_z_i), + (alpha_a_i, E::G2Prepared::from(self.blinding_key)), ]) == E::Fqk::one() } + pub fn get_window_table( &self, window_size: usize, @@ -67,12 +74,14 @@ impl BlindedKeyShares { }) .collect::>() } + pub fn multiply_by_omega_inv(&mut self, domain_inv: &[E::Fr]) { - izip!(self.blinded_key_shares.iter_mut(), domain_inv.iter()) - .for_each(|(key, omega_inv)| *key = key.mul(-*omega_inv).into_affine()) + izip!(self.blinded_key_shares.iter_mut(), domain_inv.iter()).for_each( + |(key, omega_inv)| *key = key.mul(-*omega_inv).into_affine(), + ) } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct BlindedKeyShareWindowTable { pub window_table: Vec>, } @@ -84,7 +93,8 @@ pub struct PrivateKeyShare { impl PrivateKeyShare { pub fn blind(&self, b: E::Fr) -> BlindedKeyShares { - let blinding_key = E::G2Affine::prime_subgroup_generator().mul(b).into_affine(); + let blinding_key = + E::G2Affine::prime_subgroup_generator().mul(b).into_affine(); BlindedKeyShares:: { blinding_key, blinding_key_prepared: E::G2Prepared::from(blinding_key), diff --git a/tpke/src/lib.rs b/tpke/src/lib.rs index adeb9c05..0d193565 100644 --- a/tpke/src/lib.rs +++ b/tpke/src/lib.rs @@ -1,14 +1,15 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] use crate::hash_to_curve::htp_bls12381_g2; use crate::subproductdomain::SubproductDomain; use ark_ec::{msm::FixedBaseMSM, AffineCurve, PairingEngine}; use ark_ff::{Field, One, PrimeField, ToBytes, UniformRand, Zero}; use ark_poly::EvaluationDomain; -use ark_poly::{univariate::DensePolynomial, Polynomial, UVPolynomial}; +use ark_poly::{univariate::DensePolynomial, UVPolynomial}; use ark_serialize::CanonicalSerialize; use itertools::izip; use rand_core::RngCore; -use rayon::prelude::*; use std::usize; use thiserror::Error; @@ -53,7 +54,10 @@ fn hash_to_g2(message: &[u8]) -> T { T::deserialize(&point_ser[..]).unwrap() } -fn construct_tag_hash(u: E::G1Affine, stream_ciphertext: &[u8]) -> E::G2Affine { +fn construct_tag_hash( + u: E::G1Affine, + stream_ciphertext: &[u8], +) -> E::G2Affine { let mut hash_input = Vec::::new(); u.write(&mut hash_input).unwrap(); hash_input.extend_from_slice(stream_ciphertext); @@ -69,14 +73,15 @@ pub fn setup( let rng = &mut ark_std::test_rng(); let g = E::G1Affine::prime_subgroup_generator(); let h = E::G2Affine::prime_subgroup_generator(); - let g_inv = E::G1Prepared::from(-g); - let h_inv = E::G2Prepared::from(-h); + let _g_inv = E::G1Prepared::from(-g); + let _h_inv = E::G2Prepared::from(-h); assert!(shares_num >= threshold); let threshold_poly = DensePolynomial::::rand(threshold - 1, rng); - - let fft_domain = ark_poly::Radix2EvaluationDomain::::new(shares_num).unwrap(); + let fft_domain = + ark_poly::Radix2EvaluationDomain::::new(shares_num).unwrap(); let evals = threshold_poly.evaluate_over_domain_by_ref(fft_domain); + let mut domain_points = Vec::with_capacity(shares_num); let mut point = E::Fr::one(); let mut domain_points_inv = Vec::with_capacity(shares_num); @@ -92,8 +97,10 @@ pub fn setup( let window_size = FixedBaseMSM::get_mul_window_size(100); let scalar_bits = E::Fr::size_in_bits(); - let pubkey_shares = subproductdomain::fast_multiexp(&evals.evals, g.into_projective()); - let privkey_shares = subproductdomain::fast_multiexp(&evals.evals, h.into_projective()); + let pubkey_shares = + subproductdomain::fast_multiexp(&evals.evals, g.into_projective()); + let privkey_shares = + subproductdomain::fast_multiexp(&evals.evals, h.into_projective()); let x = threshold_poly.coeffs[0]; let pubkey = g.mul(x); @@ -114,7 +121,7 @@ pub fn setup( private_key_shares: private.to_vec(), }; let b = E::Fr::rand(rng); - let mut blinded_key_shares = private_key_share.blind(b.clone()); + let mut blinded_key_shares = private_key_share.blind(b); blinded_key_shares.multiply_by_omega_inv(domain_inv); /*blinded_key_shares.window_tables = blinded_key_shares.get_window_table(window_size, scalar_bits, domain_inv);*/ @@ -130,9 +137,9 @@ pub fn setup( scalar_bits, window_size, }); - let mut lagrange_N_0 = domain.iter().product::(); + let mut lagrange_n_0 = domain.iter().product::(); if domain.len() % 2 == 1 { - lagrange_N_0 = -lagrange_N_0; + lagrange_n_0 = -lagrange_n_0; } public_contexts.push(PublicDecryptionContext:: { domain: domain.to_vec(), @@ -140,7 +147,7 @@ pub fn setup( public_key_shares: public.to_vec(), }, blinded_key_shares, - lagrange_N_0, + lagrange_n_0, }); } for private in private_contexts.iter_mut() { @@ -150,7 +157,10 @@ pub fn setup( (pubkey.into(), privkey.into(), private_contexts) } -pub fn generate_random(n: usize, rng: &mut R) -> Vec { +pub fn generate_random( + n: usize, + rng: &mut R, +) -> Vec { (0..n).map(|_| E::Fr::rand(rng)).collect::>() } @@ -170,9 +180,11 @@ mod tests { let msg: &[u8] = "abc".as_bytes(); - let (pubkey, privkey, _) = setup::(threshold, shares_num, num_entities); + let (pubkey, privkey, _) = + setup::(threshold, shares_num, num_entities); - let ciphertext = encrypt::(msg, pubkey, &mut rng); + let ciphertext = + encrypt::(msg, pubkey, &mut rng); let plaintext = decrypt(&ciphertext, privkey); assert!(msg == plaintext) @@ -186,7 +198,8 @@ mod tests { let num_entities = 5; let msg: &[u8] = "abc".as_bytes(); - let (pubkey, privkey, contexts) = setup::(threshold, shares_num, num_entities); + let (pubkey, _privkey, contexts) = + setup::(threshold, shares_num, num_entities); let ciphertext = encrypt::<_, E>(msg, pubkey, rng); let mut shares: Vec> = vec![]; @@ -199,7 +212,8 @@ mod tests { .verify_blinding(&pub_context.public_key_shares, rng)); }*/ let prepared_blinded_key_shares = contexts[0].prepare_combine(&shares); - let s = contexts[0].share_combine(&ciphertext, &shares, &prepared_blinded_key_shares); + let s = + contexts[0].share_combine(&shares, &prepared_blinded_key_shares); let plaintext = decrypt_with_shared_secret(&ciphertext, &s); assert!(plaintext == msg) diff --git a/tpke/src/subproductdomain.rs b/tpke/src/subproductdomain.rs index 95fedd8e..2d7335bf 100644 --- a/tpke/src/subproductdomain.rs +++ b/tpke/src/subproductdomain.rs @@ -1,3 +1,6 @@ +#![allow(non_snake_case)] +#![allow(dead_code)] + use ark_ec::{msm::FixedBaseMSM, PairingEngine, ProjectiveCurve}; use ark_ff::{FftField, Field, PrimeField, Zero}; use ark_poly::polynomial::univariate::DensePolynomial as Poly; @@ -13,7 +16,8 @@ pub fn fast_multiexp( let window_size = FixedBaseMSM::get_mul_window_size(scalars.len()); let scalar_bits = Projective::ScalarField::size_in_bits(); - let base_table = FixedBaseMSM::get_window_table(scalar_bits, window_size, base); + let base_table = + FixedBaseMSM::get_window_table(scalar_bits, window_size, base); let exp = FixedBaseMSM::multi_scalar_mul::( scalar_bits, @@ -24,9 +28,12 @@ pub fn fast_multiexp( Projective::batch_normalization_into_affine(&exp) } +#[allow(dead_code)] pub fn poly_from_scalar(s: &F) -> Poly { Poly:: { coeffs: vec![*s] } } + +#[allow(dead_code)] pub fn moduli_from_scalar(s: &F) -> Poly { Poly:: { coeffs: vec![-*s, F::one()], @@ -76,7 +83,10 @@ pub fn rev(f: &mut Poly, m: usize) { /// GG Algorithm 9.5 /// Divide f by g in nearly linear time -pub fn fast_divide_monic(f: &Poly, g: &Poly) -> (Poly, Poly) { +pub fn fast_divide_monic( + f: &Poly, + g: &Poly, +) -> (Poly, Poly) { //assert_eq!(g.coeffs.last(), F::one()); //TODO: check monic condition if f.coeffs().len() < g.coeffs().len() { @@ -126,20 +136,27 @@ impl SubproductDomain { let prime = derivative::(&t.m); SubproductDomain { u, t, prime } } + + #[allow(dead_code)] /// Evaluate a polynomial f over the subproduct domain u pub fn evaluate(&self, f: &Poly) -> Vec { let mut evals = vec![F::zero(); self.u.len()]; self.t.evaluate(f, &self.u, &mut evals); evals } + + #[allow(dead_code)] /// Interpolate a polynomial f over the domain, such that f(u_i) = v_i pub fn interpolate(&self, v: &[F]) -> Poly { self.t.interpolate(&self.u, v) } + /// Compute the inverse of the lagrange coefficients necessary to interpolate over u pub fn inverse_lagrange_coefficients(&self) -> Vec { self.t.inverse_lagrange_coefficients(&self.u) } + + #[allow(dead_code)] /// Compute a linear combination of lagrange factors times c_i pub fn linear_combine(&self, c: &[F]) -> Poly { self.t.linear_combine(&self.u, &c) @@ -223,6 +240,8 @@ impl SubproductTree { left.evaluate(&r_0, u_0, t_0); right.evaluate(&r_1, u_1, t_1); } + + #[allow(dead_code)] /// Fast interpolate over this subproduct tree pub fn interpolate(&self, u: &[F], v: &[F]) -> Poly { let mut lagrange_coeff = self.inverse_lagrange_coefficients(u); @@ -233,6 +252,7 @@ impl SubproductTree { self.linear_combine(u, &lagrange_coeff) } + /// Fast compute lagrange coefficients over this subproduct tree pub fn inverse_lagrange_coefficients(&self, u: &[F]) -> Vec { //assert u.len() == degree of s.m @@ -244,6 +264,8 @@ impl SubproductTree { self.evaluate(&m_prime, u, &mut evals); evals } + + #[allow(dead_code)] /// GG Algorithm 10.9 /// Fast linear combination of moduli over this subproduct tree /// On input c = { c_0, ..., c_{n-1} } @@ -292,14 +314,18 @@ pub fn build_circulant( if n == coeffs.len() - 1 { circulant[0] = *coeffs.last().unwrap(); circulant[n] = *coeffs.last().unwrap(); - circulant[n + 1..n + 1 + coeffs.len() - 2].copy_from_slice(&coeffs[1..coeffs.len() - 1]); + circulant[n + 1..n + 1 + coeffs.len() - 2] + .copy_from_slice(&coeffs[1..coeffs.len() - 1]); } else { - circulant[n + 1..n + 1 + coeffs.len() - 1].copy_from_slice(&coeffs[1..]); + circulant[n + 1..n + 1 + coeffs.len() - 1] + .copy_from_slice(&coeffs[1..]); } circulant } + +#[allow(dead_code)] /// Computes the Toeplitz matrix of polynomial times the vector v -pub fn toeplitz_mul( +pub fn toeplitz_mul( polynomial: &Poly, v: &[E::G1Affine], size: usize, @@ -310,7 +336,9 @@ pub fn toeplitz_mul( let size = ark_std::cmp::max(size, m); let domain = ark_poly::Radix2EvaluationDomain::::new(2 * size) - .ok_or_else(|| anyhow::anyhow!("toeplitz multiplication on too large a domain"))?; + .ok_or_else(|| { + anyhow::anyhow!("toeplitz multiplication on too large a domain") + })?; let circulant_size = domain.size(); let toeplitz_size = circulant_size / 2;