From 1961d8aba23b1616b37599b00b84cc6a005fba8c Mon Sep 17 00:00:00 2001 From: przydatek Date: Fri, 10 Nov 2023 17:03:56 +0100 Subject: [PATCH] Add utils for handling verifiable credentials (#2019) * Add utils for handling verifiable credentials. * fix docker and deps * Address review comments. * Address feedback, extend CanisterSigPublicKey. --- Cargo.lock | 2541 ++++++++++++++++++++--- Cargo.toml | 1 + Dockerfile | 3 + src/canister_sig_util/src/lib.rs | 150 +- src/internet_identity/src/delegation.rs | 4 +- src/vc_util/Cargo.toml | 28 + src/vc_util/src/lib.rs | 458 ++++ 7 files changed, 2860 insertions(+), 325 deletions(-) create mode 100644 src/vc_util/Cargo.toml create mode 100644 src/vc_util/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 00f2402b9b..58163b2ebc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,29 +10,51 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] name = "aho-corasick" -version = "1.0.3" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" -version = "1.0.72" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b13c32d80ecc7ab747b80c3784bce54ee8a7a0cc4fbda9bf4cda2cf6fe90854" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" [[package]] name = "archive" @@ -80,6 +102,24 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base32" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" + [[package]] name = "base64" version = "0.13.1" @@ -88,9 +128,15 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "base64ct" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "beef" @@ -98,6 +144,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "binread" version = "2.2.0" @@ -144,9 +199,18 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.3.3" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "block-buffer" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] [[package]] name = "block-buffer" @@ -157,23 +221,51 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byte-unit" +version = "4.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da78b32057b8fdfc352504708feeba7216dcd65a2c9ab02978cbd288d1279b6c" +dependencies = [ + "serde", + "utf8-width", +] + [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.4.0" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cached" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" +checksum = "ec6d20b3d24b6c74e2c5331d2d3d8d1976a9883c7da179aa851afa4c90d62e36" +dependencies = [ + "hashbrown 0.12.3", + "instant", + "once_cell", + "thiserror", +] [[package]] name = "candid" @@ -186,7 +278,7 @@ dependencies = [ "byteorder", "candid_derive", "codespan-reporting", - "convert_case", + "convert_case 0.6.0", "crc32fast", "data-encoding", "hex", @@ -201,7 +293,7 @@ dependencies = [ "pretty", "serde", "serde_bytes", - "sha2", + "sha2 0.10.8", "stacker", "thiserror", ] @@ -215,7 +307,7 @@ dependencies = [ "lazy_static", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -227,14 +319,14 @@ dependencies = [ "ic-certified-map", "lazy_static", "rand", - "sha2", + "sha2 0.10.8", ] [[package]] name = "canister_tests" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64 0.21.5", "candid", "flate2", "hex", @@ -247,7 +339,7 @@ dependencies = [ "serde", "serde_bytes", "serde_cbor", - "sha2", + "sha2 0.10.8", ] [[package]] @@ -265,9 +357,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -278,6 +370,20 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets", +] + [[package]] name = "ciborium" version = "0.2.1" @@ -321,6 +427,54 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" +[[package]] +name = "comparable" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb513ee8037bf08c5270ecefa48da249f4c58e57a71ccfce0a5b0877d2a20eb2" +dependencies = [ + "comparable_derive", + "comparable_helper", + "pretty_assertions", + "serde", +] + +[[package]] +name = "comparable_derive" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a54b9c40054eb8999c5d1d36fdc90e4e5f7ff0d1d9621706f360b3cbc8beb828" +dependencies = [ + "convert_case 0.4.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "comparable_helper" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5437e327e861081c91270becff184859f706e3e50f5301a9d4dc8eb50752c3" +dependencies = [ + "convert_case 0.6.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + [[package]] name = "convert_case" version = "0.6.0" @@ -330,11 +484,17 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -354,6 +514,18 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -365,206 +537,482 @@ dependencies = [ ] [[package]] -name = "data-encoding" -version = "2.4.0" +name = "curve25519-dalek" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] [[package]] -name = "diff" -version = "0.1.13" +name = "curve25519-dalek" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms", + "rustc_version", + "subtle", + "zeroize", +] [[package]] -name = "digest" -version = "0.10.7" +name = "curve25519-dalek-derive" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "block-buffer", - "crypto-common", + "proc-macro2", + "quote", + "syn 2.0.39", ] [[package]] -name = "dirs-next" -version = "2.0.0" +name = "curve25519-dalek-ng" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +checksum = "1c359b7249347e46fb28804470d071c921156ad62b3eef5d34e2ba867533dec8" dependencies = [ - "cfg-if", - "dirs-sys-next", + "byteorder", + "digest 0.9.0", + "rand_core 0.6.4", + "subtle-ng", + "zeroize", ] [[package]] -name = "dirs-sys-next" +name = "cvt" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +checksum = "d2ae9bf77fbf2d39ef573205d554d87e86c12f1994e9ea335b0651b9b278bcf1" dependencies = [ - "libc", - "redox_users", - "winapi", + "cfg-if", ] [[package]] -name = "either" -version = "1.9.0" +name = "darling" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] [[package]] -name = "ena" -version = "0.14.2" +name = "darling_core" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" dependencies = [ - "log", + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", ] [[package]] -name = "equivalent" -version = "1.0.1" +name = "darling_macro" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] [[package]] -name = "errno" -version = "0.3.2" +name = "data-encoding" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" + +[[package]] +name = "data-encoding-macro" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", + "data-encoding", + "data-encoding-macro-internal", ] [[package]] -name = "errno-dragonfly" -version = "0.1.2" +name = "data-encoding-macro-internal" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" dependencies = [ - "cc", - "libc", + "data-encoding", + "syn 1.0.109", ] [[package]] -name = "fallible_collections" -version = "0.4.9" +name = "der" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88c69768c0a15262df21899142bc6df9b9b823546d4b4b9a7bc2d6c448ec6fd" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" dependencies = [ - "hashbrown 0.13.2", + "const-oid", + "pem-rfc7468", + "zeroize", ] [[package]] -name = "fdeflate" -version = "0.3.0" +name = "deranged" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" dependencies = [ - "simd-adler32", + "powerfmt", + "serde", ] [[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +name = "derive_more" +version = "0.99.8-alpha.0" +source = "git+https://github.com/dfinity-lab/derive_more?branch=master#9f1b894e6fde640da4e9ea71a8fc0e4dd98d01da" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] -name = "flate2" -version = "1.0.26" +name = "did_url" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" +checksum = "70d5f6334e473e3bb5650ab4ef3e4c910296b76968e62758e7c66157ff767c05" dependencies = [ - "crc32fast", - "miniz_oxide", + "form_urlencoded", + "serde", ] [[package]] -name = "fnv" -version = "1.0.7" +name = "diff" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] -name = "futures" -version = "0.3.28" +name = "digest" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", + "generic-array", ] [[package]] -name = "futures-channel" -version = "0.3.28" +name = "digest" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "futures-core", - "futures-sink", + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", ] [[package]] -name = "futures-core" -version = "0.3.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" - -[[package]] -name = "futures-executor" -version = "0.3.28" +name = "dirs-next" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ - "futures-core", - "futures-task", - "futures-util", + "cfg-if", + "dirs-sys-next", ] [[package]] -name = "futures-io" -version = "0.3.28" +name = "dirs-sys-next" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] [[package]] -name = "futures-macro" -version = "0.3.28" +name = "ecdsa" +version = "0.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.28", + "der", + "digest 0.10.7", + "elliptic-curve", + "rfc6979", + "signature", + "spki", ] [[package]] -name = "futures-sink" -version = "0.3.28" +name = "ed25519" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "signature", +] [[package]] -name = "futures-task" -version = "0.3.28" +name = "ed25519-consensus" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "3c8465edc8ee7436ffea81d21a019b16676ee3db267aa8d5a8d729581ecf998b" +dependencies = [ + "curve25519-dalek-ng", + "hex", + "rand_core 0.6.4", + "serde", + "sha2 0.9.9", + "thiserror", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "4.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d9ce6874da5d4415896cd45ffbc4d1cfc0c4f9c079427bd870742c30f2f65a9" +dependencies = [ + "curve25519-dalek 4.1.1", + "ed25519", + "hashbrown 0.14.2", + "hex", + "rand_core 0.6.4", + "sha2 0.10.8", + "zeroize", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "elliptic-curve" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest 0.10.7", + "ff 0.13.0", + "generic-array", + "group 0.13.0", + "pem-rfc7468", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "ena" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c533630cf40e9caa44bd91aadc88a75d75a4c3a12b4cfde353cbed41daa1e1f1" +dependencies = [ + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + +[[package]] +name = "errno" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fallible_collections" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a88c69768c0a15262df21899142bc6df9b9b823546d4b4b9a7bc2d6c448ec6fd" +dependencies = [ + "hashbrown 0.13.2", +] + +[[package]] +name = "fdeflate" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -586,17 +1034,51 @@ checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", + "zeroize", +] + +[[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.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", + "rand_core 0.6.4", + "subtle", ] [[package]] @@ -622,15 +1104,25 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "heck" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" [[package]] name = "hex" @@ -644,11 +1136,20 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + [[package]] name = "hound" -version = "3.5.0" +version = "3.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d13cdbd5dbb29f9c88095bbdc2590c9cba0d0a1269b983fef6b2cdd7e9f4db1" +checksum = "62adaabb884c94955b19907d60019f4e145d091c75345379e70d1ee696f7854f" [[package]] name = "http" @@ -661,6 +1162,86 @@ dependencies = [ "itoa", ] +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ic-base-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base32", + "byte-unit", + "bytes", + "candid", + "comparable", + "crc32fast", + "ic-crypto-sha2", + "ic-protobuf", + "ic-stable-structures", + "phantom_newtype", + "prost", + "serde", + "strum 0.24.1", + "strum_macros 0.24.3", +] + +[[package]] +name = "ic-btc-interface" +version = "0.1.0" +source = "git+https://github.com/dfinity/bitcoin-canister?rev=be0143a014ad4bccbc2eec5e2bcbe30317c5a84c#be0143a014ad4bccbc2eec5e2bcbe30317c5a84c" +dependencies = [ + "candid", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-btc-types-internal" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "candid", + "ic-btc-interface", + "ic-error-types", + "ic-protobuf", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-cbor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767fe244224c02f2adad1d43909de93d35d5caada28eed3f270d89735ba5bdd0" +dependencies = [ + "candid", + "ic-certification 1.2.0", + "leb128", + "nom", + "thiserror", +] + [[package]] name = "ic-cdk" version = "0.10.0" @@ -703,13 +1284,43 @@ dependencies = [ ] [[package]] -name = "ic-certification" -version = "0.25.0" +name = "ic-certificate-verification" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561f6ae522da62b6fb89c0594337c18e96a69fa1f89baae8542f3634023635b" +checksum = "07bc3fa76751b637bb0c0e37f4089d7f5a3fbacfed3c5fbcfef0d6797a54d63f" dependencies = [ - "hex", - "sha2", + "candid", + "ic-cbor", + "ic-certification 1.2.0", + "leb128", + "miracl_core_bls12381", + "nom", + "thiserror", +] + +[[package]] +name = "ic-certification" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "hex", + "ic-crypto-tree-hash", + "ic-crypto-utils-threshold-sig", + "ic-crypto-utils-threshold-sig-der", + "ic-types", + "serde", + "serde_cbor", + "tree-deserializer", +] + +[[package]] +name = "ic-certification" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a59dc342d11b2067e19d0f146bdec3674de921303ffc762f114d201ebbe0e68a" +dependencies = [ + "hex", + "sha2 0.10.8", ] [[package]] @@ -720,69 +1331,644 @@ checksum = "197524aecec47db0b6c0c9f8821aad47272c2bd762c7a0ffe9715eaca0364061" dependencies = [ "serde", "serde_bytes", - "sha2", + "sha2 0.10.8", +] + +[[package]] +name = "ic-constants" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" + +[[package]] +name = "ic-crypto-ecdsa-secp256k1" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "k256", + "lazy_static", + "num-bigint", + "pem", + "rand", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-ecdsa-secp256r1" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-getrandom-for-wasm", + "lazy_static", + "num-bigint", + "p256", + "pem", + "rand", + "rand_chacha", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-getrandom-for-wasm" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "getrandom 0.2.11", +] + +[[package]] +name = "ic-crypto-iccsa" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-internal-basic-sig-iccsa", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-cose" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-basic-sig-ecdsa-secp256r1", + "ic-crypto-internal-basic-sig-rsa-pkcs1", + "ic-types", + "serde", + "serde_cbor", + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-der-utils" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "hex", + "ic-types", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-ecdsa-secp256k1" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "ic-crypto-ecdsa-secp256k1", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-types", + "ic-crypto-secrets-containers", + "ic-types", + "serde", + "serde_bytes", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-ecdsa-secp256r1" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "ic-crypto-ecdsa-secp256r1", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-types", + "ic-crypto-secrets-containers", + "ic-types", + "p256", + "rand", + "serde", + "serde_bytes", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-ed25519" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "curve25519-dalek 3.2.0", + "ed25519-consensus", + "hex", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-seed", + "ic-crypto-internal-types", + "ic-crypto-secrets-containers", + "ic-protobuf", + "ic-types", + "rand", + "rand_chacha", + "serde", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-iccsa" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "hex", + "ic-certification 0.8.0", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-types", + "ic-crypto-sha2", + "ic-crypto-tree-hash", + "ic-types", + "serde", + "serde_bytes", + "serde_cbor", + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-rsa-pkcs1" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-getrandom-for-wasm", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-sha2", + "ic-types", + "num-bigint", + "num-traits", + "pkcs8", + "rsa", + "serde", + "sha2 0.10.8", + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-bls12-381-type" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "hex", + "ic-crypto-getrandom-for-wasm", + "ic_bls12_381", + "itertools 0.10.5", + "lazy_static", + "pairing", + "paste", + "rand", + "rand_chacha", + "sha2 0.9.9", + "subtle", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-seed" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "hex", + "ic-crypto-sha2", + "ic-types", + "rand", + "rand_chacha", + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-sha2" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "sha2 0.10.8", +] + +[[package]] +name = "ic-crypto-internal-threshold-sig-bls12381" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "cached", + "hex", + "ic-crypto-internal-bls12-381-type", + "ic-crypto-internal-seed", + "ic-crypto-internal-threshold-sig-bls12381-der", + "ic-crypto-internal-types", + "ic-crypto-secrets-containers", + "ic-crypto-sha2", + "ic-types", + "lazy_static", + "parking_lot", + "rand", + "rand_chacha", + "serde", + "serde_bytes", + "serde_cbor", + "strum_macros 0.24.3", + "subtle", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-threshold-sig-bls12381-der" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "arrayvec", + "hex", + "ic-protobuf", + "phantom_newtype", + "serde", + "serde_cbor", + "strum 0.24.1", + "strum_macros 0.24.3", + "thiserror", + "zeroize", +] + +[[package]] +name = "ic-crypto-secrets-containers" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-sha2" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-internal-sha2", +] + +[[package]] +name = "ic-crypto-standalone-sig-verifier" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-iccsa", + "ic-crypto-internal-basic-sig-cose", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-basic-sig-ecdsa-secp256k1", + "ic-crypto-internal-basic-sig-ecdsa-secp256r1", + "ic-crypto-internal-basic-sig-ed25519", + "ic-crypto-internal-basic-sig-iccsa", + "ic-crypto-internal-basic-sig-rsa-pkcs1", + "ic-crypto-internal-types", + "ic-crypto-sha2", + "ic-types", +] + +[[package]] +name = "ic-crypto-tree-hash" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "assert_matches", + "ic-crypto-internal-types", + "ic-crypto-sha2", + "ic-protobuf", + "serde", + "serde_bytes", + "thiserror", +] + +[[package]] +name = "ic-crypto-utils-threshold-sig" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "ic-crypto-internal-threshold-sig-bls12381", + "ic-crypto-internal-types", + "ic-types", +] + +[[package]] +name = "ic-crypto-utils-threshold-sig-der" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "ic-crypto-internal-threshold-sig-bls12381-der", + "ic-crypto-internal-types", + "ic-types", +] + +[[package]] +name = "ic-error-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-utils", + "serde", + "strum 0.24.1", + "strum_macros 0.24.3", +] + +[[package]] +name = "ic-ic00-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "candid", + "ic-base-types", + "ic-btc-interface", + "ic-btc-types-internal", + "ic-error-types", + "ic-protobuf", + "num-traits", + "serde", + "serde_bytes", + "serde_cbor", + "strum 0.24.1", + "strum_macros 0.24.3", ] [[package]] name = "ic-metrics-encoder" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cb321e571828d64d62319deeaaec4c8e68cdf93144dd6fe248e7a51ab2d3b5d" +checksum = "8b5c7628eac357aecda461130f8074468be5aa4d258a002032d82d817f79f1f8" + +[[package]] +name = "ic-protobuf" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "bincode", + "candid", + "erased-serde", + "maplit", + "prost", + "serde", + "serde_json", + "slog", +] [[package]] name = "ic-representation-independent-hash" -version = "1.0.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2204e06271a81f9ffee9b7bc0c4d90687d035eba95f2eb3894e19d8ff263f9e" +checksum = "410e3ccb16b86e8c4bca7270981370f6961492f1921f29f5dd1de621efb869ea" dependencies = [ "leb128", - "sha2", + "sha2 0.10.8", ] [[package]] name = "ic-response-verification" -version = "1.0.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2034aab93c484311ad040475195496dc39a6ddefd5374c3b9e37b3266850f7e" +checksum = "bc87254b89cea2b84fb2e3101527e457d01da1bdfdbf8b8699dcbc40ad11dcea" dependencies = [ - "base64 0.21.2", + "base64 0.21.5", "candid", "flate2", "hex", "http", - "ic-certification", + "ic-cbor", + "ic-certificate-verification", + "ic-certification 1.2.0", "ic-representation-independent-hash", "leb128", "log", - "miracl_core_bls12381", "nom", - "sha2", + "sha2 0.10.8", + "thiserror", + "urlencoding", +] + +[[package]] +name = "ic-stable-structures" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95dce29e3ceb0e6da3e78b305d95365530f2efd2146ca18590c0ef3aa6038568" + +[[package]] +name = "ic-sys" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "hex", + "ic-crypto-sha2", + "lazy_static", + "libc", + "nix", + "phantom_newtype", + "wsl", +] + +[[package]] +name = "ic-test-state-machine-client" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cadf6ac4a193a8a45287da67c6c385f118d9266f46d6d98e40fbbd469d3822e" +dependencies = [ + "candid", + "ciborium", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "base64 0.13.1", + "bincode", + "candid", + "chrono", + "derive_more", + "hex", + "ic-base-types", + "ic-btc-types-internal", + "ic-constants", + "ic-crypto-internal-types", + "ic-crypto-sha2", + "ic-crypto-tree-hash", + "ic-error-types", + "ic-ic00-types", + "ic-protobuf", + "ic-utils", + "maplit", + "once_cell", + "phantom_newtype", + "prost", + "serde", + "serde_bytes", + "serde_cbor", + "serde_json", + "serde_with", + "strum 0.24.1", + "strum_macros 0.24.3", + "thiserror", + "thousands", +] + +[[package]] +name = "ic-utils" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "cvt", + "hex", + "ic-sys", + "libc", + "nix", + "prost", + "rand", + "scoped_threadpool", + "serde", + "thiserror", +] + +[[package]] +name = "ic0" +version = "0.18.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576c539151d4769fb4d1a0c25c4108dd18facd04c5695b02cf2d226ab4e43aa5" + +[[package]] +name = "ic_bls12_381" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c682cb199cd8fcb582a6023325d571a6464edda26c8063fe04b6f6082a1a363c" +dependencies = [ + "digest 0.9.0", + "ff 0.12.1", + "group 0.12.1", + "pairing", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "identity_core" +version = "0.7.0-alpha.6" +source = "git+https://github.com/frederikrothenberger/identity.rs.git?branch=frederik/wasm-test#c0538f9a3d6f0025b8bf698646289d5bcb875ba9" +dependencies = [ + "ic-cdk", + "iota-crypto", + "multibase", + "serde", + "serde_json", + "strum 0.25.0", + "thiserror", + "time", + "url", + "zeroize", +] + +[[package]] +name = "identity_credential" +version = "0.7.0-alpha.6" +source = "git+https://github.com/frederikrothenberger/identity.rs.git?branch=frederik/wasm-test#c0538f9a3d6f0025b8bf698646289d5bcb875ba9" +dependencies = [ + "identity_core", + "identity_did", + "identity_document", + "identity_verification", + "indexmap", + "itertools 0.11.0", + "once_cell", + "serde", + "serde_repr", + "strum 0.25.0", + "thiserror", + "url", +] + +[[package]] +name = "identity_did" +version = "0.7.0-alpha.6" +source = "git+https://github.com/frederikrothenberger/identity.rs.git?branch=frederik/wasm-test#c0538f9a3d6f0025b8bf698646289d5bcb875ba9" +dependencies = [ + "did_url", + "form_urlencoded", + "identity_core", + "serde", + "strum 0.25.0", "thiserror", ] [[package]] -name = "ic-stable-structures" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95dce29e3ceb0e6da3e78b305d95365530f2efd2146ca18590c0ef3aa6038568" +name = "identity_document" +version = "0.7.0-alpha.6" +source = "git+https://github.com/frederikrothenberger/identity.rs.git?branch=frederik/wasm-test#c0538f9a3d6f0025b8bf698646289d5bcb875ba9" +dependencies = [ + "did_url", + "identity_core", + "identity_did", + "identity_verification", + "indexmap", + "serde", + "strum 0.25.0", + "thiserror", +] [[package]] -name = "ic-test-state-machine-client" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cadf6ac4a193a8a45287da67c6c385f118d9266f46d6d98e40fbbd469d3822e" +name = "identity_jose" +version = "0.7.0-alpha.6" +source = "git+https://github.com/frederikrothenberger/identity.rs.git?branch=frederik/wasm-test#c0538f9a3d6f0025b8bf698646289d5bcb875ba9" dependencies = [ - "candid", - "ciborium", + "ic-crypto-standalone-sig-verifier", + "ic-types", + "identity_core", + "iota-crypto", "serde", "serde_bytes", + "serde_cbor", + "serde_json", + "subtle", + "thiserror", + "zeroize", ] [[package]] -name = "ic0" -version = "0.18.11" +name = "identity_verification" +version = "0.7.0-alpha.6" +source = "git+https://github.com/frederikrothenberger/identity.rs.git?branch=frederik/wasm-test#c0538f9a3d6f0025b8bf698646289d5bcb875ba9" +dependencies = [ + "identity_core", + "identity_did", + "identity_jose", + "serde", + "strum 0.25.0", + "thiserror", +] + +[[package]] +name = "idna" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "576c539151d4769fb4d1a0c25c4108dd18facd04c5695b02cf2d226ab4e43aa5" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] [[package]] name = "image" @@ -819,34 +2005,34 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.3" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ - "autocfg", - "hashbrown 0.12.3", + "equivalent", + "hashbrown 0.14.2", + "serde", ] [[package]] -name = "indexmap" -version = "2.0.0" +name = "instant" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "equivalent", - "hashbrown 0.14.0", + "cfg-if", ] [[package]] name = "internet_identity" version = "0.1.0" dependencies = [ - "base64 0.21.2", + "base64 0.21.5", "candid", "canister_sig_util", "canister_tests", "captcha", - "getrandom", + "getrandom 0.2.11", "hex", "hex-literal", "ic-cdk", @@ -862,12 +2048,12 @@ dependencies = [ "lodepng", "rand", "rand_chacha", - "rand_core", + "rand_core 0.6.4", "regex", "serde", "serde_bytes", "serde_cbor", - "sha2", + "sha2 0.10.8", ] [[package]] @@ -880,6 +2066,23 @@ dependencies = [ "serde_bytes", ] +[[package]] +name = "iota-crypto" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5d5a986d972c3a703d48ced24fdc0bf16fb2d02959ff4b152fa77b9132f6fb0" +dependencies = [ + "autocfg", + "curve25519-dalek 3.2.0", + "digest 0.10.7", + "ed25519-zebra", + "k256", + "serde", + "sha2 0.10.8", + "x25519-dalek", + "zeroize", +] + [[package]] name = "is-terminal" version = "0.4.9" @@ -900,12 +2103,43 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "js-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2 0.10.8", +] + [[package]] name = "lalrpop" version = "0.20.0" @@ -917,12 +2151,12 @@ dependencies = [ "diff", "ena", "is-terminal", - "itertools", + "itertools 0.10.5", "lalrpop-util", "petgraph", "pico-args", "regex", - "regex-syntax 0.7.4", + "regex-syntax 0.7.5", "string_cache", "term", "tiny-keccak", @@ -943,6 +2177,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "leb128" @@ -952,21 +2189,38 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libredox" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -987,9 +2241,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "logos" @@ -1011,7 +2265,7 @@ dependencies = [ "proc-macro2", "quote", "regex-syntax 0.6.29", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -1023,11 +2277,26 @@ dependencies = [ "logos-codegen", ] +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memoffset" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] [[package]] name = "minimal-lexical" @@ -1051,12 +2320,35 @@ version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d07cbe42e2a8dd41df582fb8e00fc24d920b5561cc301fcb6d14e2e0434b500f" +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset", +] + [[package]] name = "nom" version = "7.1.3" @@ -1069,9 +2361,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -1079,6 +2371,23 @@ dependencies = [ "serde", ] +[[package]] +name = "num-bigint-dig" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc84195820f291c7697304f3cbdadd1cb7199c0efc917ff5eafd71225c136151" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand", + "smallvec", + "zeroize", +] + [[package]] name = "num-integer" version = "0.1.45" @@ -1089,6 +2398,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-rational" version = "0.4.1" @@ -1102,11 +2422,12 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -1127,7 +2448,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] @@ -1136,6 +2457,33 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2 0.10.8", +] + +[[package]] +name = "pairing" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" +dependencies = [ + "group 0.12.1", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -1148,13 +2496,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall", "smallvec", "windows-targets", ] @@ -1165,14 +2513,48 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + [[package]] name = "petgraph" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 1.9.3", + "indexmap", +] + +[[package]] +name = "phantom_newtype" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "candid", + "serde", + "slog", ] [[package]] @@ -1192,9 +2574,9 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -1202,11 +2584,38 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +dependencies = [ + "der", + "pkcs8", + "spki", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "platforms" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" + [[package]] name = "png" -version = "0.17.9" +version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59871cc5b6cce7eaccca5a802b4173377a1c2ba90654246789a8fa2334426d11" +checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" dependencies = [ "bitflags 1.3.2", "crc32fast", @@ -1215,6 +2624,12 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -1229,13 +2644,32 @@ checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "pretty" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "563c9d701c3a31dfffaaf9ce23507ba09cbe0b9125ba176d15e629b0235e9acc" +checksum = "b55c4d17d994b637e2f4daf6e5dc5d660d209d5642377d675d7a1c3ab69fa579" dependencies = [ "arrayvec", "typed-arena", - "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "pretty_assertions" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af7cee1a6c8a5b9208b3cb1061f10c0cb689087b3d8ce85fb9d2dd7a29b6ba66" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "primeorder" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7dbe9ed3b56368bd99483eb32fe9c17fdd3730aebadc906918ce78d54c7eeb4" +dependencies = [ + "elliptic-curve", ] [[package]] @@ -1250,13 +2684,36 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "psm" version = "0.1.21" @@ -1268,9 +2725,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -1283,7 +2740,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", - "rand_core", + "rand_core 0.6.4", ] [[package]] @@ -1293,68 +2750,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", ] [[package]] name = "rand_core" -version = "0.6.4" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom", + "getrandom 0.1.16", ] [[package]] -name = "redox_syscall" -version = "0.2.16" +name = "rand_core" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "bitflags 1.3.2", + "getrandom 0.2.11", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom", - "redox_syscall 0.2.16", + "getrandom 0.2.11", + "libredox", "thiserror", ] [[package]] name = "regex" -version = "1.9.3" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", "regex-automata", - "regex-syntax 0.7.4", + "regex-syntax 0.8.2", ] [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.7.4", + "regex-syntax 0.8.2", ] [[package]] @@ -1365,26 +2822,72 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "regex-syntax" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] [[package]] name = "rgb" -version = "0.8.36" +version = "0.8.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59" +checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" dependencies = [ "bytemuck", ] +[[package]] +name = "rsa" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ef35bf3e7fe15a53c4ab08a998e42271eab13eb0db224126bc7bc4c4bad96d" +dependencies = [ + "const-oid", + "digest 0.10.7", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core 0.6.4", + "sha2 0.10.8", + "signature", + "spki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + [[package]] name = "rustix" -version = "0.38.7" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "172891ebdceb05aa0005f533a6cbfca599ddd7d966f6f5d4d9b2e70478e70399" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.3.3", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -1403,17 +2906,43 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "scoped_threadpool" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" + [[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" + [[package]] name = "serde" -version = "1.0.183" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" dependencies = [ "serde_derive", ] @@ -1439,26 +2968,37 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.183" +version = "1.0.192" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aafe972d60b0b9bee71a91b92fee2d4fb3c9d7e8f6b179aa99f27203d99a4816" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "serde_tokenstream" version = "0.1.7" @@ -1470,15 +3010,60 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "serde_with" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678b5a069e50bf00ecd22d0cd8ddf7c236f68581b03db652061ed5eb13a312ff" +dependencies = [ + "serde", + "serde_with_macros", +] + +[[package]] +name = "serde_with_macros" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e182d6ec6f05393cc0e5ed1bf81ad6db3a8feedf8ee515ecdd369809bcce8082" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "sha2" -version = "0.10.7" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", - "digest", + "digest 0.10.7", +] + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", ] [[package]] @@ -1487,21 +3072,42 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "simple_asn1" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085" +dependencies = [ + "num-bigint", + "num-traits", + "thiserror", + "time", +] + [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] +[[package]] +name = "slog" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" +dependencies = [ + "erased-serde", +] + [[package]] name = "slotmap" version = "1.0.6" @@ -1513,9 +3119,25 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.0" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spki" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der", +] [[package]] name = "stacker" @@ -1543,6 +3165,68 @@ dependencies = [ "precomputed-hash", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros 0.24.3", +] + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" +dependencies = [ + "strum_macros 0.25.3", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.39", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "subtle-ng" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "734676eb262c623cec13c3155096e08d1f8f29adce39ba17948b18dad1e54142" + [[package]] name = "syn" version = "1.0.109" @@ -1556,9 +3240,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.28" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -1578,31 +3262,66 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] [[package]] name = "thiserror" -version = "1.0.44" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.44" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.28", + "syn 2.0.39", +] + +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + +[[package]] +name = "time" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", ] [[package]] @@ -1614,23 +3333,48 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" -version = "0.19.14" +version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8123f27e969974a3dfba720fdb560be359f57b44302d280ba72e76a74480e8a" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.0", + "indexmap", "toml_datetime", "winnow", ] +[[package]] +name = "tree-deserializer" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic?rev=bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e#bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" +dependencies = [ + "ic-crypto-tree-hash", + "leb128", + "serde", +] + [[package]] name = "typed-arena" version = "2.0.2" @@ -1639,15 +3383,30 @@ checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] [[package]] name = "unicode-segmentation" @@ -1657,9 +3416,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "unicode-width" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" [[package]] name = "unicode-xid" @@ -1667,18 +3426,122 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" + +[[package]] +name = "vc_util" +version = "0.1.0" +dependencies = [ + "assert_matches", + "candid", + "canister_sig_util", + "ic-certified-map", + "ic-crypto-standalone-sig-verifier", + "ic-types", + "identity_core", + "identity_credential", + "identity_jose", + "serde", + "serde_bytes", + "serde_cbor", + "serde_json", + "sha2 0.10.8", +] + [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +[[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.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasm-bindgen" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" + [[package]] name = "winapi" version = "0.3.9" @@ -1697,9 +3560,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" dependencies = [ "winapi", ] @@ -1710,6 +3573,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -1721,9 +3593,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -1736,51 +3608,114 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.4" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acaaa1190073b2b101e15083c38ee8ec891b5e05cbee516521e94ec008f61e64" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] + +[[package]] +name = "wsl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dab7ac864710bdea6594becbea5b5050333cf34fefb0dc319567eb347950d4" + +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/Cargo.toml b/Cargo.toml index 0a6c1a2cd7..f4ebe7b95b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "src/canister_tests", "src/internet_identity_interface", "src/archive", + "src/vc_util" ] resolver = "2" diff --git a/Dockerfile b/Dockerfile index bc15d1e882..2d81bff808 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,7 @@ COPY src/internet_identity_interface/Cargo.toml src/internet_identity_interface/ COPY src/archive/Cargo.toml src/archive/Cargo.toml COPY src/canister_tests/Cargo.toml src/canister_tests/Cargo.toml COPY src/canister_sig_util/Cargo.toml src/canister_sig_util/Cargo.toml +COPY src/vc_util/Cargo.toml src/vc_util/Cargo.toml ENV CARGO_TARGET_DIR=/cargo_target COPY ./scripts/build ./scripts/build RUN mkdir -p src/internet_identity/src \ @@ -60,6 +61,8 @@ RUN mkdir -p src/internet_identity/src \ && touch src/canister_tests/src/lib.rs \ && mkdir -p src/canister_sig_util/src \ && touch src/canister_sig_util/src/lib.rs \ + && mkdir -p src/vc_util/src \ + && touch src/vc_util/src/lib.rs \ && ./scripts/build --only-dependencies --internet-identity --archive \ && rm -rf src diff --git a/src/canister_sig_util/src/lib.rs b/src/canister_sig_util/src/lib.rs index 7317e187c2..966b800537 100644 --- a/src/canister_sig_util/src/lib.rs +++ b/src/canister_sig_util/src/lib.rs @@ -19,25 +19,76 @@ lazy_static! { extract_raw_root_pk_from_der(IC_ROOT_PK_DER).expect("Failed decoding IC root key."); } -/// Returns (DER-encoded) public key of the canister signatures for the given canister_id and seed. -/// (cf. https://internetcomputer.org/docs/current/references/ic-interface-spec#canister-signatures)) -pub fn get_canister_sig_pk_der(canister_id: Principal, seed: &[u8]) -> Vec { - let mut bitstring: Vec = vec![]; - bitstring.push(canister_id.as_ref().len() as u8); - bitstring.extend(canister_id.as_ref()); - bitstring.extend(seed); - - let mut der: Vec = vec![]; - // sequence of length 17 + the bit string length - der.push(0x30); - der.push(17 + bitstring.len() as u8); - der.extend(CANISTER_SIG_PK_DER_OID); - // BIT string of given length - der.push(0x03); - der.push(1 + bitstring.len() as u8); - der.push(0x00); - der.extend(bitstring); - der +/// A public key of canister signatures, +/// see https://internetcomputer.org/docs/current/references/ic-interface-spec#canister-signatures +#[derive(Clone, Eq, PartialEq, Debug)] +pub struct CanisterSigPublicKey { + pub canister_id: Principal, + pub seed: Vec, +} + +impl TryFrom<&[u8]> for CanisterSigPublicKey { + type Error = String; + + fn try_from(pk_der: &[u8]) -> Result { + let pk_raw = extract_raw_canister_sig_pk_from_der(pk_der)?; + Self::try_from_raw(pk_raw.as_slice()) + } +} + +impl CanisterSigPublicKey { + /// Constructs a new canister signatures public key. + pub fn new(canister_id: Principal, seed: Vec) -> Self { + CanisterSigPublicKey { canister_id, seed } + } + + pub fn try_from_raw(pk_raw: &[u8]) -> Result { + let canister_id_len: usize = if !pk_raw.is_empty() { + usize::from(pk_raw[0]) + } else { + return Err("empty raw canister sig pk".to_string()); + }; + if pk_raw.len() < (1 + canister_id_len) { + return Err("canister sig pk too short".to_string()); + } + let canister_id_raw = &pk_raw[1..(1 + canister_id_len)]; + let seed = &pk_raw[canister_id_len + 1..]; + let canister_id = Principal::try_from_slice(canister_id_raw) + .map_err(|e| format!("invalid canister id in canister sig pk: {}", e))?; + Ok(CanisterSigPublicKey { + canister_id, + seed: seed.to_vec(), + }) + } + + /// Returns a byte vector with DER-encoding of this key, see + /// https://internetcomputer.org/docs/current/references/ic-interface-spec#canister-signatures + pub fn to_der(&self) -> Vec { + let raw_pk = self.to_raw(); + + let mut der_pk: Vec = vec![]; + // sequence of length 17 + the bit string length + der_pk.push(0x30); + der_pk.push(17 + raw_pk.len() as u8); + der_pk.extend(CANISTER_SIG_PK_DER_OID); + // BIT string of given length + der_pk.push(0x03); + der_pk.push(1 + raw_pk.len() as u8); + der_pk.push(0x00); + der_pk.extend(raw_pk); + der_pk + } + + /// Returns a byte vector with raw encoding of this key (i.e. a bit string with + /// canister id length, canister id, and seed, without the DER-envelope) + /// https://internetcomputer.org/docs/current/references/ic-interface-spec#canister-signatures + pub fn to_raw(&self) -> Vec { + let mut raw_pk: Vec = vec![]; + raw_pk.push(self.canister_id.as_ref().len() as u8); + raw_pk.extend(self.canister_id.as_ref()); + raw_pk.extend(self.seed.as_slice()); + raw_pk + } } /// Verifies the structure given public key in DER-format, and returns raw bytes of the key. @@ -87,10 +138,69 @@ mod tests { #[test] fn should_der_encode_canister_sig_pk() { let canister_id = Principal::from_text(TEST_SIGNING_CANISTER_ID).expect("wrong principal"); - let cs_pk_der = get_canister_sig_pk_der(canister_id, &TEST_SEED); + let cs_pk = CanisterSigPublicKey::new(canister_id, TEST_SEED.to_vec()); + let cs_pk_der = cs_pk.to_der(); assert_eq!(CANISTER_SIG_PK_DER.as_slice(), cs_pk_der.as_slice()); } + #[test] + fn should_raw_encode_canister_sig_pk() { + let canister_id = Principal::from_text(TEST_SIGNING_CANISTER_ID).expect("wrong principal"); + let cs_pk = CanisterSigPublicKey::new(canister_id, TEST_SEED.to_vec()); + let cs_pk_raw = cs_pk.to_raw(); + assert_eq!( + &CANISTER_SIG_PK_DER.as_slice()[CANISTER_SIG_PK_DER_PREFIX_LENGTH..], + cs_pk_raw.as_slice() + ); + } + + #[test] + fn should_parse_canister_sig_pk_from_der() { + let cs_pk = CanisterSigPublicKey::try_from(CANISTER_SIG_PK_DER.as_slice()) + .expect("Failed parsing canister sig pk DER"); + let canister_id = Principal::from_text(TEST_SIGNING_CANISTER_ID).expect("wrong principal"); + + assert_eq!(cs_pk.canister_id, canister_id); + assert_eq!(cs_pk.seed.as_slice(), TEST_SEED.as_slice()); + assert_eq!(cs_pk.to_der().as_slice(), CANISTER_SIG_PK_DER.as_slice()); + } + + #[test] + fn should_fail_parsing_canister_sig_pk_from_bad_oid_der() { + let mut bad_oid_der = *CANISTER_SIG_PK_DER; + bad_oid_der[2] += 42; + let result = CanisterSigPublicKey::try_from(bad_oid_der.as_slice()); + assert_matches!(result, Err(e) if e.contains("invalid OID")); + } + + #[test] + fn should_fail_parsing_canister_sig_pk_from_short_der() { + let result = CanisterSigPublicKey::try_from(CANISTER_SIG_PK_DER[..25].to_vec().as_slice()); + assert_matches!(result, Err(e) if e.contains("pk too short")); + } + + #[test] + fn should_parse_canister_sig_pk_from_raw() { + let cs_pk = CanisterSigPublicKey::try_from_raw( + &CANISTER_SIG_PK_DER.as_slice()[CANISTER_SIG_PK_DER_PREFIX_LENGTH..], + ) + .expect("Failed parsing canister sig pk DER"); + let canister_id = Principal::from_text(TEST_SIGNING_CANISTER_ID).expect("wrong principal"); + + assert_eq!(cs_pk.canister_id, canister_id); + assert_eq!(cs_pk.seed.as_slice(), TEST_SEED.as_slice()); + assert_eq!(cs_pk.to_der().as_slice(), CANISTER_SIG_PK_DER.as_slice()); + } + + #[test] + fn should_fail_parsing_canister_sig_pk_from_short_raw() { + let result = CanisterSigPublicKey::try_from_raw( + &CANISTER_SIG_PK_DER.as_slice() + [CANISTER_SIG_PK_DER_PREFIX_LENGTH..(CANISTER_SIG_PK_DER_PREFIX_LENGTH + 10)], + ); + assert_matches!(result, Err(e) if e.contains("pk too short")); + } + #[test] fn should_extract_raw_canister_sig_pk_from_der() { let raw_pk = extract_raw_canister_sig_pk_from_der(CANISTER_SIG_PK_DER) diff --git a/src/internet_identity/src/delegation.rs b/src/internet_identity/src/delegation.rs index 95ebd0f8ca..d79de70e97 100644 --- a/src/internet_identity/src/delegation.rs +++ b/src/internet_identity/src/delegation.rs @@ -3,8 +3,8 @@ use crate::ii_domain::IIDomain; use crate::state::persistent_state_mut; use crate::{hash, state, update_root_hash, DAY_NS, MINUTE_NS}; use candid::Principal; -use canister_sig_util::get_canister_sig_pk_der; use canister_sig_util::signature_map::{SignatureMap, LABEL_SIG}; +use canister_sig_util::CanisterSigPublicKey; use ic_cdk::api::{data_certificate, time}; use ic_cdk::{id, trap}; use ic_certified_map::{Hash, HashTree}; @@ -177,7 +177,7 @@ fn calculate_seed(anchor_number: AnchorNumber, frontend: &FrontendHostname) -> H fn der_encode_canister_sig_key(seed: Vec) -> Vec { let my_canister_id = id(); - get_canister_sig_pk_der(my_canister_id, &seed) + CanisterSigPublicKey::new(my_canister_id, seed).to_der() } fn delegation_signature_msg_hash(d: &Delegation) -> Hash { diff --git a/src/vc_util/Cargo.toml b/src/vc_util/Cargo.toml new file mode 100644 index 0000000000..cb960bad61 --- /dev/null +++ b/src/vc_util/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "vc_util" +description = "Utils for verifiable credentials on the IC" +version = "0.1.0" +edition = "2021" + +[dependencies] +# ic dependencies +candid = "0.9" +ic-certified-map = "0.4" +ic-crypto-standalone-sig-verifier = { git = "https://github.com/dfinity/ic", rev = "bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" } +ic-types = { git = "https://github.com/dfinity/ic", rev = "bf9bc00b032a18d2dbcfcfcfb7a76a562f350c9e" } +canister_sig_util = { path = "../canister_sig_util" } + +# vc dependencies +identity_core = { git = "https://github.com/frederikrothenberger/identity.rs.git", branch = "frederik/wasm-test", default-features = false } +identity_credential = { git = "https://github.com/frederikrothenberger/identity.rs.git", branch = "frederik/wasm-test", default-features = false , features = ["validator"] } +identity_jose = { git = "https://github.com/frederikrothenberger/identity.rs.git", branch = "frederik/wasm-test", default-features = false, features = ["iccs"]} + +# other dependencies +serde = { version = "1", features = ["rc"] } +serde_bytes = "0.11" +serde_cbor = "0.11" +serde_json = "1" +sha2 = "^0.10" # set bound to match ic-certified-map bound + +[dev-dependencies] +assert_matches = "1.5.0" diff --git a/src/vc_util/src/lib.rs b/src/vc_util/src/lib.rs new file mode 100644 index 0000000000..b696ac2c1d --- /dev/null +++ b/src/vc_util/src/lib.rs @@ -0,0 +1,458 @@ +use candid::Principal; +use canister_sig_util::{extract_raw_canister_sig_pk_from_der, CanisterSigPublicKey}; +use ic_certified_map::Hash; +use ic_crypto_standalone_sig_verifier::verify_canister_sig; +use ic_types::crypto::threshold_sig::IcRootOfTrust; +use identity_core::convert::FromJson; +use identity_credential::credential::Subject; +use identity_credential::error::Error as JwtVcError; +use identity_credential::validator::JwtValidationError; +use identity_jose::jwk::{Jwk, JwkParams, JwkParamsOct, JwkType}; +use identity_jose::jws::{ + CompactJwsEncoder, Decoder, JwsAlgorithm, JwsHeader, SignatureVerificationError, + SignatureVerificationErrorKind, +}; +use identity_jose::jwt::JwtClaims; +use identity_jose::jwu::{decode_b64, encode_b64}; +use serde_json::Value; +use sha2::{Digest, Sha256}; +use std::ops::{Add, Deref, DerefMut}; + +pub const II_CREDENTIAL_URL_PREFIX: &str = + "https://internetcomputer.org/credential/internet-identity/"; +pub const II_ISSUER_URL: &str = "https://internetcomputer.org/issuers/internet-identity"; +pub const VC_SIGNING_INPUT_DOMAIN: &[u8; 26] = b"iccs_verifiable_credential"; + +/// A pair of identities, that denote the same user. +/// Used in attribute sharing flow to maintain II's unlinkability of identities. +pub struct AliasTuple { + /// A temporary identity, used in attribute sharing flow. + pub id_alias: Principal, + /// An identity under which a user is known to a dapp. + pub id_dapp: Principal, +} + +#[derive(Debug)] +pub enum CredentialVerificationError { + InvalidJws(SignatureVerificationError), + InvalidClaims(JwtValidationError), +} + +/// Returns the effective bytes that will be signed when computing a canister signature for +/// the given JWT-credential, verfiable via the specified public key. +pub fn vc_signing_input( + credential_jwt: &str, + canister_sig_pk: &CanisterSigPublicKey, +) -> Result, String> { + let encoder = jws_encoder(credential_jwt, canister_sig_pk)?; + Ok(encoder.signing_input().to_vec()) +} + +/// Computes and returns SHA-256 hash of the given `signing_input` prefixed with +/// `length(VC_SIGNING_INPUT_DOMAIN) · VC_SIGNING_INPUT_DOMAIN` +/// (for domain separation), where `length(a)` is the length of byte-array `a`, +/// and `·` denotes concatenation of bytes. +pub fn vc_signing_input_hash(signing_input: &[u8]) -> Hash { + let mut hasher = Sha256::new(); + let buf = [VC_SIGNING_INPUT_DOMAIN.len() as u8]; + hasher.update(buf); + hasher.update(VC_SIGNING_INPUT_DOMAIN); + hasher.update(signing_input); + hasher.finalize().into() +} + +/// Constructs and returns a JWS (a signed JWT) from the given components. +pub fn vc_jwt_to_jws( + credential_jwt: &str, + canister_sig_pk: &CanisterSigPublicKey, + sig: &[u8], +) -> Result { + let encoder = jws_encoder(credential_jwt, canister_sig_pk)?; + Ok(encoder.into_jws(sig)) +} + +/// Returns a DID for the given `principal`. +pub fn did_for_principal(principal: Principal) -> String { + let prefix = String::from("did:icp:"); + prefix.add(&principal.to_string()) +} + +/// Verifies the given JWS-credential as an id_alias-VC for the specified alias tuple. +/// Performs both the cryptographic verification of the credential, and the semantic +/// validation of the id_alias-claims. +pub fn verify_id_alias_credential_jws( + credential_jws: &str, + alias_tuple: &AliasTuple, + canister_sig_pk: &CanisterSigPublicKey, + root_pk_raw: &[u8], +) -> Result<(), CredentialVerificationError> { + let claims = verify_credential_jws(credential_jws, canister_sig_pk, root_pk_raw) + .map_err(CredentialVerificationError::InvalidJws)?; + validate_id_alias_claims(claims, alias_tuple) + .map_err(CredentialVerificationError::InvalidClaims) +} + +/// Verifies the specified JWS credential cryptographically. +/// DOES NOT perform semantic validation of the claims in the credential. +pub fn verify_credential_jws( + credential_jws: &str, + canister_sig_pk: &CanisterSigPublicKey, + root_pk_raw: &[u8], +) -> Result, SignatureVerificationError> { + ///// Decode JWS. + let decoder: Decoder = Decoder::new(); + let jws = decoder + .decode_compact_serialization(credential_jws.as_ref(), None) + .map_err(|e| invalid_signature_err(&format!("credential JWS parsing error: {}", e)))?; + let signature = jws.decoded_signature(); + let message = signing_input_with_prefix(jws.signing_input()); + let jws_header = jws + .protected_header() + .ok_or(invalid_signature_err("missing JWS header"))?; + let canister_sig_pk_raw = get_canister_sig_pk_raw(jws_header)?; + if canister_sig_pk_raw != canister_sig_pk.to_raw() { + return Err(invalid_signature_err(&format!( + "wrong public key in JWS header, expected: {:?}", + canister_sig_pk + ))); + } + let root_pk_bytes: [u8; 96] = root_pk_raw + .try_into() + .map_err(|e| key_decoding_err(&format!("invalid root public key: {}", e)))?; + let root_pk = IcRootOfTrust::from(root_pk_bytes); + verify_canister_sig(&message, signature, canister_sig_pk_raw.as_slice(), root_pk) + .map_err(|e| invalid_signature_err(&format!("signature verification error: {}", e)))?; + + let claims: JwtClaims = serde_json::from_slice(jws.claims()) + .map_err(|e| invalid_signature_err(&format!("failed parsing JSON JWT claims: {}", e)))?; + + Ok(claims) +} + +/// Returns the given `signing_input` prefixed with +/// length(VC_SIGNING_INPUT_DOMAIN) || VC_SIGNING_INPUT_DOMAIN +/// (for domain separation). +fn signing_input_with_prefix(signing_input: &[u8]) -> Vec { + let mut result = Vec::from([VC_SIGNING_INPUT_DOMAIN.len() as u8]); + result.extend_from_slice(VC_SIGNING_INPUT_DOMAIN); + result.extend_from_slice(signing_input); + result +} + +/// Validates that the given claims are consistent with id_alias-credential +/// for the given alias tuple. +fn validate_id_alias_claims( + claims: JwtClaims, + alias_tuple: &AliasTuple, +) -> Result<(), JwtValidationError> { + validate_claim("sub", did_for_principal(alias_tuple.id_dapp), claims.sub())?; + validate_claim("iss", II_ISSUER_URL, claims.iss())?; + let vc = claims + .vc() + .ok_or(inconsistent_jwt_claims("missing vc in id_alias JWT claims"))?; + let subject_value = vc.get("credentialSubject").ok_or(inconsistent_jwt_claims( + "missing credentialSubject in id_alias JWT vc", + ))?; + validate_credential_subject(subject_value, alias_tuple)?; + Ok(()) +} + +fn validate_credential_subject( + subject_value: &Value, + alias_tuple: &AliasTuple, +) -> Result<(), JwtValidationError> { + let subject = Subject::from_json_value(subject_value.clone()) + .map_err(|_| inconsistent_jwt_claims("missing credentialSubject in id_alias JWT vc"))?; + if subject.properties["has_id_alias"] != did_for_principal(alias_tuple.id_alias) { + return Err(inconsistent_jwt_claims("wrong id_alias")); + } + Ok(()) +} + +fn validate_claim + std::fmt::Display, S: std::fmt::Display>( + label: &str, + expected: T, + actual: Option, +) -> Result<(), JwtValidationError> { + if let Some(actual) = actual { + if expected == actual { + Ok(()) + } else { + println!( + "inconsistent claim [{}] in id_alias VC:: expected: {}, actual: {}", + label, expected, actual + ); + Err(inconsistent_jwt_claims("inconsistent claim in id_alias VC")) + } + } else { + println!("missing claim [{}] in id_alias VC", label); + Err(inconsistent_jwt_claims("missing claim in id_alias VC")) + } +} + +// Per https://datatracker.ietf.org/doc/html/rfc7518#section-6.4, +// JwkParamsOct are for symmetric keys or another key whose value is a single octet sequence. +fn canister_sig_pk_jwk(canister_sig_pk_der: &[u8]) -> Result { + let mut cspk_jwk = Jwk::new(JwkType::Oct); + cspk_jwk.set_alg("IcCs"); + cspk_jwk + .set_params(JwkParams::Oct(JwkParamsOct { + k: encode_b64(canister_sig_pk_der), + })) + .map_err(|e| format!("internal: failed creating JWK: {:?}", e))?; + Ok(cspk_jwk) +} + +fn jws_encoder<'a>( + credential_jwt: &'a str, + canister_sig_pk: &CanisterSigPublicKey, +) -> Result, String> { + let mut header: JwsHeader = JwsHeader::new(); + header.set_alg(JwsAlgorithm::IcCs); + let kid = did_for_principal(canister_sig_pk.canister_id); + let jwk = canister_sig_pk_jwk(&canister_sig_pk.to_der())?; + header.set_kid(kid); + header.deref_mut().set_jwk(jwk); + + let encoder: CompactJwsEncoder = CompactJwsEncoder::new(credential_jwt.as_ref(), &header) + .map_err(|e| format!("internal: failed creating JWS encoder: {:?}", e))?; + Ok(encoder) +} + +fn unsupported_alg_err(custom_message: &str) -> SignatureVerificationError { + let err: SignatureVerificationError = SignatureVerificationErrorKind::UnsupportedAlg.into(); + err.with_custom_message(custom_message.to_string()) +} + +fn key_decoding_err(custom_message: &str) -> SignatureVerificationError { + let err: SignatureVerificationError = SignatureVerificationErrorKind::KeyDecodingFailure.into(); + err.with_custom_message(custom_message.to_string()) +} + +fn invalid_signature_err(custom_message: &str) -> SignatureVerificationError { + let err: SignatureVerificationError = SignatureVerificationErrorKind::InvalidSignature.into(); + err.with_custom_message(custom_message.to_string()) +} + +fn inconsistent_jwt_claims(custom_message: &'static str) -> JwtValidationError { + JwtValidationError::CredentialStructure(JwtVcError::InconsistentCredentialJwtClaims( + custom_message, + )) +} + +// Extracts and returns raw canister sig public key (without DER-prefix) from the given header. +fn get_canister_sig_pk_raw(jws_header: &JwsHeader) -> Result, SignatureVerificationError> { + let jwk = jws_header + .deref() + .jwk() + .ok_or(key_decoding_err("missing JWK in JWS header"))?; + if jwk.alg() != Some("IcCs") { + return Err(unsupported_alg_err("expected IcCs")); + } + // Per https://datatracker.ietf.org/doc/html/rfc7518#section-6.4, + // JwkParamsOct are for symmetric keys or another key whose value is a single octet sequence. + if jwk.kty() != JwkType::Oct { + return Err(unsupported_alg_err("expected JWK of type oct")); + } + let jwk_params = jwk + .try_oct_params() + .map_err(|_| key_decoding_err("missing JWK oct params"))?; + let pk_der = decode_b64(jwk_params.k.as_bytes()) + .map_err(|_| key_decoding_err("invalid base64url encoding"))?; + let pk_raw = extract_raw_canister_sig_pk_from_der(pk_der.as_slice()) + .map_err(|e| key_decoding_err(&e.to_string()))?; + Ok(pk_raw) +} + +#[cfg(test)] +mod tests { + use super::*; + use assert_matches::assert_matches; + use canister_sig_util::{extract_raw_root_pk_from_der, IC_ROOT_PK_DER_PREFIX}; + + const TEST_IC_ROOT_PK_B64URL: &str = "MIGCMB0GDSsGAQQBgtx8BQMBAgEGDCsGAQQBgtx8BQMCAQNhAK32VjilMFayIiyRuyRXsCdLypUZilrL2t_n_XIXjwab3qjZnpR52Ah6Job8gb88SxH-J1Vw1IHxaY951Giv4OV6zB4pj4tpeY2nqJG77Blwk-xfR1kJkj1Iv-1oQ9vtHw"; + const ALIAS_PRINCIPAL: &str = "s33qc-ctnp5-ubyz4-kubqo-p2tem-he4ls-6j23j-hwwba-37zbl-t2lv3-pae"; + const DAPP_PRINCIPAL: &str = "cpehq-54hef-odjjt-bockl-3ldtg-jqle4-ysi5r-6bfah-v6lsa-xprdv-pqe"; + const ID_ALIAS_CREDENTIAL_JWS: &str = "eyJqd2siOnsia3R5Ijoib2N0IiwiYWxnIjoiSWNDcyIsImsiOiJNRHd3REFZS0t3WUJCQUdEdUVNQkFnTXNBQW9BQUFBQUFBQUFBQUVCamxUYzNvSzVRVU9SbUt0T3YyVXBhMnhlQW5vNEJ4RlFFYmY1VWRUSTZlYyJ9LCJraWQiOiJkaWQ6aWNwOnJ3bGd0LWlpYWFhLWFhYWFhLWFhYWFhLWNhaSIsImFsZyI6IkljQ3MifQ.eyJpc3MiOiJodHRwczovL2ludGVybmV0Y29tcHV0ZXIub3JnL2lzc3VlcnMvaW50ZXJuZXQtaWRlbnRpdHkiLCJuYmYiOjE2MjAzMjg2MzAsImp0aSI6Imh0dHBzOi8vaW50ZXJuZXRjb21wdXRlci5vcmcvY3JlZGVudGlhbC9pbnRlcm5ldC1pZGVudGl0eS8xNjIwMzI4NjMwMDAwMDAwMDAwIiwic3ViIjoiZGlkOmljcDpjcGVocS01NGhlZi1vZGpqdC1ib2NrbC0zbGR0Zy1qcWxlNC15c2k1ci02YmZhaC12NmxzYS14cHJkdi1wcWUiLCJ2YyI6eyJAY29udGV4dCI6Imh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwidHlwZSI6WyJWZXJpZmlhYmxlQ3JlZGVudGlhbCIsIkludGVybmV0SWRlbnRpdHlJZEFsaWFzIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7Imhhc19pZF9hbGlhcyI6ImRpZDppY3A6czMzcWMtY3RucDUtdWJ5ejQta3VicW8tcDJ0ZW0taGU0bHMtNmoyM2otaHd3YmEtMzd6YmwtdDJsdjMtcGFlIn19fQ.2dn3omtjZXJ0aWZpY2F0ZVkBi9nZ96JkdHJlZYMBgwGDAYMCSGNhbmlzdGVygwJKAAAAAAAAAAABAYMBgwGDAYMCTmNlcnRpZmllZF9kYXRhggNYIMlBo1U8rvfGFEAvZoEFZX0uFlOGZLwgNjaBiyazTjUsggRYINLM_z_MXakw3sDoSiVB5lhRa0uxUB5w6LQQ5phqBX1gggRYIBfmGXVF1WCWPapsKI5MoFLJ55x11hQqSb_sRnrp5hFVggRYIBNvlU5ah4f5OsbVrHPPSsAhJo91Mf_fFkAE813rttVaggRYIEfscybxhCV3H9WVS6yOWyrSfnoAvrk5mr3vaKZOwOZiggRYID_qjkmyX1ydMvjuG7MS1E4grrzurjpGjbvYR7-YHMXwgwGCBFggNVP2WB1Ts90nZG9hyLDaCww4gbhXxtw8R-poiMET62uDAkR0aW1lggNJgLiu1N2JpL4WaXNpZ25hdHVyZVgwogHXOX8bnQxCHy8TOkAG2Xak_qb2Yx22j5c9R5WC-8ResKLfeGgkSWbadE92xqRRZHRyZWWDAYIEWCB1hhWALXUuzFwXrojqFkaSB6Yejid7LwgvbIj61MjIN4MCQ3NpZ4MCWCA6UuW6rWVPRqQn_k-pP9kMNe6RKs1gj7QVCsaG4Bx2OYMBggRYIOxGloHVCCWojZGGGusUYkg0Q-v_podIYMUM-jvDBF62gwJYIP28vIabsWSa5kTsn1ypw6vHamcQnTcYFNsiRlZMNcbAggNA"; + const ID_ALIAS_CREDENTIAL_JWS_NO_JWK: &str = "eyJraWQiOiJkaWQ6aWM6aWktY2FuaXN0ZXIiLCJhbGciOiJJY0NzIn0.eyJpc3MiOiJodHRwczovL2ludGVybmV0Y29tcHV0ZXIub3JnL2lzc3VlcnMvaW50ZXJuZXQtaWRlbml0eSIsIm5iZiI6MTYyMDMyODYzMCwianRpIjoiaHR0cHM6Ly9pbnRlcm5ldGNvbXB1dGVyLm9yZy9jcmVkZW50aWFsL2ludGVybmV0LWlkZW5pdHkiLCJzdWIiOiJkaWQ6d2ViOmNwZWhxLTU0aGVmLW9kamp0LWJvY2tsLTNsZHRnLWpxbGU0LXlzaTVyLTZiZmFoLXY2bHNhLXhwcmR2LXBxZSIsInZjIjp7IkBjb250ZXh0IjoiaHR0cHM6Ly93d3cudzMub3JnLzIwMTgvY3JlZGVudGlhbHMvdjEiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiSW50ZXJuZXRJZGVudGl0eUlkQWxpYXMiXSwiY3JlZGVudGlhbFN1YmplY3QiOnsiaGFzX2lkX2FsaWFzIjoiZGlkOndlYjpzMzNxYy1jdG5wNS11Ynl6NC1rdWJxby1wMnRlbS1oZTRscy02ajIzai1od3diYS0zN3pibC10Mmx2My1wYWUifX19.2dn3omtjZXJ0aWZpY2F0ZVkBi9nZ96JkdHJlZYMBgwGDAYMCSGNhbmlzdGVygwJKAAAAAAAAAAABAYMBgwGDAYMCTmNlcnRpZmllZF9kYXRhggNYIG3uU_jutBtXB-of0uEA3RkCrcunK6D8QFPtX-gDSwDeggRYINLM_z_MXakw3sDoSiVB5lhRa0uxUB5w6LQQ5phqBX1gggRYIMULjwe1N6XomH10SEyc2r_uc7mGf1aSadeDaid9cUrkggRYIDw__VW2PgWMFp6mK-GmPG-7Fc90q58oK_wjcJ3IrkToggRYIAQTcQAtnxsa93zbfZEZV0f28OhiXL5Wp1OAyDHNI_x4ggRYINkQ8P9zGUvsVi3XbQ2bs6V_3kAiN8UNM6yPgeXfmArEgwGCBFggNVP2WB1Ts90nZG9hyLDaCww4gbhXxtw8R-poiMET62uDAkR0aW1lggNJgLiu1N2JpL4WaXNpZ25hdHVyZVgwqHrYoUsNvSEaSShbW8barx0_ODXD5ZBEl9nKOdkNy_fBmGErE_C7ILbC91_fyZ7CZHRyZWWDAYIEWCB223o-sI97tc3LwJL3LRxQ4If6v_IvfC1fwIGYYQ9vroMCQ3NpZ4MCWCA6UuW6rWVPRqQn_k-pP9kMNe6RKs1gj7QVCsaG4Bx2OYMBgwJYIHszMLDS2VadioIaHajRY5iJzroqMs63lVrs_Uj42j0sggNAggRYICm0w_XxGEw4fDPoYcojCILEi0qdH4-4Zw7klzdaPNOC"; + const TEST_SIGNING_CANISTER_ID: &str = "rwlgt-iiaaa-aaaaa-aaaaa-cai"; + const TEST_SEED: [u8; 32] = [ + 142, 84, 220, 222, 130, 185, 65, 67, 145, 152, 171, 78, 191, 101, 41, 107, 108, 94, 2, 122, + 56, 7, 17, 80, 17, 183, 249, 81, 212, 200, 233, 231, + ]; + const TEST_CREDENTIAL_JWT: &str = r#"{"iss":"https://employment.info/","nbf":1620328630,"jti":"https://employment.info/credentials/42","sub":"did:icp:igfpm-3fhrp-syqme-4i4xk-o4pgd-5xdh4-fbbgw-jnxm5-bvou4-ljt52-kqe","vc":{"@context":"https://www.w3.org/2018/credentials/v1","type":["VerifiableCredential","VerifiedEmployee"],"credentialSubject":{"employee_of":{"employerId":"did:web:dfinity.org","employerName":"DFINITY Foundation"}}}}"#; + + fn test_ic_root_pk_raw() -> Vec { + let pk_der = decode_b64(TEST_IC_ROOT_PK_B64URL).expect("failure decoding canister pk"); + extract_raw_root_pk_from_der(pk_der.as_slice()) + .expect("failure extracting root pk from DER") + } + + fn test_canister_sig_pk() -> CanisterSigPublicKey { + CanisterSigPublicKey::new( + Principal::from_text(TEST_SIGNING_CANISTER_ID).expect("wrong principal"), + TEST_SEED.to_vec(), + ) + } + + fn alias_principal() -> Principal { + Principal::from_text(ALIAS_PRINCIPAL).expect("wrong principal") + } + + fn dapp_principal() -> Principal { + Principal::from_text(DAPP_PRINCIPAL).expect("wrong principal") + } + + fn claims_from_jws(credential_jws: &str) -> JwtClaims { + let decoder: Decoder = Decoder::new(); + let jws = decoder + .decode_compact_serialization(credential_jws.as_ref(), None) + .expect("failed JWS parsing"); + let claims: JwtClaims = + serde_json::from_slice(jws.claims()).expect("failed parsing JSON JWT claims"); + claims + } + + #[test] + fn should_compute_domain_separated_signing_input_hash() { + let signing_input = b"some bytes to sign"; + let signing_input_with_prefix = signing_input_with_prefix(signing_input.as_slice()); + assert_eq!(26, signing_input_with_prefix[0]); + assert_eq!( + b"iccs_verifiable_credential".as_slice(), + signing_input_with_prefix[1..27].to_vec().as_slice() + ); + let util_hash = vc_signing_input_hash(signing_input); + let mut hasher = Sha256::new(); + hasher.update(signing_input_with_prefix); + let manual_hash: Hash = hasher.finalize().into(); + assert_eq!(util_hash, manual_hash); + } + + #[test] + fn should_construct_correct_jws() { + let canister_id = Principal::from_text(TEST_SIGNING_CANISTER_ID).expect("wrong principal"); + let canister_sig_pk = CanisterSigPublicKey::new(canister_id, TEST_SEED.to_vec()); + let dummy_sig: &str = "some signature"; + let credential_jwt = String::from_utf8(TEST_CREDENTIAL_JWT.into()).expect("wrong JWT"); + let credential_jws = vc_jwt_to_jws(&credential_jwt, &canister_sig_pk, dummy_sig.as_bytes()) + .expect("failed constructing JWS"); + let decoder: Decoder = Decoder::new(); + let jws = decoder + .decode_compact_serialization(credential_jws.as_ref(), None) + .expect("Failed parsing constructed JWS"); + assert_eq!(dummy_sig.as_bytes(), jws.decoded_signature()); + let jws_header = jws.protected_header().expect("JWS without header"); + let canister_sig_pk_from_jws = + get_canister_sig_pk_raw(jws_header).expect("JWS header without pk"); + let canister_sig_pk_raw = + extract_raw_canister_sig_pk_from_der(canister_sig_pk.to_der().as_slice()) + .expect("wrong canister sig pk"); + assert_eq!(canister_sig_pk_from_jws, canister_sig_pk_raw); + assert_eq!(jws.claims(), TEST_CREDENTIAL_JWT.as_bytes()); + } + + #[test] + fn should_compute_icp_did() { + let principal = dapp_principal(); + let did = did_for_principal(principal); + assert!(did.starts_with("did:icp:")); + assert!(did.ends_with(&principal.to_string())); + assert_eq!(did.len(), "did:icp:".len() + principal.to_string().len()); + } + + #[test] + fn should_validate_id_alias_claims() { + validate_id_alias_claims( + claims_from_jws(ID_ALIAS_CREDENTIAL_JWS), + &AliasTuple { + id_alias: alias_principal(), + id_dapp: dapp_principal(), + }, + ) + .expect("Failed validating id_alias claims"); + } + + #[test] + fn should_fail_validate_id_alias_claims_if_wrong_id_alias() { + let result = validate_id_alias_claims( + claims_from_jws(ID_ALIAS_CREDENTIAL_JWS), + &AliasTuple { + id_alias: dapp_principal(), + id_dapp: dapp_principal(), + }, + ); + assert_matches!(result, Err(e) if format!("{:?}", e).contains("wrong id_alias")); + } + + #[test] + fn should_fail_validate_id_alias_claims_if_wrong_id_dapp() { + let result = validate_id_alias_claims( + claims_from_jws(ID_ALIAS_CREDENTIAL_JWS), + &AliasTuple { + id_alias: dapp_principal(), + id_dapp: dapp_principal(), + }, + ); + assert_matches!(result, Err(e) if format!("{:?}", e).contains("wrong id_alias")); + } + + #[test] + fn should_verify_credential_jws() { + verify_credential_jws( + ID_ALIAS_CREDENTIAL_JWS, + &test_canister_sig_pk(), + &test_ic_root_pk_raw(), + ) + .expect("JWS verification failed"); + } + + #[test] + fn should_fail_verify_credential_jws_without_canister_pk() { + let result = verify_credential_jws( + ID_ALIAS_CREDENTIAL_JWS_NO_JWK, + &test_canister_sig_pk(), + &test_ic_root_pk_raw(), + ); + assert_matches!(result, Err(e) if e.to_string().contains("missing JWK in JWS header")); + } + + #[test] + fn should_fail_verify_credential_jws_with_wrong_canister_sig_pk() { + let wrong_canister_sig_pk = CanisterSigPublicKey::new(alias_principal(), vec![1, 2, 3]); + let result = verify_credential_jws( + ID_ALIAS_CREDENTIAL_JWS, + &wrong_canister_sig_pk, + &test_ic_root_pk_raw(), + ); + assert_matches!(result, Err(e) if e.to_string().contains("wrong public key in JWS header")); + } + + #[test] + fn should_fail_verify_credential_jws_with_wrong_root_pk() { + let mut ic_root_pk = test_ic_root_pk_raw(); + ic_root_pk[IC_ROOT_PK_DER_PREFIX.len()] += 1; // change the root pk value + let result = verify_credential_jws( + ID_ALIAS_CREDENTIAL_JWS, + &test_canister_sig_pk(), + &ic_root_pk, + ); + assert_matches!(result, Err(e) if { let err_msg = e.to_string(); + err_msg.contains("invalid signature") && + err_msg.contains("Malformed ThresBls12_381 public key") }); + } + + #[test] + fn should_verify_id_alias_credential_jws() { + verify_id_alias_credential_jws( + ID_ALIAS_CREDENTIAL_JWS, + &AliasTuple { + id_alias: alias_principal(), + id_dapp: dapp_principal(), + }, + &test_canister_sig_pk(), + &test_ic_root_pk_raw(), + ) + .expect("JWS verification failed"); + } +}