diff --git a/Cargo.lock b/Cargo.lock index 9eb4508..5c93394 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aead" @@ -37,6 +37,21 @@ dependencies = [ "subtle", ] +[[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.93" @@ -49,6 +64,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "autocfg" version = "1.4.0" @@ -79,6 +100,15 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[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" @@ -117,12 +147,46 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[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 = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" + +[[package]] +name = "cached" +version = "0.49.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e8e463fceca5674287f32d252fb1d94083758b8709c160efae66d263e5f4eba" +dependencies = [ + "hashbrown", + "instant", + "once_cell", + "thiserror", +] + [[package]] name = "candid" version = "0.10.10" @@ -173,6 +237,19 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chrono" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "num-traits", + "serde", + "windows-targets", +] + [[package]] name = "ciborium" version = "0.2.2" @@ -197,7 +274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", - "half", + "half 2.4.1", ] [[package]] @@ -210,6 +287,42 @@ dependencies = [ "inout", ] +[[package]] +name = "comparable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8606f9aa5b5a2df738584b139c79413d0c1545ed0ffd16e76e0944d1de7388c0" +dependencies = [ + "comparable_derive", + "comparable_helper", + "pretty_assertions", + "serde", +] + +[[package]] +name = "comparable_derive" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f36ea7383b9a2a9ae0a4e225d8a9c1c3aeadde78c59cdc35bad5c02b4dad01" +dependencies = [ + "convert_case 0.4.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "comparable_helper" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71c9b60259084f32c14d32476f3a299b4997e3c186e1473bd972ff8a8c83d1b4" +dependencies = [ + "convert_case 0.6.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "const-hex" version = "1.13.2" @@ -229,6 +342,27 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "coset" version = "0.3.8" @@ -324,6 +458,41 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "darling" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + [[package]] name = "data-encoding" version = "2.6.0" @@ -350,6 +519,12 @@ dependencies = [ "powerfmt", ] +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + [[package]] name = "digest" version = "0.10.7" @@ -429,6 +604,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + [[package]] name = "ff" version = "0.13.0" @@ -445,6 +629,12 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "futures" version = "0.3.31" @@ -577,6 +767,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "half" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" + [[package]] name = "half" version = "2.4.1" @@ -587,6 +783,12 @@ dependencies = [ "crunchy", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heck" version = "0.5.0" @@ -620,6 +822,104 @@ dependencies = [ "digest", ] +[[package]] +name = "iana-time-zone" +version = "0.1.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" +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.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "byte-unit", + "bytes", + "candid", + "comparable", + "hex", + "ic-crypto-sha2", + "ic-protobuf", + "phantom_newtype", + "prost", + "serde", + "strum", + "strum_macros", +] + +[[package]] +name = "ic-btc-interface" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0152e14e697b0e988dbfdcb3f7e352d1c76a65b7d2d75c5d76bad22c3aca10d" +dependencies = [ + "candid", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-btc-replica-types" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "candid", + "ic-btc-interface", + "ic-error-types", + "ic-protobuf", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-canister-sig-creation" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db33deb06e0edb366d8d86ef67d7bc1e1759bc7046b0323a33b85b21b8d8d87" +dependencies = [ + "candid", + "hex", + "ic-cdk 0.14.1", + "ic-certification 2.6.0", + "ic-representation-independent-hash", + "lazy_static", + "serde", + "serde_bytes", + "serde_cbor", + "sha2", + "thiserror", +] + +[[package]] +name = "ic-cdk" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cff1a3c3db565e3384c9c9d6d676b0a3f89a0886f4f787294d9c946d844369f" +dependencies = [ + "candid", + "ic-cdk-macros 0.14.0", + "ic0", + "serde", + "serde_bytes", +] + [[package]] name = "ic-cdk" version = "0.17.0" @@ -627,12 +927,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2abdf9341da9f9f6b451a40609cb69645a05a8e9eb7784c16209f16f2c0f76f" dependencies = [ "candid", - "ic-cdk-macros", + "ic-cdk-macros 0.17.0", "ic0", "serde", "serde_bytes", ] +[[package]] +name = "ic-cdk-macros" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01dc6bc425ec048d6ac4137c7c0f2cfbd6f8b0be8efc568feae2b265f566117c" +dependencies = [ + "candid", + "proc-macro2", + "quote", + "serde", + "serde_tokenstream", + "syn 2.0.89", +] + [[package]] name = "ic-cdk-macros" version = "0.17.0" @@ -654,7 +968,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb8fd812a9e26f6aa00594546f8fbf4d4853f39c3ba794c8ff11ecf86fd3c9e4" dependencies = [ "futures", - "ic-cdk", + "ic-cdk 0.17.0", "ic0", "serde", "serde_bytes", @@ -662,62 +976,528 @@ dependencies = [ ] [[package]] -name = "ic-crypto-ed25519" +name = "ic-certification" version = "0.9.0" source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" dependencies = [ - "curve25519-dalek", - "ed25519-dalek", - "hkdf", - "pem", - "rand", - "thiserror", - "zeroize", + "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-crypto-secp256k1" +name = "ic-certification" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64ee3d8b6e81b51f245716d3e0badb63c283c00f3c9fb5d5219afc30b5bf821" +dependencies = [ + "hex", + "serde", + "serde_bytes", + "sha2", +] + +[[package]] +name = "ic-crypto-ecdsa-secp256r1" version = "0.9.0" source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" dependencies = [ "hmac", - "k256", "lazy_static", "num-bigint", + "p256", "pem", "rand", "rand_chacha", + "sha2", "simple_asn1", "zeroize", ] [[package]] -name = "ic-stable-structures" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf89c1bc326c72498bcc0cd954f2edf718c018e7c586d2193d701d3c9af29a" +name = "ic-crypto-ed25519" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" dependencies = [ - "ic_principal", + "curve25519-dalek", + "ed25519-dalek", + "hkdf", + "pem", + "rand", + "thiserror", + "zeroize", ] [[package]] -name = "ic0" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de254dd67bbd58073e23dc1c8553ba12fa1dc610a19de94ad2bbcd0460c067f" +name = "ic-crypto-iccsa" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-crypto-internal-basic-sig-iccsa", +] [[package]] -name = "ic_cose_canister" -version = "0.4.0" +name = "ic-crypto-internal-basic-sig-cose" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" dependencies = [ - "candid", - "ciborium", + "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.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "hex", + "ic-types", + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-ecdsa-secp256k1" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-internal-types", + "ic-crypto-secp256k1", + "ic-crypto-secrets-containers", + "ic-types", + "serde", + "serde_bytes", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-basic-sig-ecdsa-secp256r1" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "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.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "curve25519-dalek", + "hex", + "ic-crypto-ed25519", + "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.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "hex", + "ic-certification 0.9.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.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-crypto-internal-basic-sig-der-utils", + "ic-crypto-sha2", + "ic-types", + "num-bigint", + "num-traits", + "pkcs8", + "rsa", + "serde", + "sha2", + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-bls12-381-type" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "hex", + "ic_bls12_381", + "itertools", + "lazy_static", + "pairing", + "paste", + "rand", + "rand_chacha", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-seed" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "hex", + "ic-crypto-sha2", + "rand", + "rand_chacha", + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-sha2" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "sha2", +] + +[[package]] +name = "ic-crypto-internal-threshold-sig-bls12381" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "cached", + "hex", + "ic-crypto-internal-bls12-381-type", + "ic-crypto-internal-seed", + "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", + "subtle", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-types" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "arrayvec 0.7.6", + "hex", + "ic-protobuf", + "phantom_newtype", + "serde", + "serde_cbor", + "strum", + "strum_macros", + "thiserror", + "zeroize", +] + +[[package]] +name = "ic-crypto-secp256k1" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "hmac", + "k256", + "lazy_static", + "num-bigint", + "pem", + "rand", + "rand_chacha", + "simple_asn1", + "zeroize", +] + +[[package]] +name = "ic-crypto-secrets-containers" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-sha2" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-crypto-internal-sha2", +] + +[[package]] +name = "ic-crypto-standalone-sig-verifier" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +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-sha2", + "ic-types", +] + +[[package]] +name = "ic-crypto-tree-hash" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-crypto-internal-types", + "ic-crypto-sha2", + "ic-protobuf", + "serde", + "serde_bytes", + "thiserror", +] + +[[package]] +name = "ic-crypto-utils-threshold-sig" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "ic-crypto-internal-threshold-sig-bls12381", + "ic-crypto-internal-types", + "ic-types", +] + +[[package]] +name = "ic-crypto-utils-threshold-sig-der" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "ic-crypto-internal-types", + "ic-types", + "simple_asn1", +] + +[[package]] +name = "ic-error-types" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-protobuf", + "ic-utils", + "serde", + "strum", + "strum_macros", +] + +[[package]] +name = "ic-limits" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" + +[[package]] +name = "ic-management-canister-types" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "candid", + "ic-base-types", + "ic-btc-interface", + "ic-btc-replica-types", + "ic-error-types", + "ic-protobuf", + "ic-utils", + "num-traits", + "serde", + "serde_bytes", + "serde_cbor", + "strum", + "strum_macros", +] + +[[package]] +name = "ic-protobuf" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "bincode", + "candid", + "erased-serde", + "prost", + "serde", + "serde_json", + "slog", +] + +[[package]] +name = "ic-representation-independent-hash" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08ae59483e377cd9aad94ec339ed1d2583b0d5929cab989328dac2d853b2f570" +dependencies = [ + "leb128", + "sha2", +] + +[[package]] +name = "ic-stable-structures" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcaf89c1bc326c72498bcc0cd954f2edf718c018e7c586d2193d701d3c9af29a" +dependencies = [ + "ic_principal", +] + +[[package]] +name = "ic-types" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "base64", + "bincode", + "candid", + "chrono", + "hex", + "ic-base-types", + "ic-btc-replica-types", + "ic-crypto-internal-types", + "ic-crypto-sha2", + "ic-crypto-tree-hash", + "ic-error-types", + "ic-limits", + "ic-management-canister-types", + "ic-protobuf", + "ic-utils", + "ic-validate-eq", + "ic-validate-eq-derive", + "maplit", + "once_cell", + "phantom_newtype", + "prost", + "serde", + "serde_bytes", + "serde_cbor", + "serde_json", + "serde_with", + "strum", + "strum_macros", + "thiserror", + "thousands", +] + +[[package]] +name = "ic-utils" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "hex", + "scoped_threadpool", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-validate-eq" +version = "0.0.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-validate-eq-derive", +] + +[[package]] +name = "ic-validate-eq-derive" +version = "0.0.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ic0" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de254dd67bbd58073e23dc1c8553ba12fa1dc610a19de94ad2bbcd0460c067f" + +[[package]] +name = "ic_bls12_381" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22c65787944f32af084dffd0c68c1e544237b76e215654ddea8cd9f527dd8b69" +dependencies = [ + "digest", + "ff", + "group", + "pairing", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "ic_cose_canister" +version = "0.4.0" +dependencies = [ + "candid", + "ciborium", "const-hex", "getrandom", - "ic-cdk", + "ic-canister-sig-creation", + "ic-cdk 0.17.0", "ic-cdk-timers", + "ic-certification 2.6.0", "ic-crypto-ed25519", "ic-crypto-secp256k1", + "ic-crypto-standalone-sig-verifier", "ic-stable-structures", "ic_cose_types", "serde", @@ -736,7 +1516,7 @@ dependencies = [ "ed25519-dalek", "hkdf", "hmac", - "ic-cdk", + "ic-cdk 0.17.0", "icrc-ledger-types", "k256", "num-traits", @@ -780,6 +1560,12 @@ dependencies = [ "time", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "inout" version = "0.1.3" @@ -789,6 +1575,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + [[package]] name = "itertools" version = "0.12.1" @@ -804,6 +1599,16 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" +[[package]] +name = "js-sys" +version = "0.3.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + [[package]] name = "k256" version = "0.13.4" @@ -832,6 +1637,9 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] [[package]] name = "leb128" @@ -851,6 +1659,28 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + [[package]] name = "memchr" version = "2.7.4" @@ -880,6 +1710,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-conv" version = "0.1.0" @@ -895,6 +1742,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -917,6 +1775,50 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[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", +] + +[[package]] +name = "pairing" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fec4625e73cf41ef4bb6846cafa6d44736525f442ba45e407c4a000a13996f" +dependencies = [ + "group", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + [[package]] name = "paste" version = "1.0.15" @@ -941,6 +1843,17 @@ dependencies = [ "base64ct", ] +[[package]] +name = "phantom_newtype" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "candid", + "num-traits", + "serde", + "slog", +] + [[package]] name = "pin-project-lite" version = "0.2.15" @@ -953,6 +1866,17 @@ 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" @@ -996,11 +1920,30 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b55c4d17d994b637e2f4daf6e5dc5d660d209d5642377d675d7a1c3ab69fa579" dependencies = [ - "arrayvec", + "arrayvec 0.5.2", "typed-arena", "unicode-width", ] +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + [[package]] name = "proc-macro2" version = "1.0.92" @@ -1026,6 +1969,29 @@ dependencies = [ "unarray", ] +[[package]] +name = "prost" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "psm" version = "0.1.24" @@ -1083,6 +2049,15 @@ dependencies = [ "rand_core", ] +[[package]] +name = "redox_syscall" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +dependencies = [ + "bitflags", +] + [[package]] name = "regex-syntax" version = "0.8.5" @@ -1099,6 +2074,27 @@ dependencies = [ "subtle", ] +[[package]] +name = "rsa" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c75d7c5c6b673e58bf54d8544a9f432e3a925b0e80f7cd3602ab5c50c55519" +dependencies = [ + "const-oid", + "digest", + "num-bigint-dig", + "num-integer", + "num-traits", + "pkcs1", + "pkcs8", + "rand_core", + "sha2", + "signature", + "spki", + "subtle", + "zeroize", +] + [[package]] name = "rustc_version" version = "0.4.1" @@ -1114,6 +2110,24 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[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" @@ -1152,6 +2166,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half 1.8.3", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.215" @@ -1163,6 +2187,18 @@ dependencies = [ "syn 2.0.89", ] +[[package]] +name = "serde_json" +version = "1.0.134" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + [[package]] name = "serde_tokenstream" version = "0.2.2" @@ -1175,6 +2211,28 @@ dependencies = [ "syn 2.0.89", ] +[[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.8" @@ -1233,6 +2291,15 @@ 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.7" @@ -1242,6 +2309,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "spki" version = "0.7.3" @@ -1265,6 +2344,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "strum" version = "0.26.3" @@ -1335,6 +2420,12 @@ dependencies = [ "syn 2.0.89", ] +[[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.36" @@ -1366,6 +2457,16 @@ dependencies = [ "time-core", ] +[[package]] +name = "tree-deserializer" +version = "0.9.0" +source = "git+https://github.com/dfinity/ic/?rev=5d202894864f4db4a5a46f44422aebc80c3d321b#5d202894864f4db4a5a46f44422aebc80c3d321b" +dependencies = [ + "ic-crypto-tree-hash", + "leb128", + "serde", +] + [[package]] name = "typed-arena" version = "2.0.2" @@ -1390,6 +2491,12 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + [[package]] name = "unicode-width" version = "0.1.14" @@ -1406,6 +2513,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "utf8-width" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3" + [[package]] name = "version_check" version = "0.9.5" @@ -1418,6 +2531,69 @@ 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.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn 2.0.89", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.59.0" @@ -1503,6 +2679,12 @@ dependencies = [ "zeroize", ] +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + [[package]] name = "zerocopy" version = "0.7.35" diff --git a/Cargo.toml b/Cargo.toml index 967ff0e..97902a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,11 @@ ic-cdk = "0.17" ic-cdk-timers = "0.11" ic-stable-structures = "0.6" icrc-ledger-types = "0.1" +ic-certification = "2.6" +ic-canister-sig-creation = "1.1" getrandom = { version = "0.2", features = ["custom"] } coset = "0.3" aes-gcm = "0.10" ic-crypto-secp256k1 = { git = "https://github.com/dfinity/ic/", rev = "5d202894864f4db4a5a46f44422aebc80c3d321b" } ic-crypto-ed25519 = { git = "https://github.com/dfinity/ic/", rev = "5d202894864f4db4a5a46f44422aebc80c3d321b" } +ic-crypto-standalone-sig-verifier = { git = "https://github.com/dfinity/ic/", rev = "5d202894864f4db4a5a46f44422aebc80c3d321b" } diff --git a/canister_ids.json b/canister_ids.json index 084b170..79abf1c 100644 --- a/canister_ids.json +++ b/canister_ids.json @@ -1,5 +1,9 @@ { + "__Candid_UI": { + "local": "bnz7o-iuaaa-aaaaa-qaaaa-cai" + }, "ic_cose_canister": { - "ic": "53cyg-yyaaa-aaaap-ahpua-cai" + "ic": "53cyg-yyaaa-aaaap-ahpua-cai", + "local": "53cyg-yyaaa-aaaap-ahpua-cai" } } \ No newline at end of file diff --git a/src/ic_cose_canister/Cargo.toml b/src/ic_cose_canister/Cargo.toml index 839ffa6..e34a876 100644 --- a/src/ic_cose_canister/Cargo.toml +++ b/src/ic_cose_canister/Cargo.toml @@ -25,5 +25,8 @@ ic-cdk-timers = { workspace = true } ic-stable-structures = { workspace = true } ic-crypto-secp256k1 = { workspace = true } ic-crypto-ed25519 = { workspace = true } +ic-canister-sig-creation = { workspace = true } +ic-certification = { workspace = true } +ic-crypto-standalone-sig-verifier = { workspace = true } getrandom = { version = "0.2", features = ["custom"] } ic_cose_types = { path = "../ic_cose_types", version = "0.4" } diff --git a/src/ic_cose_canister/README.md b/src/ic_cose_canister/README.md index b62b0ad..38b8beb 100644 --- a/src/ic_cose_canister/README.md +++ b/src/ic_cose_canister/README.md @@ -23,14 +23,20 @@ ecdh_cose_encrypted_key : (SettingPath, ECDHInput) -> (Result_3); ecdsa_public_key : (opt PublicKeyInput) -> (Result_4) query; ecdsa_sign : (SignInput) -> (Result_5); + get_delegation : (blob, blob, nat64) -> (Result_6) query; namespace_add_auditors : (text, vec principal) -> (Result); + namespace_add_delegator : (NamespaceDelegatorsInput) -> (Result_7); namespace_add_managers : (text, vec principal) -> (Result); namespace_add_users : (text, vec principal) -> (Result); + namespace_get_delegators : (text, text) -> (Result_7) query; + namespace_get_fixed_identity : (text, text) -> (Result_8) query; namespace_get_info : (text) -> (Result_1) query; namespace_remove_auditors : (text, vec principal) -> (Result); + namespace_remove_delegator : (NamespaceDelegatorsInput) -> (Result); namespace_remove_managers : (text, vec principal) -> (Result); namespace_remove_users : (text, vec principal) -> (Result); - namespace_top_up : (text, nat) -> (Result_6); + namespace_sign_delegation : (SignDelegationInput) -> (Result_9); + namespace_top_up : (text, nat) -> (Result_10); namespace_update_info : (UpdateNamespaceInput) -> (Result); schnorr_public_key : (SchnorrAlgorithm, opt PublicKeyInput) -> ( Result_4, @@ -38,16 +44,22 @@ schnorr_sign : (SchnorrAlgorithm, SignInput) -> (Result_5); schnorr_sign_identity : (SchnorrAlgorithm, SignIdentityInput) -> (Result_5); setting_add_readers : (SettingPath, vec principal) -> (Result); - setting_create : (SettingPath, CreateSettingInput) -> (Result_7); - setting_get : (SettingPath) -> (Result_8) query; - setting_get_archived_payload : (SettingPath) -> (Result_9) query; - setting_get_info : (SettingPath) -> (Result_8) query; + setting_create : (SettingPath, CreateSettingInput) -> (Result_11); + setting_get : (SettingPath) -> (Result_12) query; + setting_get_archived_payload : (SettingPath) -> (Result_13) query; + setting_get_info : (SettingPath) -> (Result_12) query; setting_remove_readers : (SettingPath, vec principal) -> (Result); - setting_update_info : (SettingPath, UpdateSettingInfoInput) -> (Result_7); + setting_update_info : (SettingPath, UpdateSettingInfoInput) -> (Result_11); setting_update_payload : (SettingPath, UpdateSettingPayloadInput) -> ( - Result_7, + Result_11, ); - state_get_info : () -> (Result_10) query; + state_get_info : () -> (Result_14) query; + validate2_admin_add_allowed_apis : (vec text) -> (Result_15); + validate2_admin_add_auditors : (vec principal) -> (Result_15); + validate2_admin_add_managers : (vec principal) -> (Result_15); + validate2_admin_remove_allowed_apis : (vec text) -> (Result_15); + validate2_admin_remove_auditors : (vec principal) -> (Result_15); + validate2_admin_remove_managers : (vec principal) -> (Result_15); validate_admin_add_allowed_apis : (vec text) -> (Result); validate_admin_add_auditors : (vec principal) -> (Result); validate_admin_add_managers : (vec principal) -> (Result); @@ -67,6 +79,7 @@ Deploy to local network: dfx deploy ic_cose_canister # or with arguments +# dfx canister create --specified-id 53cyg-yyaaa-aaaap-ahpua-cai ic_cose_canister dfx deploy ic_cose_canister --argument "(opt variant {Init = record { name = \"LDC Labs\"; diff --git a/src/ic_cose_canister/ic_cose_canister.did b/src/ic_cose_canister/ic_cose_canister.did index 5b27989..687e146 100644 --- a/src/ic_cose_canister/ic_cose_canister.did +++ b/src/ic_cose_canister/ic_cose_canister.did @@ -1,5 +1,5 @@ -type ChainArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs }; type CreateNamespaceInput = record { + session_expires_in_ms : opt nat64; managers : vec principal; desc : opt text; name : text; @@ -20,6 +20,11 @@ type CreateSettingOutput = record { created_at : nat64; version : nat32; }; +type Delegation = record { + pubkey : blob; + targets : opt vec principal; + expiration : nat64; +}; type ECDHInput = record { public_key : blob; nonce : blob }; type ECDHOutput = record { public_key : blob; payload : blob }; type InitArgs = record { @@ -32,9 +37,16 @@ type InitArgs = record { subnet_size : nat64; vetkd_key_name : text; }; +type InstallArgs = variant { Upgrade : UpgradeArgs; Init : InitArgs }; +type NamespaceDelegatorsInput = record { + ns : text; + delegators : vec principal; + name : text; +}; type NamespaceInfo = record { status : int8; updated_at : nat64; + session_expires_in_ms : nat64; managers : vec principal; payload_bytes_total : nat64; desc : text; @@ -43,6 +55,7 @@ type NamespaceInfo = record { created_at : nat64; auditors : vec principal; settings_total : nat64; + fixed_id_names : vec record { text; vec principal }; user_settings_total : nat64; users : vec principal; visibility : nat8; @@ -52,16 +65,20 @@ type PublicKeyInput = record { ns : text; derivation_path : vec blob }; type PublicKeyOutput = record { public_key : blob; chain_code : blob }; type Result = variant { Ok; Err : text }; type Result_1 = variant { Ok : NamespaceInfo; Err : text }; -type Result_10 = variant { Ok : StateInfo; Err : text }; -type Result_11 = variant { Ok : text; Err : text }; +type Result_10 = variant { Ok : nat; Err : text }; +type Result_11 = variant { Ok : CreateSettingOutput; Err : text }; +type Result_12 = variant { Ok : SettingInfo; Err : text }; +type Result_13 = variant { Ok : SettingArchivedPayload; Err : text }; +type Result_14 = variant { Ok : StateInfo; Err : text }; +type Result_15 = variant { Ok : text; Err : text }; type Result_2 = variant { Ok : vec NamespaceInfo; Err : text }; type Result_3 = variant { Ok : ECDHOutput; Err : text }; type Result_4 = variant { Ok : PublicKeyOutput; Err : text }; type Result_5 = variant { Ok : blob; Err : text }; -type Result_6 = variant { Ok : nat; Err : text }; -type Result_7 = variant { Ok : CreateSettingOutput; Err : text }; -type Result_8 = variant { Ok : SettingInfo; Err : text }; -type Result_9 = variant { Ok : SettingArchivedPayload; Err : text }; +type Result_6 = variant { Ok : SignedDelegation; Err : text }; +type Result_7 = variant { Ok : vec principal; Err : text }; +type Result_8 = variant { Ok : principal; Err : text }; +type Result_9 = variant { Ok : SignDelegationOutput; Err : text }; type SchnorrAlgorithm = variant { ed25519; bip340secp256k1 }; type SettingArchivedPayload = record { dek : opt blob; @@ -90,12 +107,24 @@ type SettingPath = record { version : nat32; user_owned : bool; }; +type SignDelegationInput = record { + ns : text; + sig : blob; + name : text; + pubkey : blob; +}; +type SignDelegationOutput = record { + user_key : blob; + seed : blob; + expiration : nat64; +}; type SignIdentityInput = record { ns : text; audience : text }; type SignInput = record { ns : text; derivation_path : vec blob; message : blob; }; +type SignedDelegation = record { signature : blob; delegation : Delegation }; type StateInfo = record { freezing_threshold : nat64; ecdsa_key_name : text; @@ -113,6 +142,7 @@ type StateInfo = record { }; type UpdateNamespaceInput = record { status : opt int8; + session_expires_in_ms : opt nat64; desc : opt text; name : text; max_payload_size : opt nat64; @@ -135,7 +165,7 @@ type UpgradeArgs = record { name : opt text; subnet_size : opt nat64; }; -service : (opt ChainArgs) -> { +service : (opt InstallArgs) -> { admin_add_allowed_apis : (vec text) -> (Result); admin_add_auditors : (vec principal) -> (Result); admin_add_managers : (vec principal) -> (Result); @@ -147,14 +177,20 @@ service : (opt ChainArgs) -> { ecdh_cose_encrypted_key : (SettingPath, ECDHInput) -> (Result_3); ecdsa_public_key : (opt PublicKeyInput) -> (Result_4) query; ecdsa_sign : (SignInput) -> (Result_5); + get_delegation : (blob, blob, nat64) -> (Result_6) query; namespace_add_auditors : (text, vec principal) -> (Result); + namespace_add_delegator : (NamespaceDelegatorsInput) -> (Result_7); namespace_add_managers : (text, vec principal) -> (Result); namespace_add_users : (text, vec principal) -> (Result); + namespace_get_delegators : (text, text) -> (Result_7) query; + namespace_get_fixed_identity : (text, text) -> (Result_8) query; namespace_get_info : (text) -> (Result_1) query; namespace_remove_auditors : (text, vec principal) -> (Result); + namespace_remove_delegator : (NamespaceDelegatorsInput) -> (Result); namespace_remove_managers : (text, vec principal) -> (Result); namespace_remove_users : (text, vec principal) -> (Result); - namespace_top_up : (text, nat) -> (Result_6); + namespace_sign_delegation : (SignDelegationInput) -> (Result_9); + namespace_top_up : (text, nat) -> (Result_10); namespace_update_info : (UpdateNamespaceInput) -> (Result); schnorr_public_key : (SchnorrAlgorithm, opt PublicKeyInput) -> ( Result_4, @@ -162,22 +198,22 @@ service : (opt ChainArgs) -> { schnorr_sign : (SchnorrAlgorithm, SignInput) -> (Result_5); schnorr_sign_identity : (SchnorrAlgorithm, SignIdentityInput) -> (Result_5); setting_add_readers : (SettingPath, vec principal) -> (Result); - setting_create : (SettingPath, CreateSettingInput) -> (Result_7); - setting_get : (SettingPath) -> (Result_8) query; - setting_get_archived_payload : (SettingPath) -> (Result_9) query; - setting_get_info : (SettingPath) -> (Result_8) query; + setting_create : (SettingPath, CreateSettingInput) -> (Result_11); + setting_get : (SettingPath) -> (Result_12) query; + setting_get_archived_payload : (SettingPath) -> (Result_13) query; + setting_get_info : (SettingPath) -> (Result_12) query; setting_remove_readers : (SettingPath, vec principal) -> (Result); - setting_update_info : (SettingPath, UpdateSettingInfoInput) -> (Result_7); + setting_update_info : (SettingPath, UpdateSettingInfoInput) -> (Result_11); setting_update_payload : (SettingPath, UpdateSettingPayloadInput) -> ( - Result_7, + Result_11, ); - state_get_info : () -> (Result_10) query; - validate2_admin_add_allowed_apis : (vec text) -> (Result_11); - validate2_admin_add_auditors : (vec principal) -> (Result_11); - validate2_admin_add_managers : (vec principal) -> (Result_11); - validate2_admin_remove_allowed_apis : (vec text) -> (Result_11); - validate2_admin_remove_auditors : (vec principal) -> (Result_11); - validate2_admin_remove_managers : (vec principal) -> (Result_11); + state_get_info : () -> (Result_14) query; + validate2_admin_add_allowed_apis : (vec text) -> (Result_15); + validate2_admin_add_auditors : (vec principal) -> (Result_15); + validate2_admin_add_managers : (vec principal) -> (Result_15); + validate2_admin_remove_allowed_apis : (vec text) -> (Result_15); + validate2_admin_remove_auditors : (vec principal) -> (Result_15); + validate2_admin_remove_managers : (vec principal) -> (Result_15); validate_admin_add_allowed_apis : (vec text) -> (Result); validate_admin_add_auditors : (vec principal) -> (Result); validate_admin_add_managers : (vec principal) -> (Result); diff --git a/src/ic_cose_canister/src/api_identity.rs b/src/ic_cose_canister/src/api_identity.rs new file mode 100644 index 0000000..5d57447 --- /dev/null +++ b/src/ic_cose_canister/src/api_identity.rs @@ -0,0 +1,142 @@ +use candid::Principal; +use ciborium::into_writer; +use ic_canister_sig_creation::{delegation_signature_msg, CanisterSigPublicKey}; +use ic_cose_types::{ + types::{ + namespace::NamespaceDelegatorsInput, Delegation, SignDelegationInput, SignDelegationOutput, + SignedDelegation, + }, + MILLISECONDS, +}; +use ic_crypto_standalone_sig_verifier::{ + user_public_key_from_bytes, verify_basic_sig_by_public_key, +}; +use serde_bytes::ByteBuf; +use std::collections::BTreeSet; + +use crate::store; + +#[ic_cdk::query] +fn namespace_get_fixed_identity(namespace: String, name: String) -> Result { + let mut seed = vec![]; + into_writer(&(&namespace, &name), &mut seed).expect("failed to encode seed"); + let user_key = CanisterSigPublicKey::new(ic_cdk::id(), seed); + Ok(Principal::self_authenticating(user_key.to_der().as_slice())) +} + +#[ic_cdk::query] +fn namespace_get_delegators( + namespace: String, + name: String, +) -> Result, String> { + let caller = ic_cdk::caller(); + store::ns::with(&namespace, |ns| { + if !ns.can_read_namespace(&caller) { + return Err("no permission".to_string()); + } + + ns.fixed_id_names.get(&name).map_or_else( + || Err("name not found".to_string()), + |delegators| Ok(delegators.clone()), + ) + }) +} + +#[ic_cdk::update] +fn namespace_add_delegator( + mut input: NamespaceDelegatorsInput, +) -> Result, String> { + store::state::allowed_api("namespace_add_delegator")?; + input.validate()?; + + let caller = ic_cdk::caller(); + store::ns::with_mut(&input.ns, |ns| { + if !ns.can_write_namespace(&caller) { + return Err("no permission".to_string()); + } + let name = input.name.to_ascii_lowercase(); + let delegators = ns.fixed_id_names.entry(name).or_insert_with(BTreeSet::new); + delegators.append(&mut input.delegators); + Ok(delegators.clone()) + }) +} + +#[ic_cdk::update] +fn namespace_remove_delegator(input: NamespaceDelegatorsInput) -> Result<(), String> { + store::state::allowed_api("namespace_remove_delegator")?; + input.validate()?; + + let caller = ic_cdk::caller(); + store::ns::with_mut(&input.ns, |ns| { + if !ns.can_write_namespace(&caller) { + return Err("no permission".to_string()); + } + let name = input.name.to_ascii_lowercase(); + if let Some(delegators) = ns.fixed_id_names.get_mut(&name) { + delegators.retain(|v| !input.delegators.contains(v)); + if delegators.is_empty() { + ns.fixed_id_names.remove(&name); + } + } + Ok(()) + }) +} + +#[ic_cdk::update] +fn namespace_sign_delegation(input: SignDelegationInput) -> Result { + store::state::allowed_api("namespace_sign_delegation")?; + let caller = ic_cdk::caller(); + let now_ms = ic_cdk::api::time() / MILLISECONDS; + let name = input.name.to_ascii_lowercase(); + + let (pk, _) = user_public_key_from_bytes(input.pubkey.as_slice()) + .map_err(|err| format!("invalid public key: {:?}", err))?; + let mut msg = vec![]; + into_writer(&(&input.ns, &name, &caller), &mut msg).expect("failed to encode Delegations data"); + verify_basic_sig_by_public_key(pk.algorithm_id, &msg, input.sig.as_slice(), &pk.key) + .map_err(|err| format!("challenge verification failed: {:?}", err))?; + + let mut seed = vec![]; + into_writer(&(&input.ns, &name), &mut seed).expect("failed to encode seed"); + let user_key = CanisterSigPublicKey::new(ic_cdk::id(), seed); + let session_expires_in_ms = store::ns::with(&input.ns, |ns| { + if let Some(delegators) = ns.fixed_id_names.get(&name) { + if delegators.contains(&caller) { + return Ok(ns.session_expires_in_ms); + } + return Err("caller is not a delegator".to_string()); + } + Err("name not found".to_string()) + })?; + if session_expires_in_ms == 0 { + return Err("delegation is disabled".to_string()); + } + let expiration = (now_ms + session_expires_in_ms) * MILLISECONDS; + let delegation_hash = delegation_signature_msg(input.pubkey.as_slice(), expiration, None); + store::state::add_signature(user_key.seed.as_slice(), delegation_hash.as_slice()); + + Ok(SignDelegationOutput { + expiration, + user_key: user_key.to_der().into(), + seed: user_key.seed.into(), + }) +} + +#[ic_cdk::query] +fn get_delegation( + seed: ByteBuf, + pubkey: ByteBuf, + expiration: u64, +) -> Result { + let delegation_hash = delegation_signature_msg(pubkey.as_slice(), expiration, None); + let signature = store::state::get_signature(seed.as_slice(), delegation_hash.as_slice())?; + + Ok(SignedDelegation { + delegation: Delegation { + pubkey, + expiration, + targets: None, + }, + signature: ByteBuf::from(signature), + }) +} diff --git a/src/ic_cose_canister/src/api_init.rs b/src/ic_cose_canister/src/api_init.rs index 3686c21..4c1e703 100644 --- a/src/ic_cose_canister/src/api_init.rs +++ b/src/ic_cose_canister/src/api_init.rs @@ -5,7 +5,7 @@ use std::{collections::BTreeSet, time::Duration}; use crate::store; #[derive(Clone, Debug, CandidType, Deserialize)] -pub enum ChainArgs { +pub enum InstallArgs { Init(InitArgs), Upgrade(UpgradeArgs), } @@ -32,9 +32,9 @@ pub struct UpgradeArgs { } #[ic_cdk::init] -fn init(args: Option) { +fn init(args: Option) { match args.expect("init args is missing") { - ChainArgs::Init(args) => { + InstallArgs::Init(args) => { store::state::with_mut(|s| { s.name = args.name; s.ecdsa_key_name = args.ecdsa_key_name; @@ -50,7 +50,7 @@ fn init(args: Option) { s.governance_canister = args.governance_canister; }); } - ChainArgs::Upgrade(_) => { + InstallArgs::Upgrade(_) => { ic_cdk::trap( "cannot initialize the canister with an Upgrade args. Please provide an Init args.", ); @@ -68,11 +68,11 @@ fn pre_upgrade() { } #[ic_cdk::post_upgrade] -fn post_upgrade(args: Option) { +fn post_upgrade(args: Option) { store::state::load(); match args { - Some(ChainArgs::Upgrade(args)) => { + Some(InstallArgs::Upgrade(args)) => { store::state::with_mut(|s| { if let Some(name) = args.name { s.name = name; @@ -88,7 +88,7 @@ fn post_upgrade(args: Option) { } }); } - Some(ChainArgs::Init(_)) => { + Some(InstallArgs::Init(_)) => { ic_cdk::trap( "cannot upgrade the canister with an Init args. Please provide an Upgrade args.", ); diff --git a/src/ic_cose_canister/src/lib.rs b/src/ic_cose_canister/src/lib.rs index 69e1d4a..f125990 100644 --- a/src/ic_cose_canister/src/lib.rs +++ b/src/ic_cose_canister/src/lib.rs @@ -8,6 +8,7 @@ use std::collections::BTreeSet; mod api_admin; mod api_cose; +mod api_identity; mod api_init; mod api_namespace; mod api_setting; @@ -16,7 +17,7 @@ mod schnorr; mod store; mod vetkd; -use api_init::ChainArgs; +use api_init::InstallArgs; fn is_controller() -> Result<(), String> { let caller = ic_cdk::caller(); diff --git a/src/ic_cose_canister/src/store.rs b/src/ic_cose_canister/src/store.rs index 28b32d7..abf11b2 100644 --- a/src/ic_cose_canister/src/store.rs +++ b/src/ic_cose_canister/src/store.rs @@ -1,5 +1,11 @@ use candid::Principal; use ciborium::{from_reader, from_reader_with_buffer, into_writer}; +use ic_canister_sig_creation::{ + signature_map::{CanisterSigInputs, SignatureMap, LABEL_SIG}, + DELEGATION_SIG_DOMAIN, +}; +use ic_cdk::api::set_certified_data; +use ic_certification::labeled_hash; use ic_cose_types::{ cose::{ cwt::{ClaimsSet, Timestamp, SCOPE_NAME}, @@ -32,6 +38,8 @@ use crate::{ vetkd::{vetkd_encrypted_key, vetkd_public_key}, }; +const SESSION_EXPIRES_IN_MS: u64 = 1000 * 3600 * 24; // 1 day + type Memory = VirtualMemory; #[derive(Clone, Default, Deserialize, Serialize)] @@ -127,6 +135,10 @@ pub struct Namespace { pub user_settings: BTreeMap<(Principal, ByteBuf), Setting>, // settings created by users #[serde(rename = "g")] pub gas_balance: u128, // gas balance, TODO: https://internetcomputer.org/docs/current/developer-docs/gas-cost + #[serde(default, rename = "f")] + pub fixed_id_names: BTreeMap>, // fixed_id_name -> users + #[serde(default, rename = "se")] + pub session_expires_in_ms: u64, // session expires in milliseconds } impl Namespace { @@ -146,6 +158,8 @@ impl Namespace { settings_total: self.settings.len() as u64, user_settings_total: self.user_settings.len() as u64, gas_balance: self.gas_balance, + fixed_id_names: self.fixed_id_names.clone(), + session_expires_in_ms: self.session_expires_in_ms, } } @@ -389,6 +403,7 @@ const NS_MEMORY_ID: MemoryId = MemoryId::new(1); const PAYLOADS_MEMORY_ID: MemoryId = MemoryId::new(2); thread_local! { + static SIGNATURES : RefCell = RefCell::new(SignatureMap::default()); static STATE: RefCell = RefCell::new(State::default()); static NS: RefCell> = const { RefCell::new(BTreeMap::new()) }; @@ -447,6 +462,31 @@ pub mod state { } } + pub fn add_signature(seed: &[u8], message: &[u8]) { + SIGNATURES.with_borrow_mut(|sigs| { + let sig_inputs = CanisterSigInputs { + domain: DELEGATION_SIG_DOMAIN, + seed, + message, + }; + sigs.add_signature(&sig_inputs); + + set_certified_data(&labeled_hash(LABEL_SIG, &sigs.root_hash())); + }); + } + + pub fn get_signature(seed: &[u8], message: &[u8]) -> Result, String> { + SIGNATURES.with_borrow(|sigs| { + let sig_inputs = CanisterSigInputs { + domain: DELEGATION_SIG_DOMAIN, + seed, + message, + }; + sigs.get_signature_as_cbor(&sig_inputs, None) + .map_err(|err| format!("failed to get signature: {:?}", err)) + }) + } + pub async fn init_public_key() { let (ecdsa_key_name, schnorr_key_name) = with(|r| (r.ecdsa_key_name.clone(), r.schnorr_key_name.clone())); @@ -820,6 +860,7 @@ pub mod ns { managers: input.managers, auditors: input.auditors, users: input.users, + session_expires_in_ms: input.session_expires_in_ms.unwrap_or(SESSION_EXPIRES_IN_MS), ..Default::default() }; @@ -851,6 +892,9 @@ pub mod ns { if let Some(visibility) = input.visibility { ns.visibility = visibility; } + if let Some(session_expires_in_ms) = input.session_expires_in_ms { + ns.session_expires_in_ms = session_expires_in_ms; + } ns.updated_at = now_ms; Ok(()) }) diff --git a/src/ic_cose_types/src/lib.rs b/src/ic_cose_types/src/lib.rs index 628633c..36d09ce 100644 --- a/src/ic_cose_types/src/lib.rs +++ b/src/ic_cose_types/src/lib.rs @@ -21,7 +21,7 @@ pub fn to_cbor_bytes(obj: &impl Serialize) -> Vec { buf } -/// Validates the key of Namespace and Setting +/// Validates namespace /// /// # Arguments /// * `s` - A string slice that holds the name to be validated. diff --git a/src/ic_cose_types/src/types/mod.rs b/src/ic_cose_types/src/types/mod.rs index 0500036..6dce131 100644 --- a/src/ic_cose_types/src/types/mod.rs +++ b/src/ic_cose_types/src/types/mod.rs @@ -1,4 +1,4 @@ -use candid::CandidType; +use candid::{CandidType, Principal}; use serde::{Deserialize, Serialize}; use serde_bytes::{ByteArray, ByteBuf}; use std::collections::BTreeMap; @@ -49,3 +49,35 @@ pub struct ECDHOutput { pub payload: T, // should be random for each request pub public_key: ByteArray<32>, // server side ECDH public key } + +#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +pub struct Delegation { + pub pubkey: ByteBuf, + pub expiration: u64, + pub targets: Option>, +} + +#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +pub struct SignedDelegation { + pub delegation: Delegation, + pub signature: ByteBuf, +} + +#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +pub struct SignDelegationInput { + pub ns: String, + pub name: String, + pub pubkey: ByteBuf, + pub sig: ByteBuf, +} + +#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +pub struct SignDelegationOutput { + /// The session expiration time in nanoseconds since the UNIX epoch. This is the time at which + /// the delegation will no longer be valid. + pub expiration: u64, + /// The user canister public key. This key is used to derive the user principal. + pub user_key: ByteBuf, + /// seed is a part of the user_key + pub seed: ByteBuf, +} diff --git a/src/ic_cose_types/src/types/namespace.rs b/src/ic_cose_types/src/types/namespace.rs index 20dbf11..cad72f8 100644 --- a/src/ic_cose_types/src/types/namespace.rs +++ b/src/ic_cose_types/src/types/namespace.rs @@ -1,6 +1,6 @@ use candid::{CandidType, Principal}; use serde::{Deserialize, Serialize}; -use std::collections::BTreeSet; +use std::collections::{BTreeMap, BTreeSet}; use crate::{validate_key, validate_principals}; @@ -22,6 +22,8 @@ pub struct NamespaceInfo { pub settings_total: u64, // settings created by managers for users pub user_settings_total: u64, // settings created by users pub gas_balance: u128, // cycles + pub fixed_id_names: BTreeMap>, // fixed identity names + pub session_expires_in_ms: u64, // session expiration in milliseconds for fixed identity } #[derive(CandidType, Clone, Debug, Default, Deserialize, Serialize)] @@ -33,6 +35,7 @@ pub struct CreateNamespaceInput { pub managers: BTreeSet, // managers can read and write all settings pub auditors: BTreeSet, // auditors can read all settings pub users: BTreeSet, // users can read and write settings they created + pub session_expires_in_ms: Option, // session expiration in milliseconds for fixed identity, default to 1 day } impl CreateNamespaceInput { @@ -65,6 +68,7 @@ pub struct UpdateNamespaceInput { pub max_payload_size: Option, pub status: Option, pub visibility: Option, // 0: private; 1: public + pub session_expires_in_ms: Option, } impl UpdateNamespaceInput { @@ -95,3 +99,18 @@ impl UpdateNamespaceInput { Ok(()) } } + +#[derive(CandidType, Clone, Debug, Deserialize, Serialize)] +pub struct NamespaceDelegatorsInput { + pub ns: String, + pub name: String, + pub delegators: BTreeSet, +} + +impl NamespaceDelegatorsInput { + pub fn validate(&self) -> Result<(), String> { + validate_key(&self.name)?; + validate_principals(&self.delegators)?; + Ok(()) + } +}