From e0565ce17eb8a57d961342b13c1038ab87ef1675 Mon Sep 17 00:00:00 2001 From: Bogdan Opanchuk Date: Wed, 25 Dec 2024 11:09:54 -0800 Subject: [PATCH] Update KeyInit --- Cargo.lock | 460 ++++++++----------- synedrion/src/cggmp21/entities.rs | 34 +- synedrion/src/cggmp21/interactive_signing.rs | 18 +- synedrion/src/cggmp21/key_init.rs | 201 ++++++-- synedrion/src/www02/entities.rs | 15 +- 5 files changed, 388 insertions(+), 340 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33b32d0..990cb03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,24 +4,24 @@ version = 3 [[package]] name = "addr2line" -version = "0.21.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aho-corasick" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" dependencies = [ "memchr", ] @@ -83,23 +83,23 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.69" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -145,12 +145,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - [[package]] name = "block-buffer" version = "0.10.4" @@ -171,24 +165,21 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] -name = "cast" -version = "0.3.0" +name = "byteorder" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] -name = "cc" -version = "1.0.83" +name = "cast" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cfg-if" @@ -198,9 +189,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -209,15 +200,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", "half", @@ -225,18 +216,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.8" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" dependencies = [ "anstyle", "clap_lex", @@ -244,9 +235,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "cobs" @@ -268,9 +259,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -313,36 +304,34 @@ dependencies = [ [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset", - "scopeguard", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-bigint" @@ -425,9 +414,9 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", @@ -450,9 +439,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -489,18 +478,18 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "env_filter" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" dependencies = [ "log", ] [[package]] name = "env_logger" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" dependencies = [ "anstream", "anstyle", @@ -518,16 +507,6 @@ dependencies = [ "typeid", ] -[[package]] -name = "errno" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - [[package]] name = "ff" version = "0.13.0" @@ -551,9 +530,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", @@ -562,9 +541,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "group" @@ -579,9 +558,13 @@ dependencies = [ [[package]] name = "half" -version = "1.8.2" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] [[package]] name = "hashing-serializer" @@ -595,9 +578,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" @@ -622,13 +605,13 @@ checksum = "7a46645bbd70538861a90d0f26c31537cdf1e44aae99a794fb75a664b70951bc" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ "hermit-abi", - "rustix", - "windows-sys 0.48.0", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -648,16 +631,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -691,15 +675,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" - -[[package]] -name = "linux-raw-sys" -version = "0.4.11" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "log" @@ -739,26 +717,17 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memoffset" -version = "0.9.0" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -782,24 +751,24 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "overload" @@ -818,9 +787,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pkcs8" @@ -834,9 +803,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -847,24 +816,24 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] [[package]] name = "postcard" -version = "1.0.10" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" +checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8" dependencies = [ "cobs", "embedded-io 0.4.0", @@ -874,15 +843,18 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -928,9 +900,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -938,9 +910,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -948,14 +920,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", - "regex-syntax 0.8.2", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", ] [[package]] @@ -969,13 +941,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.2", + "regex-syntax 0.8.5", ] [[package]] @@ -986,9 +958,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rfc6979" @@ -1011,28 +983,15 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustix" -version = "0.38.24" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.48.0", -] +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "same-file" @@ -1043,12 +1002,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - [[package]] name = "sec1" version = "0.7.3" @@ -1076,9 +1029,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.214" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -1114,9 +1067,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -1125,11 +1078,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.134" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1212,9 +1166,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.85" +version = "2.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5023162dfcd14ef8f32034d8bcd4cc5ddc61ef7a247c024a33e24e1f24d21b56" +checksum = "d53cbcb5a243bd33b7858b1d7f4aca2153490815872d86d955d6ea29f743c035" dependencies = [ "proc-macro2", "quote", @@ -1297,9 +1251,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "serde", "tinyvec_macros", @@ -1313,9 +1267,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "pin-project-lite", @@ -1324,9 +1278,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -1382,9 +1336,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "utf8parse" @@ -1394,15 +1348,15 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", @@ -1416,23 +1370,23 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -1441,9 +1395,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1451,9 +1405,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", @@ -1464,15 +1418,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" -version = "0.3.65" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" dependencies = [ "js-sys", "wasm-bindgen", @@ -1496,11 +1450,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "winapi", + "windows-sys 0.59.0", ] [[package]] @@ -1511,11 +1465,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -1524,22 +1478,7 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -1548,46 +1487,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1600,24 +1521,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" @@ -1626,27 +1535,36 @@ checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] -name = "windows_x86_64_gnullvm" +name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +name = "zerocopy" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" +name = "zerocopy-derive" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "zeroize" diff --git a/synedrion/src/cggmp21/entities.rs b/synedrion/src/cggmp21/entities.rs index b2aa0a5..6119b02 100644 --- a/synedrion/src/cggmp21/entities.rs +++ b/synedrion/src/cggmp21/entities.rs @@ -24,12 +24,12 @@ use crate::{ /// The result of the KeyInit protocol. #[derive(Debug, Clone, Serialize, Deserialize)] pub struct KeyShare { - pub(crate) owner: I, + owner: I, /// Secret key share of this node. - pub(crate) secret_share: Secret, // `x_i` - pub(crate) public_shares: BTreeMap, // `X_j` + secret_share: Secret, // `x_i` + public_shares: BTreeMap, // `X_j` // TODO (#27): this won't be needed when Scalar/Point are a part of `P` - pub(crate) phantom: PhantomData

, + phantom: PhantomData

, } /// The result of the AuxGen protocol. @@ -125,7 +125,23 @@ pub(crate) struct PresigningValues { pub(crate) hat_cap_f: Ciphertext, } -impl KeyShare { +impl KeyShare { + pub(crate) fn new( + owner: I, + secret_share: Secret, + public_shares: BTreeMap, + ) -> Result { + if public_shares.values().sum::() == Point::IDENTITY { + return Err(LocalError::new("Key shares add up to zero")); + } + Ok(KeyShare { + owner, + secret_share, + public_shares, + phantom: PhantomData, + }) + } + /// Updates a key share with a change obtained from KeyRefresh protocol. pub fn update(self, change: KeyShareChange) -> Result { if self.owner != change.owner { @@ -217,6 +233,14 @@ impl KeyShare { &self.owner } + pub(crate) fn secret_share(&self) -> &Secret { + &self.secret_share + } + + pub(crate) fn public_shares(&self) -> &BTreeMap { + &self.public_shares + } + /// Returns the set of parties holding other shares from the set. pub fn all_parties(&self) -> BTreeSet { self.public_shares.keys().cloned().collect() diff --git a/synedrion/src/cggmp21/interactive_signing.rs b/synedrion/src/cggmp21/interactive_signing.rs index 164c233..96bc807 100644 --- a/synedrion/src/cggmp21/interactive_signing.rs +++ b/synedrion/src/cggmp21/interactive_signing.rs @@ -138,7 +138,7 @@ impl EntryPoint for InteractiveSigning { } let other_ids = key_share - .public_shares + .public_shares() .keys() .cloned() .collect::>() @@ -150,7 +150,7 @@ impl EntryPoint for InteractiveSigning { let ssid_hash = FofHasher::new_with_dst(b"ShareSetID") .chain_type::

() .chain(&shared_randomness) - .chain(&key_share.public_shares) + .chain(&key_share.public_shares()) .chain(&aux_info.public_aux) .finalize(); @@ -207,11 +207,11 @@ struct Context { impl Context where P: SchemeParams, - I: Ord + Debug, + I: Clone + Ord + Debug, { pub fn public_share(&self, i: &I) -> Result<&Point, LocalError> { self.key_share - .public_shares + .public_shares() .get(i) .ok_or_else(|| LocalError::new("Missing public_share for party Id {i:?}")) } @@ -491,7 +491,7 @@ impl Round for Round2 { let hat_s = Randomizer::random(rng, target_pk); let gamma = secret_signed_from_scalar::

(&self.context.gamma); - let x = secret_signed_from_scalar::

(&self.context.key_share.secret_share); + let x = secret_signed_from_scalar::

(self.context.key_share.secret_share()); let others_cap_k = self .all_cap_k @@ -502,7 +502,7 @@ impl Round for Round2 { let cap_d = others_cap_k * &gamma + Ciphertext::new_with_randomizer(target_pk, &-&beta, &s); let hat_cap_f = Ciphertext::new_with_randomizer(pk, &hat_beta, &hat_r); - let hat_cap_d = others_cap_k * &secret_signed_from_scalar::

(&self.context.key_share.secret_share) + let hat_cap_d = others_cap_k * &secret_signed_from_scalar::

(self.context.key_share.secret_share()) + Ciphertext::new_with_randomizer(target_pk, &-&hat_beta, &hat_s); let cap_g = self.all_cap_g.get(&self.context.my_id).ok_or(LocalError::new(format!( @@ -723,7 +723,7 @@ impl Round for Round2 { let hat_alpha_sum: SecretSigned<_> = payloads.values().map(|payload| &payload.hat_alpha).sum(); let hat_beta_sum: SecretSigned<_> = artifacts.values().map(|artifact| &artifact.hat_beta).sum(); - let chi = secret_signed_from_scalar::

(&self.context.key_share.secret_share) + let chi = secret_signed_from_scalar::

(self.context.key_share.secret_share()) * secret_signed_from_scalar::

(&self.context.k) + &hat_alpha_sum + &hat_beta_sum; @@ -1247,7 +1247,7 @@ impl Round for Round4 { let p_aff_g = AffGProof::

::new( rng, AffGSecretInputs { - x: &secret_signed_from_scalar::

(&self.context.key_share.secret_share), + x: &secret_signed_from_scalar::

(self.context.key_share.secret_share()), y: &values.hat_beta, rho: &values.hat_s, rho_y: &values.hat_r, @@ -1283,7 +1283,7 @@ impl Round for Round4 { // mul* proofs - let x = &self.context.key_share.secret_share; + let x = &self.context.key_share.secret_share(); let cap_x = self.context.public_share(&my_id)?; let rho = Randomizer::random(rng, pk); diff --git a/synedrion/src/cggmp21/key_init.rs b/synedrion/src/cggmp21/key_init.rs index f165b66..7b9e1f4 100644 --- a/synedrion/src/cggmp21/key_init.rs +++ b/synedrion/src/cggmp21/key_init.rs @@ -6,13 +6,14 @@ use alloc::{ collections::{BTreeMap, BTreeSet}, format, string::String, + vec::Vec, }; use core::{fmt::Debug, marker::PhantomData}; use manul::protocol::{ Artifact, BoxedRound, Deserializer, DirectMessage, EchoBroadcast, EntryPoint, FinalizeOutcome, LocalError, - NormalBroadcast, PartyId, Payload, Protocol, ProtocolError, ProtocolMessagePart, ProtocolValidationError, - ReceiveError, Round, RoundId, Serializer, + MessageValidationError, NormalBroadcast, PartyId, Payload, Protocol, ProtocolError, ProtocolMessagePart, + ProtocolValidationError, ReceiveError, Round, RoundId, Serializer, }; use rand_core::CryptoRngCore; use serde::{Deserialize, Serialize}; @@ -37,49 +38,154 @@ pub struct KeyInitProtocol(PhantomData<(P, I)>); impl Protocol for KeyInitProtocol { type Result = KeyShare; - type ProtocolError = KeyInitError; + type ProtocolError = KeyInitError; + + fn verify_echo_broadcast_is_invalid( + deserializer: &Deserializer, + round_id: RoundId, + message: &EchoBroadcast, + ) -> Result<(), MessageValidationError> { + match round_id { + r if r == RoundId::new(1) => message.verify_is_not::(deserializer), + r if r == RoundId::new(2) => message.verify_is_not::>(deserializer), + r if r == RoundId::new(3) => message.verify_is_some(), + _ => Err(MessageValidationError::InvalidEvidence("Invalid round number".into())), + } + } + + fn verify_normal_broadcast_is_invalid( + deserializer: &Deserializer, + round_id: RoundId, + message: &NormalBroadcast, + ) -> Result<(), MessageValidationError> { + match round_id { + r if r == RoundId::new(1) => message.verify_is_some(), + r if r == RoundId::new(2) => message.verify_is_some(), + r if r == RoundId::new(3) => message.verify_is_not::(deserializer), + _ => Err(MessageValidationError::InvalidEvidence("Invalid round number".into())), + } + } } /// Possible verifiable errors of the KeyGen protocol. #[derive(Debug, Clone, Copy, Serialize, Deserialize)] -pub enum KeyInitError { +pub struct KeyInitError { + error: KeyInitErrorEnum, + phantom: PhantomData<(P, I)>, +} + +impl KeyInitError { + fn new(error: KeyInitErrorEnum) -> Self { + Self { + error, + phantom: PhantomData, + } + } +} + +#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +enum KeyInitErrorEnum { /// A hash mismatch in Round 2. R2HashMismatch, /// Failed to verify `П^{sch}` in Round 3. R3InvalidSchProof, } -impl ProtocolError for KeyInitError { +impl ProtocolError for KeyInitError { fn description(&self) -> String { - unimplemented!() + (match self.error { + KeyInitErrorEnum::R2HashMismatch => { + "Round2: previously broadcasted hash does not match the received public data" + } + KeyInitErrorEnum::R3InvalidSchProof => "Round3: failed to verify the Schnorr proof", + }) + .into() } fn required_direct_messages(&self) -> BTreeSet { - unimplemented!() + [].into() } fn required_echo_broadcasts(&self) -> BTreeSet { - unimplemented!() + match self.error { + KeyInitErrorEnum::R2HashMismatch => [RoundId::new(1)].into(), + KeyInitErrorEnum::R3InvalidSchProof => [].into(), + } } fn required_combined_echos(&self) -> BTreeSet { - unimplemented!() + match self.error { + KeyInitErrorEnum::R2HashMismatch => [].into(), + KeyInitErrorEnum::R3InvalidSchProof => [RoundId::new(2)].into(), + } } fn verify_messages_constitute_error( &self, - _deserializer: &Deserializer, - _guilty_party: &I, - _shared_randomness: &[u8], - _echo_broadcast: EchoBroadcast, - _normal_broadcast: NormalBroadcast, + deserializer: &Deserializer, + guilty_party: &I, + shared_randomness: &[u8], + echo_broadcast: EchoBroadcast, + normal_broadcast: NormalBroadcast, _direct_message: DirectMessage, - _echo_broadcasts: BTreeMap, + echo_broadcasts: BTreeMap, _normal_broadcasts: BTreeMap, _direct_messages: BTreeMap, - _combined_echos: BTreeMap>, + combined_echos: BTreeMap>, ) -> Result<(), ProtocolValidationError> { - unimplemented!() + let sid_hash = FofHasher::new_with_dst(b"SID") + .chain_type::

() + .chain(&shared_randomness) + .finalize(); + + match self.error { + KeyInitErrorEnum::R2HashMismatch => { + let r1_serialized = echo_broadcasts.get(&RoundId::new(1)).ok_or_else(|| { + ProtocolValidationError::InvalidEvidence("Missing echo broadcast from Round 1".into()) + })?; + let r1_message = r1_serialized.deserialize::(deserializer)?; + let r2_message = echo_broadcast.deserialize::>(deserializer)?; + if r2_message.data.hash(&sid_hash, guilty_party) != r1_message.cap_v { + Ok(()) + } else { + Err(ProtocolValidationError::InvalidEvidence( + "The received hash is valid".into(), + )) + } + } + KeyInitErrorEnum::R3InvalidSchProof => { + let r2_combined = combined_echos.get(&RoundId::new(2)).ok_or_else(|| { + ProtocolValidationError::InvalidEvidence("Missing combined echos from Round 2".into()) + })?; + let r2_messages = r2_combined + .values() + .map(|echo| echo.deserialize::>(deserializer)) + .collect::, _>>()?; + + let r2_serialized = echo_broadcasts.get(&RoundId::new(2)).ok_or_else(|| { + ProtocolValidationError::InvalidEvidence("Missing echo broadcast from Round 2".into()) + })?; + let r2_message = r2_serialized.deserialize::>(deserializer)?; + + let mut rho = r2_message.data.rho; + for message in r2_messages { + rho ^= &message.data.rho; + } + + let r3_message = normal_broadcast.deserialize::(deserializer)?; + let aux = (&sid_hash, guilty_party, &rho); + if !r3_message + .psi + .verify(&r2_message.data.cap_a, &r2_message.data.cap_x, &aux) + { + Ok(()) + } else { + Err(ProtocolValidationError::InvalidEvidence( + "The Schnorr proof is valid".into(), + )) + } + } + } } } @@ -87,7 +193,7 @@ impl ProtocolError for KeyInitError { struct PublicData { cap_x: Point, cap_a: SchCommitment, - rid: BitVec, + rho: BitVec, u: BitVec, phantom: PhantomData

, } @@ -146,7 +252,7 @@ impl EntryPoint for KeyInit { // The public share let cap_x = x.mul_by_generator(); - let rid = BitVec::random(rng, P::SECURITY_PARAMETER); + let rho = BitVec::random(rng, P::SECURITY_PARAMETER); let tau = SchSecret::random(rng); let cap_a = SchCommitment::new(&tau); let u = BitVec::random(rng, P::SECURITY_PARAMETER); @@ -154,7 +260,7 @@ impl EntryPoint for KeyInit { let public_data = PublicData { cap_x, cap_a, - rid, + rho, u, phantom: PhantomData, }; @@ -188,7 +294,7 @@ struct Round1 { } #[derive(Debug, Clone, Serialize, Deserialize)] -struct Round1Message { +struct Round1EchoBroadcast { cap_v: HashOutput, } @@ -224,7 +330,7 @@ impl Round for Round1 { .context .public_data .hash(&self.context.sid_hash, &self.context.my_id); - EchoBroadcast::new(serializer, Round1Message { cap_v }) + EchoBroadcast::new(serializer, Round1EchoBroadcast { cap_v }) } fn receive_message( @@ -238,7 +344,7 @@ impl Round for Round1 { ) -> Result> { normal_broadcast.assert_is_none()?; direct_message.assert_is_none()?; - let echo = echo_broadcast.deserialize::(deserializer)?; + let echo = echo_broadcast.deserialize::(deserializer)?; Ok(Payload::new(Round1Payload { cap_v: echo.cap_v })) } @@ -268,7 +374,7 @@ struct Round2 { #[derive(Clone, Serialize, Deserialize)] #[serde(bound(serialize = "PublicData

: Serialize"))] #[serde(bound(deserialize = "PublicData

: for<'x> Deserialize<'x>"))] -struct Round2Message { +struct Round2EchoBroadcast { data: PublicData

, } @@ -302,7 +408,7 @@ impl Round for Round2 { ) -> Result { EchoBroadcast::new( serializer, - Round2Message { + Round2EchoBroadcast { data: self.context.public_data.clone(), }, ) @@ -319,14 +425,16 @@ impl Round for Round2 { ) -> Result> { normal_broadcast.assert_is_none()?; direct_message.assert_is_none()?; - let echo = echo_broadcast.deserialize::>(deserializer)?; + let echo = echo_broadcast.deserialize::>(deserializer)?; let cap_v = self .others_cap_v .get(from) .ok_or_else(|| LocalError::new(format!("Missing `V` for {from:?}")))?; if &echo.data.hash(&self.context.sid_hash, from) != cap_v { - return Err(ReceiveError::protocol(KeyInitError::R2HashMismatch)); + return Err(ReceiveError::protocol(KeyInitError::new( + KeyInitErrorEnum::R2HashMismatch, + ))); } Ok(Payload::new(Round2Payload { data: echo.data })) @@ -338,12 +446,12 @@ impl Round for Round2 { payloads: BTreeMap, _artifacts: BTreeMap, ) -> Result, LocalError> { - let mut rid = self.context.public_data.rid.clone(); + let mut rho = self.context.public_data.rho.clone(); let payloads = payloads.downcast_all::>()?; for payload in payloads.values() { - rid ^= &payload.data.rid; + rho ^= &payload.data.rho; } let others_data = payloads.into_iter().map(|(k, v)| (k, v.data)).collect(); @@ -351,7 +459,7 @@ impl Round for Round2 { Ok(FinalizeOutcome::AnotherRound(BoxedRound::new_dynamic(Round3 { context: self.context, others_data, - rid, + rho, phantom: PhantomData, }))) } @@ -361,12 +469,12 @@ impl Round for Round2 { struct Round3 { context: Context, others_data: BTreeMap>, - rid: BitVec, + rho: BitVec, phantom: PhantomData

, } #[derive(Clone, Serialize, Deserialize)] -struct Round3Message { +struct Round3Broadcast { psi: SchProof, } @@ -398,7 +506,7 @@ impl Round for Round3 { _rng: &mut impl CryptoRngCore, serializer: &Serializer, ) -> Result { - let aux = (&self.context.sid_hash, &self.context.my_id, &self.rid); + let aux = (&self.context.sid_hash, &self.context.my_id, &self.rho); let psi = SchProof::new( &self.context.tau, &self.context.x, @@ -406,7 +514,7 @@ impl Round for Round3 { &self.context.public_data.cap_x, &aux, ); - NormalBroadcast::new(serializer, Round3Message { psi }) + NormalBroadcast::new(serializer, Round3Broadcast { psi }) } fn receive_message( @@ -421,16 +529,18 @@ impl Round for Round3 { echo_broadcast.assert_is_none()?; direct_message.assert_is_none()?; - let bc = normal_broadcast.deserialize::(deserializer)?; + let bc = normal_broadcast.deserialize::(deserializer)?; let data = self .others_data .get(from) .ok_or_else(|| LocalError::new(format!("Missing data for {from:?}")))?; - let aux = (&self.context.sid_hash, from, &self.rid); + let aux = (&self.context.sid_hash, from, &self.rho); if !bc.psi.verify(&data.cap_a, &data.cap_x, &aux) { - return Err(ReceiveError::protocol(KeyInitError::R3InvalidSchProof)); + return Err(ReceiveError::protocol(KeyInitError::new( + KeyInitErrorEnum::R3InvalidSchProof, + ))); } Ok(Payload::empty()) } @@ -448,12 +558,13 @@ impl Round for Round3 { .map(|(k, v)| (k, v.cap_x)) .collect::>(); public_shares.insert(my_id.clone(), self.context.public_data.cap_x); - Ok(FinalizeOutcome::Result(KeyShare { - owner: my_id, - secret_share: self.context.x, - public_shares, - phantom: PhantomData, - })) + + // This can fail if the shares add up to zero. + // Can't really protect from it, and it should be extremely rare. + // If that happens one can only restart the whole thing. + let key_share = KeyShare::::new(my_id, self.context.x, public_shares)?; + + Ok(FinalizeOutcome::Result(key_share)) } } @@ -496,7 +607,7 @@ mod tests { let public_sets = shares .iter() - .map(|(id, share)| (*id, share.public_shares.clone())) + .map(|(id, share)| (*id, share.public_shares().clone())) .collect::>(); assert!(public_sets.values().all(|pk| pk == &public_sets[&id0])); @@ -506,7 +617,7 @@ mod tests { let public_from_secret = shares .into_iter() - .map(|(id, share)| (id, share.secret_share.mul_by_generator())) + .map(|(id, share)| (id, share.secret_share().mul_by_generator())) .collect(); assert!(public_set == &public_from_secret); diff --git a/synedrion/src/www02/entities.rs b/synedrion/src/www02/entities.rs index 868be3e..16b8204 100644 --- a/synedrion/src/www02/entities.rs +++ b/synedrion/src/www02/entities.rs @@ -173,12 +173,7 @@ impl ThresholdKeyShare>()?; - Ok(KeyShare { - owner: self.owner.clone(), - secret_share, - public_shares, - phantom: PhantomData, - }) + KeyShare::new(self.owner.clone(), secret_share, public_shares) } /// Creates a t-of-t threshold keyshare that can be used in KeyResharing protocol. @@ -196,7 +191,7 @@ impl ThresholdKeyShare ThresholdKeyShare ThresholdKeyShare