From 1adf9c4555106eaffc01d3ca6b15d6d8f6089bea Mon Sep 17 00:00:00 2001 From: NathanosDev Date: Thu, 20 Jul 2023 14:52:19 +0200 Subject: [PATCH 1/2] feat: add test utils wasm package add unit test for certificate verification JS library re #TT-296 --- .github/actions/setup-dfx/action.yml | 6 +- .github/workflows/pull-request.yml | 3 + Cargo.toml | 3 +- README.md | 2 + .../src/frontend/src/index.ts | 14 +- package.json | 3 +- .../certificate-verification-js/README.md | 14 +- .../certificate-verification-js/package.json | 3 + .../src/index.spec.ts | 49 + .../certificate-verification-js/src/index.ts | 22 +- .../Cargo.lock | 2298 +++++++++++++++++ .../Cargo.toml | 37 + .../ic-certification-test-utils-wasm/LICENSE | 202 ++ .../README.md | 1 + .../package.json | 25 + .../src/certificate.rs | 36 + .../src/certificate_builder.rs | 195 ++ .../src/encoding.rs | 18 + .../src/error.rs | 55 + .../src/lib.rs | 7 + .../src/signature.rs | 69 + .../src/tree.rs | 37 + pnpm-lock.yaml | 221 +- pnpm-workspace.yaml | 1 + rust-toolchain.toml | 4 + scripts/package.sh | 26 +- 26 files changed, 3220 insertions(+), 131 deletions(-) create mode 100644 packages/certificate-verification-js/src/index.spec.ts create mode 100644 packages/ic-certification-test-utils-wasm/Cargo.lock create mode 100644 packages/ic-certification-test-utils-wasm/Cargo.toml create mode 100644 packages/ic-certification-test-utils-wasm/LICENSE create mode 100644 packages/ic-certification-test-utils-wasm/README.md create mode 100644 packages/ic-certification-test-utils-wasm/package.json create mode 100644 packages/ic-certification-test-utils-wasm/src/certificate.rs create mode 100644 packages/ic-certification-test-utils-wasm/src/certificate_builder.rs create mode 100644 packages/ic-certification-test-utils-wasm/src/encoding.rs create mode 100644 packages/ic-certification-test-utils-wasm/src/error.rs create mode 100644 packages/ic-certification-test-utils-wasm/src/lib.rs create mode 100644 packages/ic-certification-test-utils-wasm/src/signature.rs create mode 100644 packages/ic-certification-test-utils-wasm/src/tree.rs create mode 100644 rust-toolchain.toml diff --git a/.github/actions/setup-dfx/action.yml b/.github/actions/setup-dfx/action.yml index 09ee6d94..7bc06749 100644 --- a/.github/actions/setup-dfx/action.yml +++ b/.github/actions/setup-dfx/action.yml @@ -4,10 +4,6 @@ description: Setup DFX runs: using: 'composite' steps: - - name: Get DFX version - shell: bash - run: echo "dfx_version=$(cat dfx.json | jq -r .dfx)" >> "$GITHUB_ENV" - - name: Cache DFX uses: actions/cache@v3 with: @@ -22,7 +18,7 @@ runs: echo "DFX restored from cache" else echo "DFX not restored from cache, running install script:" - DFX_VERSION=${{ env.dfx_version }} sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" + DFX_VERSION=0.14.2 sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" fi echo "DFX version" dfx --version diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 3735a01c..e7067dd1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -48,6 +48,9 @@ jobs: - name: Build NPM packages run: pnpm build + - name: Test NPM packages + run: pnpm test + - name: Test Cargo crates run: cargo test diff --git a/Cargo.toml b/Cargo.toml index 726575fe..56e4e7b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,8 @@ members = [ # these projects need wasm32-unknown-unknown as their target exclude = [ "examples/certified-counter/src/backend", - "packages/ic-response-verification-wasm" + "packages/ic-response-verification-wasm", + "packages/ic-certification-test-utils-wasm", ] [profile.release] diff --git a/README.md b/README.md index 2a705dee..38541272 100644 --- a/README.md +++ b/README.md @@ -57,5 +57,7 @@ See [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) for m | Project | Command | Description | | ----------------------------------- | ----------------------------------------------------------- | ------------------------------------------ | | All | `pnpm build` | Build all NPM projects | +| `@dfinity/certificate-verification` | `pnpm run --filter @dfinity/certificate-verification build` | Build certificate verification | +| `@dfinity/certificate-verification` | `pnpm run --filter @dfinity/certificate-verification test` | Test certificate verification | | `@dfinity/certification-test-utils` | `pnpm run --filter @dfinity/certification-test-utils build` | Build certification test utils | | `@dfinity/response-verification` | `pnpm run --filter @dfinity/response-verification build` | Build the response verification JS library | diff --git a/examples/certified-counter/src/frontend/src/index.ts b/examples/certified-counter/src/frontend/src/index.ts index e1d4b11f..a12605bc 100644 --- a/examples/certified-counter/src/frontend/src/index.ts +++ b/examples/certified-counter/src/frontend/src/index.ts @@ -33,13 +33,13 @@ buttonElement.addEventListener('click', async event => { const agent = new HttpAgent(); await agent.fetchRootKey(); - const tree = await verifyCertification( - Principal.fromText(canisterId), - new Uint8Array(certificate).buffer, - new Uint8Array(witness).buffer, - agent.rootKey, - 50000, - ); + const tree = await verifyCertification({ + canisterId: Principal.fromText(canisterId), + encodedCertificate: new Uint8Array(certificate).buffer, + encodedTree: new Uint8Array(witness).buffer, + rootKey: agent.rootKey, + maxCertificateTimeOffsetMs: 50000, + }); const treeHash = lookup_path(['count'], tree); if (!treeHash) { diff --git a/package.json b/package.json index bbee6e1e..a8b5a27d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "scripts": { "build": "pnpm run -r build", "format": "prettier --write .", - "format:check": "prettier --check ." + "format:check": "prettier --check .", + "test": "pnpm run -r test" }, "engines": { "node": "^18", diff --git a/packages/certificate-verification-js/README.md b/packages/certificate-verification-js/README.md index 5100b313..69f51a1e 100644 --- a/packages/certificate-verification-js/README.md +++ b/packages/certificate-verification-js/README.md @@ -33,13 +33,13 @@ Check [ic-certified-map](https://github.com/dfinity/cdk-rs/tree/main/library/ic- ```javascript const { data, certificate, witness } = await canister.get_data(); -const tree = await verifyCertification( - Principal.fromText(canisterId), - new Uint8Array(certificate).buffer, - new Uint8Array(witness).buffer, - agent.rootKey, - 50000, -); +const tree = await verifyCertification({ + canisterId: Principal.fromText(canisterId), + encodedCertificate: new Uint8Array(certificate).buffer, + encodedTree: new Uint8Array(witness).buffer, + rootKey: agent.rootKey, + maxCertificateTimeOffsetMs: 50000, +}); const treeDataHash = lookup_path(['count'], tree); const responseDataHash = calculateDataHash(data); diff --git a/packages/certificate-verification-js/package.json b/packages/certificate-verification-js/package.json index c520ba8f..7805e5b4 100644 --- a/packages/certificate-verification-js/package.json +++ b/packages/certificate-verification-js/package.json @@ -30,5 +30,8 @@ "@dfinity/agent": "~0.15.7", "@dfinity/candid": "~0.15.7", "@dfinity/principal": "~0.15.7" + }, + "devDependencies": { + "@dfinity/certification-test-utils": "workspace:*" } } diff --git a/packages/certificate-verification-js/src/index.spec.ts b/packages/certificate-verification-js/src/index.spec.ts new file mode 100644 index 00000000..7a4ef767 --- /dev/null +++ b/packages/certificate-verification-js/src/index.spec.ts @@ -0,0 +1,49 @@ +import { describe, expect, it } from 'vitest'; +import { HashTree, reconstruct, Cbor } from '@dfinity/agent'; +import { CertificateBuilder } from '@dfinity/certification-test-utils'; +import { Principal } from '@dfinity/principal'; +import { createHash, webcrypto } from 'node:crypto'; +import { verifyCertification } from './index'; + +globalThis.crypto = webcrypto as Crypto; + +describe('verifyCertification', () => { + it('should verify a valid certificate with delegation', async () => { + const userId = '1234'; + + const username = 'testuser'; + const usernameHash = new Uint8Array( + createHash('sha256').update(username).digest(), + ); + + const hashTree: HashTree = [ + 2, + new Uint8Array(Buffer.from(userId)), + [3, usernameHash], + ]; + const rootHash = await reconstruct(hashTree); + const cborEncodedTree = Cbor.encode(hashTree); + + const canisterId = Principal.fromUint8Array( + new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1]), + ); + const time = BigInt(Date.now()); + + const certificate = new CertificateBuilder( + canisterId.toString(), + new Uint8Array(rootHash), + ) + .withTime(time) + .withDelegation(123n, [{ high: 10, low: 0 }]) + .build(); + + const decodedHashTree = await verifyCertification({ + canisterId, + encodedCertificate: certificate.cborEncodedCertificate, + encodedTree: cborEncodedTree, + maxCertificateTimeOffsetMs: 5000, + rootKey: certificate.rootKey, + }); + expect(decodedHashTree).toEqual(hashTree); + }); +}); diff --git a/packages/certificate-verification-js/src/index.ts b/packages/certificate-verification-js/src/index.ts index acebf14a..66bc930a 100644 --- a/packages/certificate-verification-js/src/index.ts +++ b/packages/certificate-verification-js/src/index.ts @@ -9,13 +9,21 @@ import { Principal } from '@dfinity/principal'; import { PipeArrayBuffer, lebDecode } from '@dfinity/candid'; import { CertificateTimeError, CertificateVerificationError } from './error'; -export async function verifyCertification( - canisterId: Principal, - encodedCertificate: ArrayBuffer, - encodedTree: ArrayBuffer, - rootKey: ArrayBuffer, - maxCertificateTimeOffsetMs: number, -): Promise { +export interface CertificationParams { + canisterId: Principal; + encodedCertificate: ArrayBuffer; + encodedTree: ArrayBuffer; + rootKey: ArrayBuffer; + maxCertificateTimeOffsetMs: number; +} + +export async function verifyCertification({ + canisterId, + encodedCertificate, + encodedTree, + rootKey, + maxCertificateTimeOffsetMs, +}: CertificationParams): Promise { const certificate = await Certificate.create({ certificate: encodedCertificate, canisterId, diff --git a/packages/ic-certification-test-utils-wasm/Cargo.lock b/packages/ic-certification-test-utils-wasm/Cargo.lock new file mode 100644 index 00000000..7fee5fcb --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/Cargo.lock @@ -0,0 +1,2298 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +dependencies = [ + "memchr", +] + +[[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.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base32" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ce669cd6c8588f79e15cf450314f9638f967fc5770ff1c7c1deb0925ea7cfa" + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "beef" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16598dfc8e6578e9b597d9910ba2e73618385dc9f4b1d43dd92c349d6be6418f" +dependencies = [ + "binread_derive", + "lazy_static", + "rustversion", +] + +[[package]] +name = "binread_derive" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d9672209df1714ee804b1f4d4f68c8eb2a90b1f7a07acf472f88ce198ef1fed" +dependencies = [ + "either", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" + +[[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.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cached" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec6d20b3d24b6c74e2c5331d2d3d8d1976a9883c7da179aa851afa4c90d62e36" +dependencies = [ + "hashbrown 0.12.3", + "instant", + "once_cell", + "thiserror", +] + +[[package]] +name = "candid" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "244005a1917bb7614cd775ca8a5d59efeb5ac74397bb14ba29a19347ebd78591" +dependencies = [ + "anyhow", + "binread", + "byteorder", + "candid_derive", + "codespan-reporting", + "crc32fast", + "data-encoding", + "hex", + "lalrpop", + "lalrpop-util", + "leb128", + "logos", + "num-bigint", + "num-traits", + "num_enum", + "paste", + "pretty", + "serde", + "serde_bytes", + "sha2 0.10.7", + "thiserror", +] + +[[package]] +name = "candid_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f1f4db7c7d04b87b70b3a35c5dc5c2c9dd73cef8bdf6760e2f18a0d45350dd" +dependencies = [ + "lazy_static", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "time 0.1.45", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[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 = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + +[[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.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "cpufeatures" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03e69e28e9f7f77debdedbaafa2866e1de9ba56df55a8bd7cfc724c25a09987c" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "cvt" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ae9bf77fbf2d39ef573205d554d87e86c12f1994e9ea335b0651b9b278bcf1" +dependencies = [ + "cfg-if", +] + +[[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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" + +[[package]] +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 = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "either" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" + +[[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.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1" + +[[package]] +name = "erased-serde" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f2b0c2380453a92ea8b6c8e5f64ecaafccddde8ceab55ff7a8ac1029f894569" +dependencies = [ + "serde", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "features" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83072b3c84e55f9d0c0ff36a4575d0fd2e543ae4a56e04e7f5a9222188d574e3" +dependencies = [ + "bitflags", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core", + "subtle", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[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 = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff", + "rand_core", + "subtle", +] + +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[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#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "base32", + "byte-unit", + "bytes", + "candid", + "comparable", + "crc32fast", + "ic-crypto-sha", + "ic-protobuf", + "ic-stable-structures", + "phantom_newtype", + "prost", + "serde", + "strum", + "strum_macros", +] + +[[package]] +name = "ic-btc-interface" +version = "0.1.0" +source = "git+https://github.com/dfinity/bitcoin-canister?rev=e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e#e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e" +dependencies = [ + "candid", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-btc-types-internal" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "candid", + "ic-btc-interface", + "ic-protobuf", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-certification-test-utils-wasm" +version = "0.3.0" +dependencies = [ + "console_error_panic_hook", + "getrandom", + "ic-crypto-internal-seed", + "ic-crypto-internal-threshold-sig-bls12381", + "ic-crypto-internal-types", + "ic-crypto-tree-hash", + "ic-types", + "js-sys", + "leb128", + "log", + "rand", + "serde", + "serde-wasm-bindgen", + "serde_cbor", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-console-logger", +] + +[[package]] +name = "ic-constants" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" + +[[package]] +name = "ic-crypto-getrandom-for-wasm" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "getrandom", +] + +[[package]] +name = "ic-crypto-internal-bls12-381-type" +version = "0.1.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "hex", + "ic-crypto-getrandom-for-wasm", + "ic_bls12_381", + "itertools", + "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#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "hex", + "ic-crypto-sha", + "ic-types", + "rand", + "rand_chacha", + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-sha2" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "openssl", + "sha2 0.9.9", +] + +[[package]] +name = "ic-crypto-internal-threshold-sig-bls12381" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "base64", + "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-sha", + "ic-types", + "lazy_static", + "parking_lot", + "rand", + "rand_chacha", + "serde", + "serde_bytes", + "serde_cbor", + "strum_macros", + "subtle", + "zeroize", +] + +[[package]] +name = "ic-crypto-internal-threshold-sig-bls12381-der" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "simple_asn1", +] + +[[package]] +name = "ic-crypto-internal-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "arrayvec", + "base64", + "hex", + "ic-protobuf", + "phantom_newtype", + "serde", + "serde_cbor", + "strum", + "strum_macros", + "thiserror", + "zeroize", +] + +[[package]] +name = "ic-crypto-secrets-containers" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "serde", + "zeroize", +] + +[[package]] +name = "ic-crypto-sha" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "ic-crypto-internal-sha2", +] + +[[package]] +name = "ic-crypto-tree-hash" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "ic-crypto-internal-types", + "ic-crypto-sha", + "ic-protobuf", + "serde", + "serde_bytes", +] + +[[package]] +name = "ic-error-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "serde", + "strum", + "strum_macros", +] + +[[package]] +name = "ic-ic00-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "candid", + "float-cmp", + "ic-base-types", + "ic-btc-interface", + "ic-btc-types-internal", + "ic-error-types", + "ic-protobuf", + "num-traits", + "serde", + "serde_bytes", + "serde_cbor", + "strum", + "strum_macros", +] + +[[package]] +name = "ic-protobuf" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "bincode", + "candid", + "erased-serde", + "maplit", + "prost", + "serde", + "serde_json", + "slog", +] + +[[package]] +name = "ic-stable-structures" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4e026318236de13568edafd85534ad29910908bf08cdcf177d4403fd4a5f6c4" + +[[package]] +name = "ic-sys" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "hex", + "ic-crypto-sha", + "lazy_static", + "libc", + "nix", + "phantom_newtype", + "wsl", +] + +[[package]] +name = "ic-types" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "base32", + "base64", + "bincode", + "candid", + "chrono", + "derive_more", + "hex", + "http", + "ic-base-types", + "ic-btc-types-internal", + "ic-constants", + "ic-crypto-internal-types", + "ic-crypto-sha", + "ic-crypto-tree-hash", + "ic-error-types", + "ic-ic00-types", + "ic-protobuf", + "ic-utils", + "maplit", + "num-traits", + "once_cell", + "phantom_newtype", + "prost", + "serde", + "serde_bytes", + "serde_cbor", + "serde_json", + "serde_with", + "strum", + "strum_macros", + "thiserror", + "thousands", + "url", +] + +[[package]] +name = "ic-utils" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "bitflags", + "cvt", + "features", + "hex", + "ic-sys", + "libc", + "nix", + "prost", + "rand", + "scoped_threadpool", + "serde", + "thiserror", +] + +[[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", + "group", + "pairing", + "rand_core", + "subtle", + "zeroize", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +dependencies = [ + "hermit-abi", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lalrpop" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1cbf952127589f2851ab2046af368fd20645491bb4b376f04b7f94d7a9837b" +dependencies = [ + "ascii-canvas", + "bit-set", + "diff", + "ena", + "is-terminal", + "itertools", + "lalrpop-util", + "petgraph", + "regex", + "regex-syntax 0.6.29", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", +] + +[[package]] +name = "lalrpop-util" +version = "0.19.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3c48237b9604c5a4702de6b824e02006c3214327564636aef27c1028a8fa0ed" +dependencies = [ + "regex", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" + +[[package]] +name = "logos" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1" +dependencies = [ + "logos-derive", +] + +[[package]] +name = "logos-derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c" +dependencies = [ + "beef", + "fnv", + "proc-macro2", + "quote", + "regex-syntax 0.6.29", + "syn 1.0.109", +] + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[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.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_enum" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbff9bc912032c62bf65ef1d5aea88983b420f4f839db1e9b0c281a25c9c799" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "once_cell" +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 = "openssl" +version = "0.10.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.26", +] + +[[package]] +name = "openssl-sys" +version = "0.9.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "output_vt100" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" +dependencies = [ + "winapi", +] + +[[package]] +name = "pairing" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135590d8bdba2b31346f9cd1fb2a912329f5135e832a4f422942eb6ead8b6b3b" +dependencies = [ + "group", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4" +dependencies = [ + "fixedbitset", + "indexmap 1.9.3", +] + +[[package]] +name = "phantom_newtype" +version = "0.8.0" +source = "git+https://github.com/dfinity/ic#323bb2ceda477a6f7d13ab007c47935824b63150" +dependencies = [ + "candid", + "serde", + "slog", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "pretty" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad9940b913ee56ddd94aec2d3cd179dd47068236f42a1a6415ccf9d880ce2a61" +dependencies = [ + "arrayvec", + "typed-arena", +] + +[[package]] +name = "pretty_assertions" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755" +dependencies = [ + "ctor", + "diff", + "output_vt100", + "yansi", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +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", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quote" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall 0.2.16", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.2", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78" + +[[package]] +name = "rustix" +version = "0.37.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96e891d04aa506a6d1f318d2771bcb1c7dfda84e126660ace067c9b474bb2c0" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustversion" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[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.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "serde" +version = "1.0.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8c8cf938e98f769bc164923b06dce91cea1751522f46f8466461af04c9027d" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b4c031cd0d9014307d82b8abf653c0290fbdaeb4c02d00c63cf52f728628bf" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_bytes" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "416bda436f9aab92e02c8e10d49a15ddd339cea90b6e340fe51ed97abb548294" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.164" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9735b638ccc51c28bf6914d90a2e9725b377144fc612c49a611fddd1b631d68" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.26", +] + +[[package]] +name = "serde_json" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46266871c240a00b8f503b877622fe33430b3c7d963bdc0f2adc511e54a1eae3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[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.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.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[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 0.3.22", +] + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + +[[package]] +name = "slog" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" +dependencies = [ + "erased-serde", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared", + "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.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae14b91c7d11c9a851d3fbc80a963198998c2a64eec840477fa92d8ce9b70bb" + +[[package]] +name = "strum_macros" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb0dc7ee9c15cea6199cde9a127fa16a4c5819af85395457ad72d68edc85a38" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "subtle" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.26", +] + +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "time" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea9e1b3cf1243ae005d9e74085d4d542f3125458f3a81af210d901dcd7411efd" +dependencies = [ + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" +dependencies = [ + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" + +[[package]] +name = "toml_edit" +version = "0.19.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266f016b7f039eec8a1a80dfe6156b633d208b9fccca5e4db1d6775b0c4e34a7" +dependencies = [ + "indexmap 2.0.0", + "toml_datetime", + "winnow", +] + +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15811caf2415fb889178633e7724bad2509101cde276048e013b9def5e51fa0" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[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.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[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.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.26", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-console-logger" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7530a275e7faf7b5b83aabdf78244fb8d9a68a2ec4b26935a05ecc0c9b0185ed" +dependencies = [ + "log", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.26", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winnow" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca0ace3845f0d96209f0375e6d367e3eb87eb65d27d445bdc9f1843a26f39448" +dependencies = [ + "memchr", +] + +[[package]] +name = "wsl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dab7ac864710bdea6594becbea5b5050333cf34fefb0dc319567eb347950d4" + +[[package]] +name = "yansi" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" + +[[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.26", +] diff --git a/packages/ic-certification-test-utils-wasm/Cargo.toml b/packages/ic-certification-test-utils-wasm/Cargo.toml new file mode 100644 index 00000000..f534e6e0 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "ic-certification-test-utils-wasm" +description = "Utilities for testing applications that work with Internet Computer certification" +version = "0.3.0" +authors = ["DFINITY Stiftung"] +license = "Apache-2.0" +edition = "2021" +include = ["src", "Cargo.toml", "README.md"] + +[features] +debug = [] + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +leb128 = "0.2.5" +thiserror = "1.0.43" +wasm-bindgen = "0.2.83" +js-sys = "0.3.64" +console_error_panic_hook = "0.1.7" +wasm-bindgen-console-logger = "0.1.1" +log = "0.4.17" +serde = { version = "1.0", features = ["derive"] } +serde-wasm-bindgen = "0.4" +serde_cbor = "0.11.2" + +ic-types = { git = "https://github.com/dfinity/ic" } +ic-crypto-tree-hash = { git = "https://github.com/dfinity/ic" } +ic-crypto-internal-threshold-sig-bls12381 = { git = "https://github.com/dfinity/ic" } +ic-crypto-internal-seed = { git = "https://github.com/dfinity/ic" } +ic-crypto-internal-types = { git = "https://github.com/dfinity/ic" } + +# https://github.com/rust-random/rand#wasm-support +# https://docs.rs/getrandom/latest/getrandom/#webassembly-support +rand = "0.8.5" +getrandom = { version = "0.2.8", features = ["js"] } diff --git a/packages/ic-certification-test-utils-wasm/LICENSE b/packages/ic-certification-test-utils-wasm/LICENSE new file mode 100644 index 00000000..274d16b7 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023 DFINITY Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packages/ic-certification-test-utils-wasm/README.md b/packages/ic-certification-test-utils-wasm/README.md new file mode 100644 index 00000000..d6536462 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/README.md @@ -0,0 +1 @@ +# Certification Test Utils diff --git a/packages/ic-certification-test-utils-wasm/package.json b/packages/ic-certification-test-utils-wasm/package.json new file mode 100644 index 00000000..fd7ab2da --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/package.json @@ -0,0 +1,25 @@ +{ + "name": "@dfinity/certification-test-utils", + "description": "Utilities for testing applications that work with Internet Computer certification", + "version": "0.3.0", + "author": "DFINITY Stiftung", + "license": "Apache-2.0", + "repository": "github:dfinity/response-verification", + "bugs": "https://github.com/dfinity/response-verification/issues", + "keywords": [ + "internet-computer", + "icp", + "dfinity", + "certification", + "test-utils" + ], + "files": [ + "dist" + ], + "main": "./dist/nodejs/nodejs.js", + "browser": "./dist/web/web.js", + "types": "./dist/web/web.d.ts", + "scripts": { + "build": "../../scripts/package.sh . ./dist" + } +} diff --git a/packages/ic-certification-test-utils-wasm/src/certificate.rs b/packages/ic-certification-test-utils-wasm/src/certificate.rs new file mode 100644 index 00000000..cd3ded25 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/certificate.rs @@ -0,0 +1,36 @@ +use crate::{encoding::serialize_to_cbor, error::CertificationTestResult}; +use ic_crypto_tree_hash::{flatmap, Label, LabeledTree}; +use ic_types::{CanisterId, SubnetId}; + +pub(crate) fn create_certificate_tree( + canister_id: &CanisterId, + certified_data: &[u8], + encoded_time: &[u8], +) -> LabeledTree> { + LabeledTree::SubTree(flatmap![ + Label::from("canister") => LabeledTree::SubTree(flatmap![ + Label::from(canister_id.get_ref().to_vec()) => LabeledTree::SubTree(flatmap![ + Label::from("certified_data") => LabeledTree::Leaf(certified_data.to_vec()), + ]) + ]), + Label::from("time") => LabeledTree::Leaf(encoded_time.to_vec())]) +} + +pub(crate) fn create_delegation_tree( + delegatee_public_key: &[u8], + encoded_time: &[u8], + subnet_id: &SubnetId, + canister_ranges: &[(CanisterId, CanisterId)], +) -> CertificationTestResult>> { + let canister_ranges = serialize_to_cbor(&canister_ranges.to_vec()); + + Ok(LabeledTree::SubTree(flatmap![ + Label::from("subnet") => LabeledTree::SubTree(flatmap![ + Label::from(subnet_id.get_ref().to_vec()) => LabeledTree::SubTree(flatmap![ + Label::from("canister_ranges") => LabeledTree::Leaf(canister_ranges), + Label::from("public_key") => LabeledTree::Leaf(delegatee_public_key.to_vec()), + ]) + ]), + Label::from("time") => LabeledTree::Leaf(encoded_time.to_vec()) + ])) +} diff --git a/packages/ic-certification-test-utils-wasm/src/certificate_builder.rs b/packages/ic-certification-test-utils-wasm/src/certificate_builder.rs new file mode 100644 index 00000000..d53237bd --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/certificate_builder.rs @@ -0,0 +1,195 @@ +use crate::{ + certificate::{create_certificate_tree, create_delegation_tree}, + encoding::{leb_encode_timestamp, serialize_to_cbor}, + error::{CertificationTestError, CertificationTestResult}, + signature::{generate_keypair, get_tree_signature, KeyPair}, + tree::get_mixed_hash_tree, +}; +use ic_crypto_tree_hash::{LabeledTree, MixedHashTree}; +use ic_types::{ + messages::{Blob, Certificate, CertificateDelegation}, + CanisterId, PrincipalId, SubnetId, +}; +use serde::{Deserialize, Serialize}; +use std::str::FromStr; +use wasm_bindgen::prelude::*; + +const DEFAULT_CERTIFICATE_TIME: u128 = 1651142233000005031; + +#[wasm_bindgen(inspectable, getter_with_clone)] +#[derive(Debug, Clone)] +pub struct CertificateData { + #[wasm_bindgen] + pub certificate: JsValue, + + #[wasm_bindgen(js_name = rootKey)] + pub root_key: Vec, + + #[wasm_bindgen(js_name = cborEncodedCertificate)] + pub cbor_encoded_certificate: Vec, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct CanisterIdRange { + pub low: u64, + pub high: u64, +} + +#[derive(Debug, Clone)] +struct SubnetData { + subnet_id: SubnetId, + canister_id_ranges: Vec<(CanisterId, CanisterId)>, +} + +#[derive(Debug, Clone)] +struct CanisterData { + canister_id: CanisterId, + certified_data: Vec, +} + +#[wasm_bindgen(inspectable, getter_with_clone)] +#[derive(Debug, Clone)] +pub struct CertificateBuilder { + time: Option, + canister: CanisterData, + subnet: Option, +} + +#[wasm_bindgen] +impl CertificateBuilder { + #[wasm_bindgen(constructor)] + pub fn new( + canister_id: &str, + certified_data: &[u8], + ) -> CertificationTestResult { + console_error_panic_hook::set_once(); + log::set_logger(&wasm_bindgen_console_logger::DEFAULT_LOGGER).unwrap(); + log::set_max_level(log::LevelFilter::Info); + + let canister_id = CanisterId::from_str(canister_id) + .map_err(|_| CertificationTestError::CanisterIdParsingFailed)?; + + Ok(CertificateBuilder { + time: None, + canister: CanisterData { + canister_id, + certified_data: certified_data.to_vec(), + }, + subnet: None, + }) + } + + #[wasm_bindgen(js_name = withDelegation)] + pub fn with_delegation( + mut self, + subnet_id: u64, + canister_id_ranges: Vec, + ) -> CertificationTestResult { + let canister_id_ranges = canister_id_ranges + .into_iter() + .map(|v| serde_wasm_bindgen::from_value::(v)) + .map(|v| v.map(|v| (CanisterId::from_u64(v.low), CanisterId::from_u64(v.high)))) + .collect::>()?; + + let subnet_id = SubnetId::from(PrincipalId::new_subnet_test_id(subnet_id)); + + self.subnet = Some(SubnetData { + subnet_id, + canister_id_ranges, + }); + + Ok(self) + } + + #[wasm_bindgen(js_name = withTime)] + pub fn with_time(mut self, time: u64) -> Self { + self.time = Some(u128::from(time) * 1_000_000); + + self + } + + pub fn build(self) -> CertificationTestResult { + let time = self.time.unwrap_or(DEFAULT_CERTIFICATE_TIME); + let encoded_time = leb_encode_timestamp(time)?; + + let tree = create_certificate_tree( + &self.canister.canister_id, + &self.canister.certified_data, + &encoded_time, + ); + let (keypair, tree, signature) = build_certificate(&tree)?; + let delegation = None; + let delegation_data = self.build_delegation(&keypair, &encoded_time)?; + + if let Some((delegation, keypair)) = delegation_data { + let certificate = Certificate { + tree, + signature, + delegation: Some(delegation), + }; + let certificate_json = serde_wasm_bindgen::to_value(&certificate)?; + let certificate_cbor = serialize_to_cbor(&certificate); + + return Ok(CertificateData { + certificate: certificate_json, + root_key: keypair.public_key, + cbor_encoded_certificate: certificate_cbor, + }); + }; + + let certificate = Certificate { + tree, + signature, + delegation, + }; + let certificate_json = serde_wasm_bindgen::to_value(&certificate)?; + let certificate_cbor = serialize_to_cbor(&certificate); + + return Ok(CertificateData { + certificate: certificate_json, + root_key: keypair.public_key, + cbor_encoded_certificate: certificate_cbor, + }); + } + + fn build_delegation( + self, + delegatee_keypair: &KeyPair, + encoded_time: &[u8], + ) -> CertificationTestResult> { + if let Some(subnet) = self.subnet { + let tree = create_delegation_tree( + &delegatee_keypair.public_key, + encoded_time, + &subnet.subnet_id, + &subnet.canister_id_ranges, + )?; + let (keypair, tree, signature) = build_certificate(&tree)?; + let certificate = Certificate { + tree, + signature, + delegation: None, + }; + + return Ok(Some(( + CertificateDelegation { + certificate: Blob(serialize_to_cbor(&certificate)), + subnet_id: Blob(subnet.subnet_id.get().to_vec()), + }, + keypair, + ))); + } + + Ok(None) + } +} + +fn build_certificate( + tree: &LabeledTree>, +) -> CertificationTestResult<(KeyPair, MixedHashTree, Blob)> { + let keypair = generate_keypair()?; + let tree = get_mixed_hash_tree(&tree)?; + let signature = get_tree_signature(&tree, &keypair.private_key)?; + + Ok((keypair, tree, signature)) +} diff --git a/packages/ic-certification-test-utils-wasm/src/encoding.rs b/packages/ic-certification-test-utils-wasm/src/encoding.rs new file mode 100644 index 00000000..726f4e6f --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/encoding.rs @@ -0,0 +1,18 @@ +use crate::error::{CertificationTestError, CertificationTestResult}; +use serde::Serialize; + +pub(crate) fn serialize_to_cbor(payload: &T) -> Vec { + let mut serializer = serde_cbor::Serializer::new(Vec::new()); + serializer.self_describe().unwrap(); + payload.serialize(&mut serializer).unwrap(); + serializer.into_inner() +} + +pub(crate) fn leb_encode_timestamp(timestamp: u128) -> CertificationTestResult> { + let mut encoded_time = vec![]; + + leb128::write::unsigned(&mut encoded_time, timestamp as u64) + .map_err(|_| CertificationTestError::TimestampLebEncodingFailed)?; + + Ok(encoded_time) +} diff --git a/packages/ic-certification-test-utils-wasm/src/error.rs b/packages/ic-certification-test-utils-wasm/src/error.rs new file mode 100644 index 00000000..9e864131 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/error.rs @@ -0,0 +1,55 @@ +use ic_crypto_internal_threshold_sig_bls12381::api::threshold_sign_error::ClibThresholdSignError; +use ic_crypto_tree_hash::TreeHashError; +use thiserror::Error; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +#[derive(Error, Debug)] +pub enum CertificationTestError { + #[error("could not hash tree")] + UnableToHashTree, + + #[error("could not generate witness")] + WitnessGenerationFailed, + + #[error("could not sign message")] + ThresholdSigningFailed, + + #[error("could not serialize certificate to cbor")] + CertificateSerializationFailed, + + #[error("could not leb encode timestamp")] + TimestampLebEncodingFailed, + + #[error("could not parse canister ID")] + CanisterIdParsingFailed, + + #[error("could not encode public key")] + PublicKeyEncodingFailed +} + +impl From for CertificationTestError { + fn from(_: TreeHashError) -> Self { + CertificationTestError::UnableToHashTree + } +} + +impl From for CertificationTestError { + fn from(_: ClibThresholdSignError) -> Self { + CertificationTestError::ThresholdSigningFailed + } +} + +impl From for CertificationTestError { + fn from(_: serde_wasm_bindgen::Error) -> Self { + CertificationTestError::CertificateSerializationFailed + } +} + +impl Into for CertificationTestError { + fn into(self) -> JsValue { + JsValue::from_str(&format!("{}", self)) + } +} + +pub type CertificationTestResult = Result; diff --git a/packages/ic-certification-test-utils-wasm/src/lib.rs b/packages/ic-certification-test-utils-wasm/src/lib.rs new file mode 100644 index 00000000..dedf163e --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/lib.rs @@ -0,0 +1,7 @@ +pub mod certificate_builder; + +mod certificate; +mod encoding; +mod error; +mod signature; +mod tree; diff --git a/packages/ic-certification-test-utils-wasm/src/signature.rs b/packages/ic-certification-test-utils-wasm/src/signature.rs new file mode 100644 index 00000000..53385128 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/signature.rs @@ -0,0 +1,69 @@ +use crate::error::{CertificationTestError, CertificationTestResult}; +use ic_crypto_internal_seed::Seed; +use ic_crypto_internal_threshold_sig_bls12381::{ + api::{combined_public_key, generate_threshold_key, public_key_to_der, sign_message}, + types::SecretKeyBytes, +}; +use ic_crypto_internal_types::sign::threshold_sig::public_key::{ + bls12_381::PublicKeyBytes, CspThresholdSigPublicKey, +}; +use ic_crypto_tree_hash::MixedHashTree; +use ic_types::{ + consensus::certification::CertificationContent, + crypto::{ + threshold_sig::ThresholdSigPublicKey, CombinedThresholdSig, CombinedThresholdSigOf, + CryptoHash, Signable, + }, + messages::Blob, + CryptoHashOfPartialState, NumberOfNodes, +}; +use rand::{thread_rng, Rng}; + +#[derive(Debug, Clone)] +pub(crate) struct KeyPair { + pub(crate) public_key: Vec, + pub(crate) private_key: SecretKeyBytes, +} + +pub(crate) fn generate_keypair() -> CertificationTestResult { + let mut seed: [u8; 32] = [0; 32]; + thread_rng().fill(&mut seed); + + let (public_coefficients, secret_key_bytes) = generate_threshold_key( + Seed::from_bytes(&seed), + NumberOfNodes::new(1), + NumberOfNodes::new(1), + ) + .unwrap(); + + let private_key = secret_key_bytes.get(0).unwrap().clone(); + let public_key = ThresholdSigPublicKey::from(CspThresholdSigPublicKey::from( + combined_public_key(&public_coefficients).unwrap(), + )); + + let public_key = public_key_to_der(PublicKeyBytes(public_key.into_bytes())) + .map_err(|_| CertificationTestError::PublicKeyEncodingFailed)?; + + Ok(KeyPair { + public_key, + private_key, + }) +} + +pub(crate) fn get_tree_signature( + mixed_hash_tree: &MixedHashTree, + private_key: &SecretKeyBytes, +) -> CertificationTestResult { + let root_hash = CryptoHashOfPartialState::from(CryptoHash(mixed_hash_tree.digest().to_vec())); + + let signature = sign_message( + &CertificationContent::new(root_hash) + .as_signed_bytes() + .as_slice(), + private_key, + )?; + let signature: CombinedThresholdSigOf = + CombinedThresholdSigOf::from(CombinedThresholdSig(signature.0.to_vec())); + + Ok(Blob(signature.get().0)) +} diff --git a/packages/ic-certification-test-utils-wasm/src/tree.rs b/packages/ic-certification-test-utils-wasm/src/tree.rs new file mode 100644 index 00000000..07cbc664 --- /dev/null +++ b/packages/ic-certification-test-utils-wasm/src/tree.rs @@ -0,0 +1,37 @@ +use crate::error::{CertificationTestError, CertificationTestResult}; +use ic_crypto_tree_hash::{ + HashTreeBuilder, HashTreeBuilderImpl, LabeledTree, MixedHashTree, WitnessGenerator, +}; + +pub(crate) fn get_mixed_hash_tree( + tree: &LabeledTree>, +) -> CertificationTestResult { + let mut hash_tree_builder = HashTreeBuilderImpl::new(); + hash_full_tree(&mut hash_tree_builder, tree); + + let witness_gen = hash_tree_builder + .witness_generator() + .ok_or(CertificationTestError::WitnessGenerationFailed)?; + + let mixed_hash_tree = witness_gen.mixed_hash_tree(&tree)?; + + Ok(mixed_hash_tree) +} + +fn hash_full_tree(hash_tree_builder: &mut HashTreeBuilderImpl, tree: &LabeledTree>) { + match tree { + LabeledTree::Leaf(bytes) => { + hash_tree_builder.start_leaf(); + hash_tree_builder.write_leaf(&bytes[..]); + hash_tree_builder.finish_leaf(); + } + LabeledTree::SubTree(map) => { + hash_tree_builder.start_subtree(); + for (l, child) in map.iter() { + hash_tree_builder.new_edge(l.clone()); + hash_full_tree(hash_tree_builder, child); + } + hash_tree_builder.finish_subtree(); + } + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c83ebbf4..13dd422a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,22 +1,18 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - importers: .: devDependencies: '@dfinity/agent': specifier: ~0.15.7 - version: 0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.4.2)(typescript@5.1.3) '@dfinity/candid': specifier: ~0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@types/node@20.4.2)(typescript@5.1.3) '@dfinity/principal': specifier: ~0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@types/node@20.4.2)(typescript@5.1.3) prettier: specifier: ^2.8.8 version: 2.8.8 @@ -25,7 +21,7 @@ importers: version: 5.1.3 vite: specifier: ^4.3.9 - version: 4.3.9(@types/node@20.3.1) + version: 4.3.9(@types/node@20.4.2) vite-plugin-checker: specifier: ^0.6.1 version: 0.6.1(typescript@5.1.3)(vite@4.3.9) @@ -41,13 +37,13 @@ importers: devDependencies: '@dfinity/agent': specifier: 0.15.7 - version: 0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.4.2)(typescript@5.1.3) '@dfinity/candid': specifier: 0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@types/node@20.4.2)(typescript@5.1.3) '@dfinity/principal': specifier: 0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@types/node@20.4.2)(typescript@5.1.3) assert: specifier: 2.0.0 version: 2.0.0 @@ -114,7 +110,7 @@ importers: dependencies: '@dfinity/principal': specifier: ~0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@4.8.4) + version: 0.15.7(@types/node@20.4.2)(typescript@4.8.4) '@dfinity/response-verification': specifier: workspace:* version: link:../../packages/ic-response-verification-wasm @@ -130,7 +126,7 @@ importers: version: 9.4.1(typescript@4.8.4)(webpack@5.76.0) ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@20.3.1)(typescript@4.8.4) + version: 10.9.1(@types/node@20.4.2)(typescript@4.8.4) typescript: specifier: ^4.8.4 version: 4.8.4 @@ -148,7 +144,7 @@ importers: dependencies: '@dfinity/principal': specifier: ~0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@4.8.4) + version: 0.15.7(@types/node@20.4.2)(typescript@4.8.4) '@dfinity/response-verification': specifier: workspace:* version: link:../../packages/ic-response-verification-wasm @@ -164,7 +160,7 @@ importers: version: 9.4.1(typescript@4.8.4)(webpack@5.76.0) ts-node: specifier: ^10.9.1 - version: 10.9.1(@types/node@20.3.1)(typescript@4.8.4) + version: 10.9.1(@types/node@20.4.2)(typescript@4.8.4) typescript: specifier: ^4.8.4 version: 4.8.4 @@ -182,13 +178,19 @@ importers: dependencies: '@dfinity/agent': specifier: ~0.15.7 - version: 0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.4.2)(typescript@5.1.3) '@dfinity/candid': specifier: ~0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@types/node@20.4.2)(typescript@5.1.3) '@dfinity/principal': specifier: ~0.15.7 - version: 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + version: 0.15.7(@types/node@20.4.2)(typescript@5.1.3) + devDependencies: + '@dfinity/certification-test-utils': + specifier: workspace:* + version: link:../ic-certification-test-utils-wasm + + packages/ic-certification-test-utils-wasm: {} packages/ic-response-verification-tests: dependencies: @@ -231,7 +233,7 @@ importers: version: 5.76.0(webpack-cli@4.10.0) webpack-cli: specifier: ^4.10.0 - version: 4.10.0(webpack@5.76.0) + version: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.76.0) packages/ic-response-verification-wasm: {} @@ -264,20 +266,20 @@ packages: dependencies: '@jridgewell/trace-mapping': 0.3.9 - /@dfinity/agent@0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.3.1)(typescript@5.1.3): + /@dfinity/agent@0.15.7(@dfinity/candid@0.15.7)(@dfinity/principal@0.15.7)(@types/node@20.4.2)(typescript@5.1.3): resolution: {integrity: sha512-w34yvlUTpPBG8nLOD0t/ao3k2xonOFq4QGvfJ1HiS/nIggdza/3xC3nLBszGrjVYWj1jqu8BLFvQXCAeWin75A==} peerDependencies: '@dfinity/candid': ^0.15.7 '@dfinity/principal': ^0.15.7 dependencies: - '@dfinity/candid': 0.15.7(@types/node@20.3.1)(typescript@5.1.3) - '@dfinity/principal': 0.15.7(@types/node@20.3.1)(typescript@5.1.3) + '@dfinity/candid': 0.15.7(@types/node@20.4.2)(typescript@5.1.3) + '@dfinity/principal': 0.15.7(@types/node@20.4.2)(typescript@5.1.3) base64-arraybuffer: 0.2.0 bignumber.js: 9.1.1 borc: 2.1.2 js-sha256: 0.9.0 simple-cbor: 0.4.1 - ts-node: 10.9.1(@types/node@20.3.1)(typescript@5.1.3) + ts-node: 10.9.1(@types/node@20.4.2)(typescript@5.1.3) transitivePeerDependencies: - '@swc/core' - '@swc/wasm' @@ -298,10 +300,10 @@ packages: simple-cbor: 0.4.1 dev: false - /@dfinity/candid@0.15.7(@types/node@20.3.1)(typescript@5.1.3): + /@dfinity/candid@0.15.7(@types/node@20.4.2)(typescript@5.1.3): resolution: {integrity: sha512-lTcjK/xrSyT7wvUQ2pApG+yklQAwxaofQ04D1IWv0/8gKbY0eUbh8G2w6+CypJ15Hb1CH24ijUj8nWdeX/z3jg==} dependencies: - ts-node: 10.9.1(@types/node@20.3.1)(typescript@5.1.3) + ts-node: 10.9.1(@types/node@20.4.2)(typescript@5.1.3) transitivePeerDependencies: - '@swc/core' - '@swc/wasm' @@ -324,11 +326,23 @@ packages: - typescript dev: false - /@dfinity/principal@0.15.7(@types/node@20.3.1)(typescript@5.1.3): + /@dfinity/principal@0.15.7(@types/node@20.4.2)(typescript@4.8.4): resolution: {integrity: sha512-6/AkYzpGEH6Jw/0+B/EeeQn+5u2GDDvRLt1kQPhIG4txQYFnOy04H3VvyrymmfAj6/CXUgrOrux6OxgYSLYVJg==} dependencies: js-sha256: 0.9.0 - ts-node: 10.9.1(@types/node@20.3.1)(typescript@5.1.3) + ts-node: 10.9.1(@types/node@20.4.2)(typescript@4.8.4) + transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' + - '@types/node' + - typescript + dev: false + + /@dfinity/principal@0.15.7(@types/node@20.4.2)(typescript@5.1.3): + resolution: {integrity: sha512-6/AkYzpGEH6Jw/0+B/EeeQn+5u2GDDvRLt1kQPhIG4txQYFnOy04H3VvyrymmfAj6/CXUgrOrux6OxgYSLYVJg==} + dependencies: + js-sha256: 0.9.0 + ts-node: 10.9.1(@types/node@20.4.2)(typescript@5.1.3) transitivePeerDependencies: - '@swc/core' - '@swc/wasm' @@ -635,13 +649,13 @@ packages: resolution: {integrity: sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g==} dependencies: '@types/connect': 3.4.35 - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/bonjour@3.5.10: resolution: {integrity: sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/chai-subset@1.3.3: @@ -658,13 +672,13 @@ packages: resolution: {integrity: sha512-4x5FkPpLipqwthjPsF7ZRbOv3uoLUFkTA9G9v583qi4pACvq0uTELrB8OLUzPWUI4IJIyvM85vzkV1nyiI2Lig==} dependencies: '@types/express-serve-static-core': 4.17.35 - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/connect@3.4.35: resolution: {integrity: sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/eslint-scope@3.7.4: @@ -688,7 +702,7 @@ packages: /@types/express-serve-static-core@4.17.35: resolution: {integrity: sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 '@types/qs': 6.9.7 '@types/range-parser': 1.2.4 '@types/send': 0.17.1 @@ -714,7 +728,7 @@ packages: /@types/http-proxy@1.17.11: resolution: {integrity: sha512-HC8G7c1WmaF2ekqpnFq626xd3Zz0uvaqFmBJNRZCGEZCXkvSdJoNFn/8Ygbd9fKNQj8UzLdCETaI0UWPAjK7IA==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/isomorphic-fetch@0.0.36: @@ -736,6 +750,9 @@ packages: /@types/node@20.3.1: resolution: {integrity: sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==} + /@types/node@20.4.2: + resolution: {integrity: sha512-Dd0BYtWgnWJKwO1jkmTrzofjK2QXXcai0dmtzvIBhcA+RsG5h8R3xlyta0kGOZRNfL9GuRtb1knmPEhQrePCEw==} + /@types/qs@6.9.7: resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==} dev: true @@ -752,7 +769,7 @@ packages: resolution: {integrity: sha512-Cwo8LE/0rnvX7kIIa3QHCkcuF21c05Ayb0ZfxPiv0W8VRiZiNW/WuRupHKpqqGVGf7SUA44QSOUKaEd9lIrd/Q==} dependencies: '@types/mime': 1.3.2 - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/serve-index@1.9.1: @@ -766,19 +783,19 @@ packages: dependencies: '@types/http-errors': 2.0.1 '@types/mime': 3.0.1 - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/sockjs@0.3.33: resolution: {integrity: sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@types/ws@8.5.5: resolution: {integrity: sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 dev: true /@vitest/expect@0.32.2: @@ -945,18 +962,6 @@ packages: webpack-cli: 4.10.0(webpack-dev-server@4.11.1)(webpack@5.76.0) dev: true - /@webpack-cli/serve@1.7.0(webpack-cli@4.10.0): - resolution: {integrity: sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==} - peerDependencies: - webpack-cli: 4.x.x - webpack-dev-server: '*' - peerDependenciesMeta: - webpack-dev-server: - optional: true - dependencies: - webpack-cli: 4.10.0(webpack@5.76.0) - dev: true - /@webpack-cli/serve@1.7.0(webpack-cli@4.10.0)(webpack-dev-server@4.11.1): resolution: {integrity: sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==} peerDependencies: @@ -2422,7 +2427,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -3561,6 +3566,67 @@ packages: typescript: 5.1.3 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + dev: true + + /ts-node@10.9.1(@types/node@20.4.2)(typescript@4.8.4): + resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.3 + '@types/node': 20.4.2 + acorn: 8.9.0 + acorn-walk: 8.2.0 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 4.8.4 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + + /ts-node@10.9.1(@types/node@20.4.2)(typescript@5.1.3): + resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.3 + '@types/node': 20.4.2 + acorn: 8.9.0 + acorn-walk: 8.2.0 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.1.3 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 /tslib@2.5.3: resolution: {integrity: sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w==} @@ -3672,7 +3738,7 @@ packages: engines: {node: '>= 0.8'} dev: true - /vite-node@0.32.2(@types/node@20.3.1): + /vite-node@0.32.2(@types/node@20.4.2): resolution: {integrity: sha512-dTQ1DCLwl2aEseov7cfQ+kDMNJpM1ebpyMMMwWzBvLbis8Nla/6c9WQcqpPssTwS6Rp/+U6KwlIj8Eapw4bLdA==} engines: {node: '>=v14.18.0'} hasBin: true @@ -3682,7 +3748,7 @@ packages: mlly: 1.4.0 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.3.9(@types/node@20.3.1) + vite: 4.3.9(@types/node@20.4.2) transitivePeerDependencies: - '@types/node' - less @@ -3738,14 +3804,14 @@ packages: strip-ansi: 6.0.1 tiny-invariant: 1.3.1 typescript: 5.1.3 - vite: 4.3.9(@types/node@20.3.1) + vite: 4.3.9(@types/node@20.4.2) vscode-languageclient: 7.0.0 vscode-languageserver: 7.0.0 vscode-languageserver-textdocument: 1.0.8 vscode-uri: 3.0.7 dev: true - /vite@4.3.9(@types/node@20.3.1): + /vite@4.3.9(@types/node@20.4.2): resolution: {integrity: sha512-qsTNZjO9NoJNW7KnOrgYwczm0WctJ8m/yqYAMAK9Lxt4SoySUfS5S8ia9K7JHpa3KEeMfyF8LoJ3c5NeBJy6pg==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -3770,7 +3836,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.3.1 + '@types/node': 20.4.2 esbuild: 0.17.19 postcss: 8.4.24 rollup: 3.25.3 @@ -3811,7 +3877,7 @@ packages: dependencies: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 - '@types/node': 20.3.1 + '@types/node': 20.4.2 '@vitest/expect': 0.32.2 '@vitest/runner': 0.32.2 '@vitest/snapshot': 0.32.2 @@ -3831,8 +3897,8 @@ packages: strip-literal: 1.0.1 tinybench: 2.5.0 tinypool: 0.5.0 - vite: 4.3.9(@types/node@20.3.1) - vite-node: 0.32.2(@types/node@20.3.1) + vite: 4.3.9(@types/node@20.4.2) + vite-node: 0.32.2(@types/node@20.4.2) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -3937,41 +4003,6 @@ packages: webpack-merge: 5.9.0 dev: true - /webpack-cli@4.10.0(webpack@5.76.0): - resolution: {integrity: sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==} - engines: {node: '>=10.13.0'} - hasBin: true - peerDependencies: - '@webpack-cli/generators': '*' - '@webpack-cli/migrate': '*' - webpack: 4.x.x || 5.x.x - webpack-bundle-analyzer: '*' - webpack-dev-server: '*' - peerDependenciesMeta: - '@webpack-cli/generators': - optional: true - '@webpack-cli/migrate': - optional: true - webpack-bundle-analyzer: - optional: true - webpack-dev-server: - optional: true - dependencies: - '@discoveryjs/json-ext': 0.5.7 - '@webpack-cli/configtest': 1.2.0(webpack-cli@4.10.0)(webpack@5.76.0) - '@webpack-cli/info': 1.5.0(webpack-cli@4.10.0) - '@webpack-cli/serve': 1.7.0(webpack-cli@4.10.0) - colorette: 2.0.20 - commander: 7.2.0 - cross-spawn: 7.0.3 - fastest-levenshtein: 1.0.16 - import-local: 3.1.0 - interpret: 2.2.0 - rechoir: 0.7.1 - webpack: 5.76.0(webpack-cli@4.10.0) - webpack-merge: 5.9.0 - dev: true - /webpack-dev-middleware@5.3.3(webpack@5.76.0): resolution: {integrity: sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==} engines: {node: '>= 12.13.0'} @@ -4188,3 +4219,7 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} dev: true + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c76dc7d5..e95665e0 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,6 @@ packages: - 'packages/certificate-verification-js' + - 'packages/ic-certification-test-utils-wasm' - 'packages/ic-response-verification-wasm' - 'packages/ic-response-verification-tests' - 'packages/ic-response-verification-tests/dfx-project' diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 00000000..6fa09152 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.70.0" +components = ["rustfmt", "clippy"] +targets = ["wasm32-unknown-unknown"] diff --git a/scripts/package.sh b/scripts/package.sh index dd8afb70..7c5e97fd 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -1,26 +1,32 @@ PKG_ROOT=$1 OUT_DIR=$2 +early_exit() { + echo "Performing early exit..." + + exit 1 +} + build_release_packages() { - wasm-pack build --target web --out-name web --out-dir $OUT_DIR/web --release $PKG_ROOT - wasm-pack build --target nodejs --out-name nodejs --out-dir $OUT_DIR/nodejs --release $PKG_ROOT + wasm-pack build --target web --out-name web --out-dir $OUT_DIR/web --release $PKG_ROOT || early_exit + wasm-pack build --target nodejs --out-name nodejs --out-dir $OUT_DIR/nodejs --release $PKG_ROOT || early_exit } build_debug_packages() { - wasm-pack build --target web --out-name web --out-dir $OUT_DIR/debug/dist/web --dev $PKG_ROOT -- --features "debug" - wasm-pack build --target nodejs --out-name nodejs --out-dir $OUT_DIR/debug/dist/nodejs --dev $PKG_ROOT -- --features "debug" + wasm-pack build --target web --out-name web --out-dir $OUT_DIR/debug/dist/web --dev $PKG_ROOT -- --features "debug" || early_exit + wasm-pack build --target nodejs --out-name nodejs --out-dir $OUT_DIR/debug/dist/nodejs --dev $PKG_ROOT -- --features "debug" || early_exit } delete_generated_files() { - find $OUT_DIR -name ".gitignore" -type f -delete - find $OUT_DIR -name "README.md" -type f -delete - find $OUT_DIR -name "package.json" -type f -delete - find $OUT_DIR -name "LICENSE" -type f -delete + find $OUT_DIR -name ".gitignore" -type f -delete || early_exit + find $OUT_DIR -name "README.md" -type f -delete || early_exit + find $OUT_DIR -name "package.json" -type f -delete || early_exit + find $OUT_DIR -name "LICENSE" -type f -delete || early_exit } add_debug_files() { - cp $PKG_ROOT/package.json $OUT_DIR/debug/ - cp $PKG_ROOT/LICENSE $OUT_DIR/debug/ + cp $PKG_ROOT/package.json $OUT_DIR/debug/ || early_exit + cp $PKG_ROOT/LICENSE $OUT_DIR/debug/ || early_exit } build_release_packages From 80e718ff9bedf089fad36fcaa276cfedeedc7076 Mon Sep 17 00:00:00 2001 From: Nathan Mc Grath Date: Fri, 21 Jul 2023 11:56:39 +0200 Subject: [PATCH 2/2] refactor: update verify certification params interface name Co-authored-by: Kepler Vital --- packages/certificate-verification-js/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/certificate-verification-js/src/index.ts b/packages/certificate-verification-js/src/index.ts index 66bc930a..e071b505 100644 --- a/packages/certificate-verification-js/src/index.ts +++ b/packages/certificate-verification-js/src/index.ts @@ -9,7 +9,7 @@ import { Principal } from '@dfinity/principal'; import { PipeArrayBuffer, lebDecode } from '@dfinity/candid'; import { CertificateTimeError, CertificateVerificationError } from './error'; -export interface CertificationParams { +export interface VerifyCertificationParams { canisterId: Principal; encodedCertificate: ArrayBuffer; encodedTree: ArrayBuffer; @@ -23,7 +23,7 @@ export async function verifyCertification({ encodedTree, rootKey, maxCertificateTimeOffsetMs, -}: CertificationParams): Promise { +}: VerifyCertificationParams): Promise { const certificate = await Certificate.create({ certificate: encodedCertificate, canisterId,