diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3e05fb588..23b52dbce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,14 @@ jobs: with: channel: nightly-2026-03-04 cache-base: main + - name: Setup Noir + uses: noir-lang/noirup@v0.1.2 + with: + toolchain: v1.0.0-beta.19 + - name: Generate mobile benchmark Noir artifacts + env: + MOBENCH_CI_PREPARE: "1" + run: bench-mobile/scripts/generate-fixtures.sh - name: Build run: cargo build --all-targets --all-features --verbose - name: Run tests diff --git a/.github/workflows/mobile-bench-pr-command.yml b/.github/workflows/mobile-bench-pr-command.yml new file mode 100644 index 000000000..a0aca840f --- /dev/null +++ b/.github/workflows/mobile-bench-pr-command.yml @@ -0,0 +1,166 @@ +name: Mobile Bench PR Command + +on: + issue_comment: + types: [created] + +permissions: + contents: read + actions: read + checks: write + pull-requests: write + +jobs: + resolve: + name: Parse /mobench and resolve context + if: >- + github.event_name == 'issue_comment' && + github.event.action == 'created' && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '/mobench') + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + outputs: + trusted: ${{ steps.trust.outputs.trusted }} + platform: ${{ steps.parse.outputs.platform }} + device_profile: ${{ steps.parse.outputs.device_profile }} + iterations: ${{ steps.parse.outputs.iterations }} + warmup: ${{ steps.parse.outputs.warmup }} + head_sha: ${{ steps.pr.outputs.head_sha }} + pr_number: ${{ github.event.issue.number }} + requested_by: ${{ github.event.comment.user.login }} + steps: + - name: Check trust + id: trust + env: + AUTHOR_ASSOCIATION: ${{ github.event.comment.author_association }} + run: | + if echo "OWNER,MEMBER,COLLABORATOR" | tr ',' '\n' | grep -qx "$AUTHOR_ASSOCIATION"; then + echo "trusted=true" >> "$GITHUB_OUTPUT" + else + echo "::warning::Untrusted author association: $AUTHOR_ASSOCIATION" + echo "trusted=false" >> "$GITHUB_OUTPUT" + fi + + - name: Parse command + if: steps.trust.outputs.trusted == 'true' + id: parse + env: + COMMENT_BODY: ${{ github.event.comment.body }} + run: | + set -euo pipefail + line=$(echo "$COMMENT_BODY" | head -1) + + extract_val() { + echo "$line" | sed -n "s/.*${1}=\([^ ]*\).*/\1/p" + } + + platform=$(extract_val platform) + device_profile=$(extract_val device_profile) + iterations=$(extract_val iterations) + warmup=$(extract_val warmup) + + case "${platform:-both}" in + android|ios|both) platform="${platform:-both}" ;; + *) echo "::warning::Invalid platform '${platform}', defaulting to 'both'"; platform="both" ;; + esac + + case "${device_profile:-triad}" in + smoke|triad|worst) device_profile="${device_profile:-triad}" ;; + *) echo "::warning::Invalid device_profile '${device_profile}', defaulting to 'triad'"; device_profile="triad" ;; + esac + + if ! [[ "${iterations:-2}" =~ ^[0-9]+$ ]]; then + echo "::warning::Invalid iterations '${iterations}', defaulting to '2'" + iterations="2" + else + iterations="${iterations:-2}" + fi + + if ! [[ "${warmup:-1}" =~ ^[0-9]+$ ]]; then + echo "::warning::Invalid warmup '${warmup}', defaulting to '1'" + warmup="1" + else + warmup="${warmup:-1}" + fi + + echo "platform=${platform}" >> "$GITHUB_OUTPUT" + echo "device_profile=${device_profile}" >> "$GITHUB_OUTPUT" + echo "iterations=${iterations}" >> "$GITHUB_OUTPUT" + echo "warmup=${warmup}" >> "$GITHUB_OUTPUT" + + - name: Resolve PR refs + if: steps.trust.outputs.trusted == 'true' + id: pr + env: + GH_TOKEN: ${{ github.token }} + PR_URL: ${{ github.event.issue.pull_request.url }} + run: | + set -euo pipefail + head_sha=$(gh api "$PR_URL" --jq '.head.sha') + [[ "$head_sha" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::Expected a full PR head SHA"; exit 1; } + echo "head_sha=$head_sha" >> "$GITHUB_OUTPUT" + + resolve_devices: + needs: resolve + if: needs.resolve.outputs.trusted == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + ios_devices: ${{ steps.resolve.outputs.ios_devices }} + android_devices: ${{ steps.resolve.outputs.android_devices }} + steps: + - id: resolve + shell: bash + env: + DEVICE_PROFILE: ${{ needs.resolve.outputs.device_profile }} + run: | + set -euo pipefail + case "$DEVICE_PROFILE" in + smoke|worst) + ios_devices='[{"device":"iPhone SE 2022","os_version":"15"}]' + android_devices='[{"device":"Samsung Galaxy M32","os_version":"11.0"}]' + ;; + triad) + ios_devices='[{"device":"iPhone SE 2022","os_version":"15"},{"device":"iPhone 14","os_version":"16"},{"device":"iPhone 16 Pro Max","os_version":"18"}]' + android_devices='[{"device":"Samsung Galaxy S24","os_version":"14.0"},{"device":"Google Pixel 7","os_version":"13.0"},{"device":"Samsung Galaxy M32","os_version":"11.0"}]' + ;; + *) echo "::error::Unsupported device profile: $DEVICE_PROFILE"; exit 1 ;; + esac + echo "ios_devices=$ios_devices" >> "$GITHUB_OUTPUT" + echo "android_devices=$android_devices" >> "$GITHUB_OUTPUT" + + browserstack: + name: Run BrowserStack benchmarks + needs: [resolve, resolve_devices] + if: needs.resolve.outputs.trusted == 'true' + permissions: + actions: read + checks: write + contents: read + pull-requests: write + uses: worldcoin/mobile-bench-rs/.github/workflows/reusable-bench.yml@8a2dfbb2ba941aa6a6582bf49dae482cc87779df + secrets: + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + with: + crate_path: ./bench-mobile + functions: '["bench_mobile::bench_passport_complete_age_check_prove","bench_mobile::bench_passport_fragmented_age_check_prove","bench_mobile::bench_oprf_prove"]' + functions_ios: '["bench_mobile::bench_passport_complete_age_check_prove","bench_mobile::bench_passport_fragmented_age_check_prove","bench_mobile::bench_oprf_prove"]' + functions_android: '["bench_mobile::bench_passport_fragmented_age_check_prove","bench_mobile::bench_oprf_prove","bench_mobile::bench_passport_complete_age_check_prove"]' + prepare_script: bench-mobile/scripts/generate-fixtures.sh + platform: ${{ needs.resolve.outputs.platform }} + ios_devices: ${{ needs.resolve_devices.outputs.ios_devices }} + android_devices: ${{ needs.resolve_devices.outputs.android_devices }} + iterations: ${{ needs.resolve.outputs.iterations }} + warmup: ${{ needs.resolve.outputs.warmup }} + mobench_version: "0.1.47" + max_completion_timeout_secs: 7200 + rust_toolchain: nightly-2026-03-04 + ffi_backend: native-c-abi + pr_number: ${{ needs.resolve.outputs.pr_number }} + requested_by: ${{ needs.resolve.outputs.requested_by }} + head_sha: ${{ needs.resolve.outputs.head_sha }} diff --git a/.github/workflows/mobile-bench.yml b/.github/workflows/mobile-bench.yml new file mode 100644 index 000000000..b7672e782 --- /dev/null +++ b/.github/workflows/mobile-bench.yml @@ -0,0 +1,127 @@ +name: Mobile Benchmarks + +on: + workflow_dispatch: + inputs: + functions_ios: + description: "Optional iOS-specific benchmark functions" + required: false + type: string + default: '["bench_mobile::bench_passport_complete_age_check_prove","bench_mobile::bench_passport_fragmented_age_check_prove","bench_mobile::bench_oprf_prove"]' + functions_android: + description: "Optional Android-specific benchmark functions" + required: false + type: string + default: '["bench_mobile::bench_passport_complete_age_check_prove","bench_mobile::bench_passport_fragmented_age_check_prove","bench_mobile::bench_oprf_prove"]' + platform: + description: "android | ios | both" + required: false + type: choice + default: both + options: [android, ios, both] + device_profile: + description: "Device profile to run" + required: false + type: choice + default: triad + options: [smoke, triad, worst] + device_profile_ios: + description: "Optional iOS-specific device profile" + required: false + type: string + default: "" + device_profile_android: + description: "Optional Android-specific device profile" + required: false + type: string + default: "" + iterations: + description: "Number of benchmark iterations" + required: false + type: string + default: "2" + warmup: + description: "Number of warmup iterations" + required: false + type: string + default: "1" + pr_number: + description: "PR number for reporting" + required: true + type: string + head_sha: + description: "Exact commit SHA to benchmark" + required: true + type: string + +permissions: + contents: read + actions: read + checks: write + pull-requests: write + +concurrency: + group: mobench-${{ inputs.pr_number }} + cancel-in-progress: false + +jobs: + resolve_devices: + name: Resolve device profiles + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + ios_devices: ${{ steps.resolve.outputs.ios_devices }} + android_devices: ${{ steps.resolve.outputs.android_devices }} + steps: + - id: resolve + shell: bash + env: + IOS_PROFILE: ${{ inputs.device_profile_ios != '' && inputs.device_profile_ios || inputs.device_profile }} + ANDROID_PROFILE: ${{ inputs.device_profile_android != '' && inputs.device_profile_android || inputs.device_profile }} + run: | + set -euo pipefail + case "$IOS_PROFILE" in + smoke|worst) ios_devices='[{"device":"iPhone SE 2022","os_version":"15"}]' ;; + triad) ios_devices='[{"device":"iPhone SE 2022","os_version":"15"},{"device":"iPhone 14","os_version":"16"},{"device":"iPhone 16 Pro Max","os_version":"18"}]' ;; + *) echo "::error::Unsupported iOS device profile: $IOS_PROFILE"; exit 1 ;; + esac + case "$ANDROID_PROFILE" in + smoke|worst) android_devices='[{"device":"Samsung Galaxy M32","os_version":"11.0"}]' ;; + triad) android_devices='[{"device":"Samsung Galaxy S24","os_version":"14.0"},{"device":"Google Pixel 7","os_version":"13.0"},{"device":"Samsung Galaxy M32","os_version":"11.0"}]' ;; + *) echo "::error::Unsupported Android device profile: $ANDROID_PROFILE"; exit 1 ;; + esac + echo "ios_devices=$ios_devices" >> "$GITHUB_OUTPUT" + echo "android_devices=$android_devices" >> "$GITHUB_OUTPUT" + + browserstack: + name: BrowserStack benchmarks + needs: resolve_devices + permissions: + actions: read + checks: write + contents: read + pull-requests: write + uses: worldcoin/mobile-bench-rs/.github/workflows/reusable-bench.yml@8a2dfbb2ba941aa6a6582bf49dae482cc87779df + secrets: + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + with: + crate_path: ./bench-mobile + functions: '["bench_mobile::bench_passport_complete_age_check_prove","bench_mobile::bench_passport_fragmented_age_check_prove","bench_mobile::bench_oprf_prove"]' + functions_ios: ${{ inputs.functions_ios }} + functions_android: ${{ inputs.functions_android }} + prepare_script: bench-mobile/scripts/generate-fixtures.sh + platform: ${{ inputs.platform }} + ios_devices: ${{ needs.resolve_devices.outputs.ios_devices }} + android_devices: ${{ needs.resolve_devices.outputs.android_devices }} + iterations: ${{ inputs.iterations }} + warmup: ${{ inputs.warmup }} + mobench_version: "0.1.47" + max_completion_timeout_secs: 7200 + rust_toolchain: nightly-2026-03-04 + ffi_backend: native-c-abi + pr_number: ${{ inputs.pr_number }} + allow_non_pr: false + head_sha: ${{ inputs.head_sha }} + requested_by: ${{ github.actor }} diff --git a/Cargo.lock b/Cargo.lock index e51998d63..715209035 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -553,6 +553,25 @@ version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" +[[package]] +name = "bench-mobile" +version = "0.1.0" +dependencies = [ + "anyhow", + "inventory", + "libc", + "mobench-sdk", + "noirc_abi", + "noirc_artifacts", + "provekit-backend-bn254", + "provekit-common", + "provekit-r1cs-compiler", + "rayon", + "serde", + "serde_json", + "thiserror 1.0.69", +] + [[package]] name = "bincode" version = "1.3.3" @@ -2564,6 +2583,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "inventory" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b" +dependencies = [ + "rustversion", +] + [[package]] name = "ipnet" version = "2.12.0" @@ -3114,6 +3142,31 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "mobench-macros" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a202bc64289731f6761ad9d056fa9d084808aecb17d0c1d7ac98765bcf3e92" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "mobench-sdk" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed6b1083cdd1e6a79ab3396a14e26a6fa472a60366bd37b9f2dce9a9eaa2d21f" +dependencies = [ + "inventory", + "libc", + "mobench-macros", + "serde", + "serde_json", + "thiserror 1.0.69", +] + [[package]] name = "nargo" version = "1.0.0-beta.20" diff --git a/Cargo.toml b/Cargo.toml index 821309f82..53293a08a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] resolver = "2" members = [ + "bench-mobile", "skyscraper/fp-rounding", "skyscraper/hla", "skyscraper/bn254-multiplier", @@ -125,6 +126,8 @@ divan = "0.1.21" hex = "0.4.3" inferno = { version = "0.12", default-features = false } itertools = "0.14.0" +inventory = "0.3" +mobench-sdk = { version = "0.1.47", default-features = false, features = ["registry"] } num-bigint = "0.4" paste = "1.0.15" postcard = { version = "1.1.1", features = ["use-std"] } @@ -159,6 +162,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter", "ansi"] } tracing-tracy = "=0.11.4" tracy-client = "=0.18.0" tracy-client-sys = "=0.24.3" +uniffi = "0.28" parking_lot = "0.12" keccak = "0.2.0" xz2 = "0.1.7" diff --git a/bench-mobile/Cargo.toml b/bench-mobile/Cargo.toml new file mode 100644 index 000000000..a364ddd22 --- /dev/null +++ b/bench-mobile/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "bench-mobile" +version = "0.1.0" +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +publish = false +description = "Mobile benchmarks for ProveKit Noir passport proving" + +[package.metadata.cargo-machete] +ignored = ["inventory"] + +[lib] +crate-type = ["lib", "cdylib", "staticlib"] + +[dependencies] +anyhow.workspace = true +inventory.workspace = true +mobench-sdk.workspace = true +noirc_abi.workspace = true +noirc_artifacts.workspace = true +provekit-backend-bn254 = { workspace = true, features = ["witness-generation", "parallel"] } +provekit-common.workspace = true +provekit-r1cs-compiler.workspace = true +rayon.workspace = true +serde.workspace = true +serde_json.workspace = true +thiserror = "1.0" + +[target.'cfg(unix)'.dependencies] +libc = "0.2" + +[lints] +workspace = true diff --git a/bench-mobile/build.rs b/bench-mobile/build.rs new file mode 100644 index 000000000..cf6605029 --- /dev/null +++ b/bench-mobile/build.rs @@ -0,0 +1,111 @@ +use std::{ + env, fs, io, + path::{Path, PathBuf}, +}; + +struct FixtureArtifact { + output_file: &'static str, + source_target_rel: &'static str, +} + +const FIXTURE_ARTIFACTS: &[FixtureArtifact] = &[ + FixtureArtifact { + output_file: "complete_age_check.json", + source_target_rel: "noir-examples/noir-passport-monolithic/complete_age_check/target/\ + complete_age_check.json", + }, + FixtureArtifact { + output_file: "t_add_dsc_720.json", + source_target_rel: "noir-examples/noir-passport/merkle_age_check/target/t_add_dsc_720.json", + }, + FixtureArtifact { + output_file: "t_add_id_data_720.json", + source_target_rel: "noir-examples/noir-passport/merkle_age_check/target/t_add_id_data_720.\ + json", + }, + FixtureArtifact { + output_file: "t_add_integrity_commit.json", + source_target_rel: "noir-examples/noir-passport/merkle_age_check/target/\ + t_add_integrity_commit.json", + }, + FixtureArtifact { + output_file: "t_attest.json", + source_target_rel: "noir-examples/noir-passport/merkle_age_check/target/t_attest.json", + }, + FixtureArtifact { + output_file: "oprf.json", + source_target_rel: "noir-examples/oprf/target/oprf.json", + }, + FixtureArtifact { + output_file: "p256.json", + source_target_rel: "noir-examples/p256_bigcurve/target/p256.json", + }, +]; + +fn copy_if_present(from: &Path, to: &Path) -> io::Result { + if from.exists() { + fs::copy(from, to)?; + Ok(true) + } else { + Ok(false) + } +} + +fn env_flag_enabled(name: &str) -> bool { + env::var_os(name).is_some_and(|value| value != "0" && value != "false") +} + +fn main() { + let manifest_dir = + PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR")); + let workspace_dir = manifest_dir + .parent() + .expect("bench-mobile crate should live at workspace root") + .to_path_buf(); + let out_dir = + PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR")).join("bench_mobile_fixtures"); + let artifact_dir = env::var_os("PROVEKIT_MOBILE_BENCH_ARTIFACT_DIR").map(PathBuf::from); + let require_artifacts = env_flag_enabled("PROVEKIT_REQUIRE_MOBILE_BENCH_ARTIFACTS") + || env_flag_enabled("MOBENCH_CI_PREPARE"); + + println!("cargo:rerun-if-env-changed=PROVEKIT_REQUIRE_MOBILE_BENCH_ARTIFACTS"); + println!("cargo:rerun-if-env-changed=MOBENCH_CI_PREPARE"); + + fs::create_dir_all(&out_dir).expect("create generated fixture output dir"); + + for artifact in FIXTURE_ARTIFACTS { + let out_path = out_dir.join(artifact.output_file); + let mut copied = false; + + if let Some(dir) = artifact_dir.as_ref() { + copied = copy_if_present(&dir.join(artifact.output_file), &out_path) + .expect("copy mobile benchmark artifact from override dir"); + println!("cargo:rerun-if-env-changed=PROVEKIT_MOBILE_BENCH_ARTIFACT_DIR"); + } + + if !copied { + let source_path = workspace_dir.join(artifact.source_target_rel); + copied = copy_if_present(&source_path, &out_path) + .expect("copy mobile benchmark artifact from Noir target dir"); + println!("cargo:rerun-if-changed={}", source_path.display()); + } + + if !copied { + println!( + "cargo:warning=missing generated Noir artifact {}; run the mobile fixture \ + generation workflow step before executing bench-mobile tests", + artifact.output_file + ); + if require_artifacts { + panic!( + "missing required generated Noir artifact {} at {}; run \ + bench-mobile/scripts/generate-fixtures.sh before building mobile benchmark \ + artifacts", + artifact.output_file, + workspace_dir.join(artifact.source_target_rel).display() + ); + } + fs::write(&out_path, "{}\n").expect("write placeholder mobile benchmark artifact"); + } + } +} diff --git a/bench-mobile/scripts/generate-fixtures.sh b/bench-mobile/scripts/generate-fixtures.sh new file mode 100755 index 000000000..31299ebea --- /dev/null +++ b/bench-mobile/scripts/generate-fixtures.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ "${MOBENCH_CI_PREPARE:-}" != "1" ]]; then + echo "MOBENCH_CI_PREPARE=1 is required to generate mobile benchmark fixtures" >&2 + exit 1 +fi + +if ! command -v noirup >/dev/null 2>&1; then + curl --fail --location --silent --show-error https://raw.githubusercontent.com/noir-lang/noirup/dedc07043b6ae9a680a19c7394847a58e404cbba/install | bash +fi + +export PATH="${HOME}/.nargo/bin:${PATH}" +noirup --version v1.0.0-beta.20 +nargo --version + +repo_root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" + +compile_fixture() { + local circuit_dir="$1" + local aggregate_target_dir="${2:-}" + echo "Generating Noir artifact in ${circuit_dir}" + ( + cd "${repo_root}/${circuit_dir}" + nargo compile --skip-brillig-constraints-check --force + ) + + if [[ -n "${aggregate_target_dir}" ]]; then + local circuit_target_dir="${repo_root}/${circuit_dir}/target" + local target_dir="${repo_root}/${aggregate_target_dir}" + mkdir -p "${target_dir}" + if compgen -G "${circuit_target_dir}/*.json" >/dev/null; then + cp "${circuit_target_dir}"/*.json "${target_dir}/" + fi + fi +} + +compile_fixture "noir-examples/noir-passport-monolithic/complete_age_check" +compile_fixture "noir-examples/noir-passport/merkle_age_check/t_add_dsc_720" \ + "noir-examples/noir-passport/merkle_age_check/target" +compile_fixture "noir-examples/noir-passport/merkle_age_check/t_add_id_data_720" \ + "noir-examples/noir-passport/merkle_age_check/target" +compile_fixture "noir-examples/noir-passport/merkle_age_check/t_add_integrity_commit" \ + "noir-examples/noir-passport/merkle_age_check/target" +compile_fixture "noir-examples/noir-passport/merkle_age_check/t_attest" \ + "noir-examples/noir-passport/merkle_age_check/target" +compile_fixture "noir-examples/oprf" +compile_fixture "noir-examples/p256_bigcurve" diff --git a/bench-mobile/src/examples.rs b/bench-mobile/src/examples.rs new file mode 100644 index 000000000..334eb29d6 --- /dev/null +++ b/bench-mobile/src/examples.rs @@ -0,0 +1,83 @@ +use { + crate::in_process::{ + prepare_noir_program_from_json, NoirProof, PreparedNoirProgram, VerifiedNoirProgram, + }, + anyhow::{Context, Result}, +}; + +const COMPLETE_AGE_CHECK_PROGRAM: &str = include_str!(concat!( + env!("OUT_DIR"), + "/bench_mobile_fixtures/complete_age_check.json" +)); +const COMPLETE_AGE_CHECK_TOML: &str = + include_str!("../../noir-examples/noir-passport-monolithic/complete_age_check/Prover.toml"); +const OPRF_PROGRAM: &str = + include_str!(concat!(env!("OUT_DIR"), "/bench_mobile_fixtures/oprf.json")); +const OPRF_TOML: &str = include_str!("../../noir-examples/oprf/Prover.toml"); +const P256_BIGCURVE_PROGRAM: &str = + include_str!(concat!(env!("OUT_DIR"), "/bench_mobile_fixtures/p256.json")); +const P256_BIGCURVE_TOML: &str = include_str!("../../noir-examples/p256_bigcurve/Prover.toml"); + +#[derive(Clone, Copy)] +pub enum MobileBenchFixture { + CompleteAgeCheck, + Oprf, + P256Bigcurve, +} + +impl MobileBenchFixture { + fn name(self) -> &'static str { + match self { + Self::CompleteAgeCheck => "complete_age_check", + Self::Oprf => "oprf", + Self::P256Bigcurve => "p256_bigcurve", + } + } + + fn program_json(self) -> &'static str { + match self { + Self::CompleteAgeCheck => COMPLETE_AGE_CHECK_PROGRAM, + Self::Oprf => OPRF_PROGRAM, + Self::P256Bigcurve => P256_BIGCURVE_PROGRAM, + } + } + + fn prover_toml(self) -> &'static str { + match self { + Self::CompleteAgeCheck => COMPLETE_AGE_CHECK_TOML, + Self::Oprf => OPRF_TOML, + Self::P256Bigcurve => P256_BIGCURVE_TOML, + } + } +} + +pub type PreparedCircuitFixture = PreparedNoirProgram; +pub type VerifiedCircuitFixture = VerifiedNoirProgram; + +pub fn prepare_fixture(fixture: MobileBenchFixture) -> Result { + prepare_noir_program_from_json( + fixture.name(), + fixture.program_json(), + fixture.prover_toml(), + ) + .with_context(|| format!("while preparing {} benchmark fixture", fixture.name())) +} + +pub fn prove_fixture(prepared: PreparedCircuitFixture) -> Result { + prepared.prove() +} + +pub fn prove_fixture_proof_only(prepared: PreparedCircuitFixture) -> Result { + prepared.prove_only() +} + +pub fn verify_fixture(verified: VerifiedCircuitFixture) -> Result { + verified.verify() +} + +pub fn fixture_end_to_end_smoke(fixture: MobileBenchFixture) -> Result<()> { + let prepared = prepare_fixture(fixture)?; + let verified = prove_fixture(prepared)?; + let _verified = verify_fixture(verified)?; + Ok(()) +} diff --git a/bench-mobile/src/in_process.rs b/bench-mobile/src/in_process.rs new file mode 100644 index 000000000..e2b1d6c08 --- /dev/null +++ b/bench-mobile/src/in_process.rs @@ -0,0 +1,133 @@ +//! Safe in-process helpers built on the same ProveKit implementation as the C +//! FFI entrypoints. + +use { + anyhow::{Context, Result}, + noirc_abi::{input_parser::Format, InputMap}, + noirc_artifacts::program::ProgramArtifact, + provekit_backend_bn254::{Bn254Field, Prove, ProvekitProof, Prover, Verifier, Verify}, + provekit_common::HashConfig, + provekit_r1cs_compiler::NoirCompiler, +}; + +/// BN254 proof produced by the mobile benchmark fixtures. +pub type NoirProof = ProvekitProof; + +/// Ask the platform allocator to return free pages to the OS after a large +/// proof allocation burst. +pub fn trim_process_memory() { + #[cfg(any(target_os = "android", target_os = "linux"))] + unsafe { + type MallocTrim = unsafe extern "C" fn(libc::size_t) -> libc::c_int; + + let symbol = libc::dlsym(libc::RTLD_DEFAULT, c"malloc_trim".as_ptr().cast()); + if symbol.is_null() { + return; + } + let malloc_trim: MallocTrim = std::mem::transmute(symbol); + + // SAFETY: malloc_trim does not take ownership of Rust allocations. It + // only asks the process allocator to release unused free-list pages. + malloc_trim(0); + } +} + +/// Prepared proving and verification state for one Noir benchmark program. +#[derive(Clone)] +pub struct PreparedNoirProgram { + name: String, + prover: Prover, + verifier: Verifier, + input_map: InputMap, +} + +impl PreparedNoirProgram { + /// Return the R1CS size exposed by the prepared prover. + pub fn prover_size(&self) -> (usize, usize) { + self.prover.size() + } + + /// Return the number of R1CS constraints in the prepared verifier. + pub fn constraint_count(&self) -> usize { + self.verifier.r1cs.num_constraints() + } + + /// Return the number of parsed ABI input values. + pub fn input_count(&self) -> usize { + self.input_map.len() + } + + /// Generate and bind a proof to the matching verifier state. + pub fn prove(self) -> Result { + let proof = self + .prover + .prove(self.input_map) + .with_context(|| format!("while proving {} benchmark fixture", self.name))?; + + Ok(VerifiedNoirProgram { + name: self.name, + verifier: self.verifier, + proof, + }) + } + + /// Generate only the proof, dropping verifier-side state before proving. + pub fn prove_only(self) -> Result { + let Self { + name, + prover, + verifier, + input_map, + } = self; + + drop(verifier); + trim_process_memory(); + + prover + .prove(input_map) + .with_context(|| format!("while proving {name} benchmark fixture")) + } +} + +/// Verified-ready proof plus verifier state for one Noir benchmark program. +#[derive(Clone)] +pub struct VerifiedNoirProgram { + name: String, + verifier: Verifier, + proof: NoirProof, +} + +impl VerifiedNoirProgram { + /// Verify the proof against its matching verifier state. + pub fn verify(mut self) -> Result { + self.verifier + .verify(&self.proof) + .with_context(|| format!("while verifying {} benchmark fixture", self.name))?; + + Ok(self) + } +} + +/// Prepare a Noir program from an already-compiled artifact JSON string and a +/// TOML witness input string. +pub fn prepare_noir_program_from_json( + name: impl Into, + program_json: &str, + prover_toml: &str, +) -> Result { + let name = name.into(); + let program: ProgramArtifact = serde_json::from_str(program_json) + .with_context(|| format!("while deserializing {name} program artifact"))?; + let scheme = NoirCompiler::from_program(program, HashConfig::default()) + .with_context(|| format!("while preparing {name} noir proof scheme"))?; + let input_map = Format::Toml + .parse(prover_toml, scheme.abi()) + .with_context(|| format!("while parsing {name} prover inputs"))?; + + Ok(PreparedNoirProgram { + name, + prover: Prover::from_noir_proof_scheme(scheme.clone()), + verifier: Verifier::from_noir_proof_scheme(scheme), + input_map, + }) +} diff --git a/bench-mobile/src/lib.rs b/bench-mobile/src/lib.rs new file mode 100644 index 000000000..e3cbaec24 --- /dev/null +++ b/bench-mobile/src/lib.rs @@ -0,0 +1,530 @@ +//! Mobile benchmarks for ProveKit passport and example circuits. + +use { + crate::passport::{ + prove_complete_age_check_fixture, prove_complete_age_check_fixture_proof_only, + prove_fragmented_age_check_fixture_proof_only, verify_complete_age_check_fixture, + PreparedCompleteAgeCheckFixture, PreparedFragmentedAgeCheckFixture, + VerifiedCompleteAgeCheckFixture, + }, + examples::{MobileBenchFixture, PreparedCircuitFixture, VerifiedCircuitFixture}, + mobench_sdk::{benchmark, profile_phase}, + serde_json::json, + std::hint::black_box, +}; + +pub mod examples; +mod in_process; +pub mod passport; + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct BenchSpec { + pub name: String, + pub iterations: u32, + pub warmup: u32, +} + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct BenchSample { + pub duration_ns: u64, + pub cpu_time_ms: Option, + pub peak_memory_kb: Option, + pub process_peak_memory_kb: Option, +} + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct SemanticPhase { + pub name: String, + pub duration_ns: u64, +} + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct HarnessTimelineSpan { + pub phase: String, + pub start_offset_ns: u64, + pub end_offset_ns: u64, + pub iteration: Option, +} + +#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] +pub struct BenchReport { + pub spec: BenchSpec, + pub samples: Vec, + pub phases: Vec, + pub timeline: Vec, +} + +#[derive(Debug, thiserror::Error)] +pub enum BenchError { + #[error("iterations must be greater than zero")] + InvalidIterations, + + #[error("unknown benchmark function: {name}")] + UnknownFunction { name: String }, + + #[error("benchmark execution failed: {reason}")] + ExecutionFailed { reason: String }, +} + +#[cfg(target_os = "android")] +fn configure_android_complete_age_check_threads(function: &str) { + use std::sync::Once; + + static INIT: Once = Once::new(); + + if function != "bench_mobile::bench_passport_complete_age_check_prove" { + return; + } + + INIT.call_once(|| { + let threads = std::env::var("PROVEKIT_ANDROID_COMPLETE_AGE_RAYON_THREADS") + .ok() + .and_then(|value| value.parse::().ok()) + .filter(|threads| *threads > 0) + .unwrap_or(1); + + match rayon::ThreadPoolBuilder::new() + .num_threads(threads) + .build_global() + { + Ok(()) => log_benchmark_lifecycle( + "rayon_configured", + function, + 0, + 0, + json!({ "threads": threads }), + ), + Err(error) => log_benchmark_lifecycle( + "rayon_config_skipped", + function, + 0, + 0, + json!({ "threads": threads, "error": error.to_string() }), + ), + } + }); +} + +#[cfg(not(target_os = "android"))] +fn configure_android_complete_age_check_threads(_function: &str) {} + +impl From for BenchSpec { + fn from(spec: mobench_sdk::BenchSpec) -> Self { + Self { + name: spec.name, + iterations: spec.iterations, + warmup: spec.warmup, + } + } +} + +impl From for mobench_sdk::BenchSpec { + fn from(spec: BenchSpec) -> Self { + Self { + name: spec.name, + iterations: spec.iterations, + warmup: spec.warmup, + } + } +} + +impl From for BenchSample { + fn from(sample: mobench_sdk::BenchSample) -> Self { + Self { + duration_ns: sample.duration_ns, + cpu_time_ms: sample.cpu_time_ms, + peak_memory_kb: sample.peak_memory_kb, + process_peak_memory_kb: sample.process_peak_memory_kb, + } + } +} + +impl From for SemanticPhase { + fn from(phase: mobench_sdk::SemanticPhase) -> Self { + Self { + name: phase.name, + duration_ns: phase.duration_ns, + } + } +} + +impl From for HarnessTimelineSpan { + fn from(span: mobench_sdk::HarnessTimelineSpan) -> Self { + Self { + phase: span.phase, + start_offset_ns: span.start_offset_ns, + end_offset_ns: span.end_offset_ns, + iteration: span.iteration, + } + } +} + +impl From for BenchReport { + fn from(report: mobench_sdk::RunnerReport) -> Self { + Self { + spec: report.spec.into(), + samples: report.samples.into_iter().map(Into::into).collect(), + phases: report.phases.into_iter().map(Into::into).collect(), + timeline: report.timeline.into_iter().map(Into::into).collect(), + } + } +} + +impl From for BenchError { + fn from(err: mobench_sdk::BenchError) -> Self { + match err { + mobench_sdk::BenchError::Runner(runner_err) => Self::ExecutionFailed { + reason: runner_err.to_string(), + }, + mobench_sdk::BenchError::UnknownFunction(name, _available) => { + Self::UnknownFunction { name } + } + _ => Self::ExecutionFailed { + reason: err.to_string(), + }, + } + } +} + +fn log_benchmark_lifecycle( + event: &str, + function: &str, + iterations: u32, + warmup: u32, + extra: serde_json::Value, +) { + let payload = json!({ + "tag": "MOBENCH_LIFECYCLE", + "event": event, + "function": function, + "iterations": iterations, + "warmup": warmup, + "extra": extra, + }); + + if event == "error" { + eprintln!("{payload}"); + } else { + println!("{payload}"); + } +} + +pub fn run_benchmark(spec: BenchSpec) -> Result { + let function = spec.name.clone(); + let iterations = spec.iterations; + let warmup = spec.warmup; + configure_android_complete_age_check_threads(&function); + log_benchmark_lifecycle( + "start", + &function, + iterations, + warmup, + json!({ + "resolved_function": function, + }), + ); + + let sdk_spec: mobench_sdk::BenchSpec = spec.into(); + match mobench_sdk::run_benchmark(sdk_spec) { + Ok(report) => { + log_benchmark_lifecycle( + "success", + &report.spec.name, + report.spec.iterations, + report.spec.warmup, + json!({ + "sample_count": report.samples.len(), + "phase_count": report.phases.len(), + "timeline_span_count": report.timeline.len(), + "sample_resource_count": report + .samples + .iter() + .filter(|sample| { + sample.cpu_time_ms.is_some() + || sample.peak_memory_kb.is_some() + || sample.process_peak_memory_kb.is_some() + }) + .count(), + }), + ); + Ok(report.into()) + } + Err(err) => { + log_benchmark_lifecycle( + "error", + &function, + iterations, + warmup, + json!({ + "resolved_function": function, + "error": err.to_string(), + }), + ); + Err(err.into()) + } + } +} + +mobench_sdk::export_native_c_abi!(); + +fn setup_complete_age_check_prepared() -> PreparedCompleteAgeCheckFixture { + passport::prepare_complete_age_check_fixture().expect("prepare complete_age_check fixture") +} + +fn setup_complete_age_check_verified() -> VerifiedCompleteAgeCheckFixture { + let prepared = setup_complete_age_check_prepared(); + prove_complete_age_check_fixture(prepared).expect("prove complete_age_check fixture") +} + +fn setup_fragmented_age_check_prepared() -> PreparedFragmentedAgeCheckFixture { + passport::prepare_fragmented_age_check_fixture().expect("prepare fragmented age_check fixture") +} + +fn setup_oprf_prepared() -> PreparedCircuitFixture { + examples::prepare_fixture(MobileBenchFixture::Oprf).expect("prepare oprf fixture") +} + +fn setup_oprf_verified() -> VerifiedCircuitFixture { + let prepared = setup_oprf_prepared(); + examples::prove_fixture(prepared).expect("prove oprf fixture") +} + +fn setup_p256_bigcurve_prepared() -> PreparedCircuitFixture { + examples::prepare_fixture(MobileBenchFixture::P256Bigcurve) + .expect("prepare p256_bigcurve fixture") +} + +fn setup_p256_bigcurve_verified() -> VerifiedCircuitFixture { + let prepared = setup_p256_bigcurve_prepared(); + examples::prove_fixture(prepared).expect("prove p256_bigcurve fixture") +} + +#[benchmark] +pub fn bench_passport_complete_age_check_prepare() { + let prepared = profile_phase("prepare", || { + passport::prepare_complete_age_check_fixture().expect("prepare complete_age_check fixture") + }); + + black_box(( + prepared.prover_size(), + prepared.constraint_count(), + prepared.input_count(), + )); +} + +#[benchmark(setup = setup_complete_age_check_prepared, per_iteration)] +pub fn bench_passport_complete_age_check_prove(prepared: PreparedCompleteAgeCheckFixture) { + let proof = profile_phase("prove", || { + prove_complete_age_check_fixture_proof_only(prepared) + .expect("prove complete_age_check fixture") + }); + + black_box(proof); +} + +#[benchmark(setup = setup_complete_age_check_verified)] +pub fn bench_passport_complete_age_check_verify(verified: &VerifiedCompleteAgeCheckFixture) { + let verified = profile_phase("verify", || { + verify_complete_age_check_fixture(verified.clone()) + .expect("verify complete_age_check fixture") + }); + + black_box(verified); +} + +#[benchmark] +pub fn bench_passport_complete_age_check_e2e() { + let prepared = profile_phase("prepare", || { + passport::prepare_complete_age_check_fixture().expect("prepare complete_age_check fixture") + }); + let verified = profile_phase("prove", || { + prove_complete_age_check_fixture(prepared).expect("prove complete_age_check fixture") + }); + let verified = profile_phase("verify", || { + verify_complete_age_check_fixture(verified).expect("verify complete_age_check fixture") + }); + + black_box(verified); +} + +#[benchmark] +pub fn bench_passport_fragmented_age_check_prepare() { + let prepared = profile_phase("prepare", || { + passport::prepare_fragmented_age_check_fixture() + .expect("prepare fragmented age_check fixture") + }); + + black_box(( + prepared.add_dsc.prover_size(), + prepared.add_id_data.prover_size(), + prepared.add_integrity_commit.prover_size(), + prepared.attest.prover_size(), + )); +} + +#[benchmark(setup = setup_fragmented_age_check_prepared, per_iteration)] +pub fn bench_passport_fragmented_age_check_prove(prepared: PreparedFragmentedAgeCheckFixture) { + let proofs = profile_phase("prove", || { + prove_fragmented_age_check_fixture_proof_only(prepared) + .expect("prove fragmented age_check fixture") + }); + + black_box(proofs); +} + +#[benchmark] +pub fn bench_oprf_prepare() { + let prepared = profile_phase("prepare", || { + examples::prepare_fixture(MobileBenchFixture::Oprf).expect("prepare oprf fixture") + }); + + black_box(( + prepared.prover_size(), + prepared.constraint_count(), + prepared.input_count(), + )); +} + +#[benchmark(setup = setup_oprf_prepared, per_iteration)] +pub fn bench_oprf_prove(prepared: PreparedCircuitFixture) { + let proof = profile_phase("prove", || { + examples::prove_fixture_proof_only(prepared).expect("prove oprf fixture") + }); + + black_box(proof); +} + +#[benchmark(setup = setup_oprf_verified)] +pub fn bench_oprf_verify(verified: &VerifiedCircuitFixture) { + let verified = profile_phase("verify", || { + examples::verify_fixture(verified.clone()).expect("verify oprf fixture") + }); + + black_box(verified); +} + +#[benchmark] +pub fn bench_oprf_e2e() { + let prepared = profile_phase("prepare", || { + examples::prepare_fixture(MobileBenchFixture::Oprf).expect("prepare oprf fixture") + }); + let verified = profile_phase("prove", || { + examples::prove_fixture(prepared).expect("prove oprf fixture") + }); + let verified = profile_phase("verify", || { + examples::verify_fixture(verified).expect("verify oprf fixture") + }); + + black_box(verified); +} + +#[benchmark] +pub fn bench_p256_bigcurve_prepare() { + let prepared = profile_phase("prepare", || { + examples::prepare_fixture(MobileBenchFixture::P256Bigcurve) + .expect("prepare p256_bigcurve fixture") + }); + + black_box(( + prepared.prover_size(), + prepared.constraint_count(), + prepared.input_count(), + )); +} + +#[benchmark(setup = setup_p256_bigcurve_prepared, per_iteration)] +pub fn bench_p256_bigcurve_prove(prepared: PreparedCircuitFixture) { + let verified = profile_phase("prove", || { + examples::prove_fixture(prepared).expect("prove p256_bigcurve fixture") + }); + + black_box(verified); +} + +#[benchmark(setup = setup_p256_bigcurve_verified)] +pub fn bench_p256_bigcurve_verify(verified: &VerifiedCircuitFixture) { + let verified = profile_phase("verify", || { + examples::verify_fixture(verified.clone()).expect("verify p256_bigcurve fixture") + }); + + black_box(verified); +} + +#[benchmark] +pub fn bench_p256_bigcurve_e2e() { + let prepared = profile_phase("prepare", || { + examples::prepare_fixture(MobileBenchFixture::P256Bigcurve) + .expect("prepare p256_bigcurve fixture") + }); + let verified = profile_phase("prove", || { + examples::prove_fixture(prepared).expect("prove p256_bigcurve fixture") + }); + let verified = profile_phase("verify", || { + examples::verify_fixture(verified).expect("verify p256_bigcurve fixture") + }); + + black_box(verified); +} + +#[cfg(test)] +mod tests { + use super::BenchReport; + + #[test] + fn report_conversion_preserves_sample_resource_metrics() { + let report = mobench_sdk::RunnerReport { + spec: mobench_sdk::BenchSpec { + name: "bench_mobile::bench_passport_complete_age_check_prove".to_string(), + iterations: 1, + warmup: 0, + }, + samples: vec![mobench_sdk::BenchSample { + duration_ns: 123, + cpu_time_ms: Some(7), + peak_memory_kb: Some(48), + process_peak_memory_kb: Some(1024), + }], + phases: vec![], + timeline: vec![], + }; + + let value = + serde_json::to_value(BenchReport::from(report)).expect("serialize bench report"); + + assert_eq!(value["samples"][0]["cpu_time_ms"], 7); + assert_eq!(value["samples"][0]["peak_memory_kb"], 48); + assert_eq!(value["samples"][0]["process_peak_memory_kb"], 1024); + } + + #[test] + fn report_conversion_preserves_timeline_spans() { + let report = mobench_sdk::RunnerReport { + spec: mobench_sdk::BenchSpec { + name: "bench_mobile::bench_passport_complete_age_check_verify".to_string(), + iterations: 1, + warmup: 0, + }, + samples: vec![mobench_sdk::BenchSample { + duration_ns: 321, + cpu_time_ms: None, + peak_memory_kb: None, + process_peak_memory_kb: None, + }], + phases: vec![], + timeline: vec![mobench_sdk::HarnessTimelineSpan { + phase: "measured".to_string(), + start_offset_ns: 10, + end_offset_ns: 20, + iteration: Some(0), + }], + }; + + let value = + serde_json::to_value(BenchReport::from(report)).expect("serialize bench report"); + + assert_eq!(value["timeline"][0]["phase"], "measured"); + assert_eq!(value["timeline"][0]["start_offset_ns"], 10); + assert_eq!(value["timeline"][0]["end_offset_ns"], 20); + assert_eq!(value["timeline"][0]["iteration"], 0); + } +} diff --git a/bench-mobile/src/passport.rs b/bench-mobile/src/passport.rs new file mode 100644 index 000000000..694486794 --- /dev/null +++ b/bench-mobile/src/passport.rs @@ -0,0 +1,211 @@ +use { + crate::in_process::{ + prepare_noir_program_from_json, trim_process_memory, NoirProof, PreparedNoirProgram, + VerifiedNoirProgram, + }, + anyhow::{Context, Result}, +}; + +const COMPLETE_AGE_CHECK_PROGRAM: &str = include_str!(concat!( + env!("OUT_DIR"), + "/bench_mobile_fixtures/complete_age_check.json" +)); +const COMPLETE_AGE_CHECK_TOML: &str = + include_str!("../../noir-examples/noir-passport-monolithic/complete_age_check/Prover.toml"); +const FRAGMENTED_ADD_DSC_PROGRAM: &str = include_str!(concat!( + env!("OUT_DIR"), + "/bench_mobile_fixtures/t_add_dsc_720.json" +)); +const FRAGMENTED_ADD_DSC_TOML: &str = include_str!( + "../../noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_dsc_720.\ + toml" +); +const FRAGMENTED_ADD_ID_DATA_PROGRAM: &str = include_str!(concat!( + env!("OUT_DIR"), + "/bench_mobile_fixtures/t_add_id_data_720.json" +)); +const FRAGMENTED_ADD_ID_DATA_TOML: &str = include_str!( + "../../noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/\ + t_add_id_data_720.toml" +); +const FRAGMENTED_ADD_INTEGRITY_COMMIT_PROGRAM: &str = include_str!(concat!( + env!("OUT_DIR"), + "/bench_mobile_fixtures/t_add_integrity_commit.json" +)); +const FRAGMENTED_ADD_INTEGRITY_COMMIT_TOML: &str = include_str!( + "../../noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/\ + t_add_integrity_commit.toml" +); +const FRAGMENTED_ATTEST_PROGRAM: &str = include_str!(concat!( + env!("OUT_DIR"), + "/bench_mobile_fixtures/t_attest.json" +)); +const FRAGMENTED_ATTEST_TOML: &str = include_str!( + "../../noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_attest.toml" +); + +pub type PreparedCompleteAgeCheckFixture = PreparedNoirProgram; +pub type VerifiedCompleteAgeCheckFixture = VerifiedNoirProgram; + +/// Prepared prover state for the four-stage fragmented age-check fixture. +#[derive(Clone)] +pub struct PreparedFragmentedAgeCheckFixture { + pub add_dsc: PreparedNoirProgram, + pub add_id_data: PreparedNoirProgram, + pub add_integrity_commit: PreparedNoirProgram, + pub attest: PreparedNoirProgram, +} + +/// Verified proof outputs for the four-stage fragmented age-check fixture. +#[derive(Clone)] +pub struct VerifiedFragmentedAgeCheckFixture { + pub add_dsc: VerifiedNoirProgram, + pub add_id_data: VerifiedNoirProgram, + pub add_integrity_commit: VerifiedNoirProgram, + pub attest: VerifiedNoirProgram, +} + +/// Proof-only outputs for the four-stage fragmented age-check fixture. +#[derive(Clone)] +pub struct FragmentedAgeCheckProofs { + pub add_dsc: NoirProof, + pub add_id_data: NoirProof, + pub add_integrity_commit: NoirProof, + pub attest: NoirProof, +} + +pub fn prepare_complete_age_check_fixture() -> Result { + prepare_noir_program_from_json( + "complete_age_check", + COMPLETE_AGE_CHECK_PROGRAM, + COMPLETE_AGE_CHECK_TOML, + ) + .context("while preparing complete_age_check benchmark fixture") +} + +pub fn prove_complete_age_check_fixture( + prepared: PreparedCompleteAgeCheckFixture, +) -> Result { + let verified = prepared.prove()?; + trim_process_memory(); + Ok(verified) +} + +pub fn prove_complete_age_check_fixture_proof_only( + prepared: PreparedCompleteAgeCheckFixture, +) -> Result { + let proof = prepared.prove_only()?; + trim_process_memory(); + Ok(proof) +} + +pub fn verify_complete_age_check_fixture( + verified: VerifiedCompleteAgeCheckFixture, +) -> Result { + verified.verify() +} + +/// Prepare all four checked-in fragmented age-check stages. +pub fn prepare_fragmented_age_check_fixture() -> Result { + Ok(PreparedFragmentedAgeCheckFixture { + add_dsc: prepare_noir_program_from_json( + "t_add_dsc_720", + FRAGMENTED_ADD_DSC_PROGRAM, + FRAGMENTED_ADD_DSC_TOML, + ) + .context("while preparing t_add_dsc_720 benchmark fixture")?, + add_id_data: prepare_noir_program_from_json( + "t_add_id_data_720", + FRAGMENTED_ADD_ID_DATA_PROGRAM, + FRAGMENTED_ADD_ID_DATA_TOML, + ) + .context("while preparing t_add_id_data_720 benchmark fixture")?, + add_integrity_commit: prepare_noir_program_from_json( + "t_add_integrity_commit", + FRAGMENTED_ADD_INTEGRITY_COMMIT_PROGRAM, + FRAGMENTED_ADD_INTEGRITY_COMMIT_TOML, + ) + .context("while preparing t_add_integrity_commit benchmark fixture")?, + attest: prepare_noir_program_from_json( + "t_attest", + FRAGMENTED_ATTEST_PROGRAM, + FRAGMENTED_ATTEST_TOML, + ) + .context("while preparing t_attest benchmark fixture")?, + }) +} + +/// Prove every fragmented age-check stage once, dropping verifier state before +/// each proof. +pub fn prove_fragmented_age_check_fixture_proof_only( + prepared: PreparedFragmentedAgeCheckFixture, +) -> Result { + let add_dsc = prepared.add_dsc.prove_only()?; + trim_process_memory(); + + let add_id_data = prepared.add_id_data.prove_only()?; + trim_process_memory(); + + let add_integrity_commit = prepared.add_integrity_commit.prove_only()?; + trim_process_memory(); + + let attest = prepared.attest.prove_only()?; + trim_process_memory(); + + Ok(FragmentedAgeCheckProofs { + add_dsc, + add_id_data, + add_integrity_commit, + attest, + }) +} + +/// Prove every fragmented age-check stage once and return the verified outputs. +pub fn prove_fragmented_age_check_fixture( + prepared: PreparedFragmentedAgeCheckFixture, +) -> Result { + let add_dsc = prepared.add_dsc.prove()?; + trim_process_memory(); + + let add_id_data = prepared.add_id_data.prove()?; + trim_process_memory(); + + let add_integrity_commit = prepared.add_integrity_commit.prove()?; + trim_process_memory(); + + let attest = prepared.attest.prove()?; + trim_process_memory(); + + Ok(VerifiedFragmentedAgeCheckFixture { + add_dsc, + add_id_data, + add_integrity_commit, + attest, + }) +} + +/// Verify every fragmented age-check stage proof once. +pub fn verify_fragmented_age_check_fixture( + verified: VerifiedFragmentedAgeCheckFixture, +) -> Result { + Ok(VerifiedFragmentedAgeCheckFixture { + add_dsc: verified.add_dsc.verify()?, + add_id_data: verified.add_id_data.verify()?, + add_integrity_commit: verified.add_integrity_commit.verify()?, + attest: verified.attest.verify()?, + }) +} + +pub fn passport_fragmented_age_check_end_to_end_smoke() -> Result<()> { + let prepared = prepare_fragmented_age_check_fixture()?; + let verified = prove_fragmented_age_check_fixture(prepared)?; + let _verified = verify_fragmented_age_check_fixture(verified)?; + Ok(()) +} + +pub fn passport_complete_age_check_end_to_end_smoke() -> Result<()> { + let prepared = prepare_complete_age_check_fixture()?; + let verified = prove_complete_age_check_fixture(prepared)?; + let _verified = verify_complete_age_check_fixture(verified)?; + Ok(()) +} diff --git a/bench-mobile/tests/examples_smoke.rs b/bench-mobile/tests/examples_smoke.rs new file mode 100644 index 000000000..ecfc17c65 --- /dev/null +++ b/bench-mobile/tests/examples_smoke.rs @@ -0,0 +1,27 @@ +use bench_mobile::examples::{fixture_end_to_end_smoke, prepare_fixture, MobileBenchFixture}; + +#[test] +fn embedded_example_fixtures_prepare_non_empty_artifacts() { + for fixture in [ + MobileBenchFixture::CompleteAgeCheck, + MobileBenchFixture::Oprf, + MobileBenchFixture::P256Bigcurve, + ] { + let prepared = prepare_fixture(fixture).expect("prepare fixture"); + let (constraints, witnesses) = prepared.prover_size(); + + assert!(constraints > 0, "expected non-empty constraint set"); + assert!(witnesses > 0, "expected non-empty witness set"); + } +} + +#[test] +fn embedded_oprf_fixture_proves_and_verifies() { + fixture_end_to_end_smoke(MobileBenchFixture::Oprf).expect("oprf smoke benchmark"); +} + +#[test] +fn embedded_p256_bigcurve_fixture_proves_and_verifies() { + fixture_end_to_end_smoke(MobileBenchFixture::P256Bigcurve) + .expect("p256_bigcurve smoke benchmark"); +} diff --git a/bench-mobile/tests/passport_smoke.rs b/bench-mobile/tests/passport_smoke.rs new file mode 100644 index 000000000..b423b3bbd --- /dev/null +++ b/bench-mobile/tests/passport_smoke.rs @@ -0,0 +1,40 @@ +use bench_mobile::passport::{ + passport_complete_age_check_end_to_end_smoke, passport_fragmented_age_check_end_to_end_smoke, + prepare_complete_age_check_fixture, prepare_fragmented_age_check_fixture, +}; + +#[test] +fn embedded_passport_fixture_prepares_non_empty_artifacts() { + let prepared = prepare_complete_age_check_fixture().expect("prepare fixture"); + let (constraints, witnesses) = prepared.prover_size(); + + assert!(constraints > 0, "expected non-empty constraint set"); + assert!(witnesses > 0, "expected non-empty witness set"); +} + +#[test] +fn embedded_passport_fixture_proves_and_verifies() { + passport_complete_age_check_end_to_end_smoke().expect("passport smoke benchmark"); +} + +#[test] +fn embedded_fragmented_passport_fixture_prepares_non_empty_artifacts() { + let prepared = prepare_fragmented_age_check_fixture().expect("prepare fragmented fixture"); + + for (name, fixture) in [ + ("t_add_dsc_720", prepared.add_dsc), + ("t_add_id_data_720", prepared.add_id_data), + ("t_add_integrity_commit", prepared.add_integrity_commit), + ("t_attest", prepared.attest), + ] { + let (constraints, witnesses) = fixture.prover_size(); + + assert!(constraints > 0, "{name} should have non-empty constraints"); + assert!(witnesses > 0, "{name} should have non-empty witnesses"); + } +} + +#[test] +fn embedded_fragmented_passport_fixture_proves_and_verifies() { + passport_fragmented_age_check_end_to_end_smoke().expect("fragmented passport smoke benchmark"); +} diff --git a/mobench.toml b/mobench.toml new file mode 100644 index 000000000..4f9d7f7a0 --- /dev/null +++ b/mobench.toml @@ -0,0 +1,20 @@ +[project] +crate = "bench-mobile" +library_name = "bench_mobile" +ffi_backend = "native-c-abi" + +[android] +package = "dev.world.benchmobile" +min_sdk = 24 +target_sdk = 34 +abis = ["arm64-v8a"] + +[ios] +bundle_id = "dev.world.benchmobile" +deployment_target = "13.0" +runner = "uikit-legacy" + +[browserstack] +ios_completion_timeout_secs = 7200 +android_benchmark_timeout_secs = 7200 +android_heartbeat_interval_secs = 10 diff --git a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_dsc_verify_1300.toml b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_dsc_verify_1300.toml index 847d76156..e24296055 100644 --- a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_dsc_verify_1300.toml +++ b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_dsc_verify_1300.toml @@ -6,7 +6,7 @@ country = "UTO" state1 = [2255395565, 3984421451, 1880533823, 1801696719, 786056496, 1504766900, 4275076418, 57901920] tbs_certificate = [48, 130, 3, 78, 160, 3, 2, 1, 2, 2, 1, 2, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 67, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 84, 49, 32, 48, 30, 6, 3, 85, 4, 10, 12, 23, 77, 111, 99, 107, 32, 80, 97, 115, 115, 112, 111, 114, 116, 32, 65, 117, 116, 104, 111, 114, 105, 116, 121, 49, 18, 48, 16, 6, 3, 85, 4, 3, 12, 9, 77, 111, 99, 107, 32, 67, 83, 67, 65, 48, 30, 23, 13, 50, 49, 48, 51, 50, 54, 49, 51, 52, 56, 48, 48, 90, 23, 13, 51, 49, 48, 51, 50, 52, 49, 51, 52, 56, 48, 48, 90, 48, 66, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 84, 49, 32, 48, 30, 6, 3, 85, 4, 10, 12, 23, 77, 111, 99, 107, 32, 80, 97, 115, 115, 112, 111, 114, 116, 32, 65, 117, 116, 104, 111, 114, 105, 116, 121, 49, 17, 48, 15, 6, 3, 85, 4, 3, 12, 8, 77, 111, 99, 107, 32, 68, 83, 67, 48, 130, 1, 34, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 130, 1, 15, 0, 48, 130, 1, 10, 2, 130, 1, 1, 0, 144, 96, 22, 98, 202, 23, 238, 6, 187, 83, 246, 10, 141, 149, 39, 62, 150, 207, 25, 76, 254, 121, 159, 193, 25, 17, 64, 229, 112, 170, 152, 94, 212, 213, 4, 191, 8, 183, 225, 184, 213, 181, 211, 100, 210, 60, 155, 26, 13, 219, 11, 116, 84, 236, 33, 212, 47, 5, 187, 226, 120, 161, 57, 97, 200, 250, 174, 139, 216, 171, 95, 178, 148, 109, 3, 137, 151, 245, 142, 53, 177, 251, 74, 202, 2, 157, 33, 55, 30, 189, 239, 243, 101, 183, 43, 68, 245, 198, 9, 90, 109, 89, 109, 33, 98, 32, 173, 121, 203, 2, 79, 68, 150, 135, 158, 72, 76, 223, 55, 66, 30, 45, 33, 16, 91, 153, 158, 127, 64, 221, 31, 151, 241, 93, 105, 235, 153, 176, 146, 221, 20, 231, 141, 2, 146, 77, 209, 30, 90, 33, 33, 232, 176, 145, 244, 229, 221, 43, 101, 10, 210, 55, 50, 200, 103, 87, 18, 82, 53, 193, 130, 124, 69, 96, 179, 87, 245, 203, 181, 205, 57, 67, 181, 80, 198, 57, 101, 151, 179, 103, 201, 243, 52, 68, 91, 122, 137, 209, 141, 39, 68, 73, 244, 200, 211, 125, 2, 176, 12, 80, 77, 81, 225, 169, 34, 209, 187, 212, 47, 56, 92, 220, 159, 89, 236, 133, 200, 211, 11, 237, 217, 129, 115, 191, 208, 39, 198, 179, 16, 28, 59, 121, 160, 48, 239, 81, 144, 102, 168, 122, 158, 59, 83, 54, 91, 211, 2, 3, 1, 0, 1, 163, 130, 1, 100, 48, 130, 1, 96, 48, 15, 6, 3, 85, 29, 19, 1, 1, 255, 4, 5, 48, 3, 1, 1, 0, 48, 14, 6, 3, 85, 29, 15, 1, 1, 255, 4, 4, 3, 2, 7, 128, 48, 41, 6, 3, 85, 29, 14, 4, 34, 4, 32, 236, 115, 196, 36, 236, 2, 138, 16, 34, 153, 224, 23, 230, 87, 56, 253, 158, 235, 14, 147, 38, 52, 87, 5, 72, 19, 213, 247, 131, 38, 127, 141, 48, 130, 1, 16, 6, 9, 43, 6, 1, 4, 1, 134, 141, 31, 1, 4, 130, 1, 1, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] tbs_certificate_len = 850 -csc_pubkey_redc_param = [21, 107, 159, 157, 72, 119, 18, 0, 27, 71, 177, 110, 89, 195, 140, 32, 0, 81, 204, 142, 10, 42, 57, 174, 56, 49, 20, 174, 40, 168, 13, 110, 119, 62, 130, 206, 113, 131, 163, 69, 216, 148, 52, 169, 100, 129, 114, 255, 46, 231, 61, 14, 80, 203, 136, 94, 50, 194, 33, 127, 20, 160, 234, 71, 20, 201, 8, 231, 223, 0, 192, 38, 138, 232, 188, 101, 68, 103, 102, 81, 27, 78, 37, 96, 11, 135, 61, 12, 158, 37, 141, 215, 151, 25, 176, 135, 41, 133, 163, 113, 221, 161, 175, 226, 9, 113, 252, 229, 239, 48, 55, 162, 33, 178, 224, 94, 18, 161, 220, 186, 163, 10, 133, 85, 127, 74, 95, 74, 192, 164, 69, 236, 121, 95, 224, 115, 181, 169, 156, 121, 161, 180, 127, 61, 26, 113, 65, 35, 241, 87, 67, 152, 40, 160, 29, 190, 249, 119, 178, 40, 99, 198, 222, 102, 162, 68, 138, 169, 237, 193, 199, 151, 159, 80, 118, 20, 141, 97, 224, 76, 212, 29, 80, 238, 32, 234, 172, 151, 141, 134, 227, 177, 61, 106, 9, 105, 194, 149, 232, 171, 165, 135, 244, 24, 214, 213, 28, 115, 68, 75, 160, 198, 129, 73, 238, 59, 59, 4, 45, 101, 235, 220, 224, 224, 5, 76, 13, 218, 137, 189, 174, 52, 38, 192, 245, 127, 138, 81, 96, 255, 162, 119, 44, 210, 247, 66, 99, 3, 202, 110, 26, 174, 27, 157, 15, 85, 81, 115, 162, 35, 217, 73, 84, 139, 198, 206, 205, 93, 221, 207, 182, 126, 20, 211, 178, 23, 232, 95, 253, 252, 254, 211, 143, 149, 130, 102, 69, 47, 230, 141, 23, 107, 148, 35, 98, 85, 98, 111, 238, 85, 148, 111, 251, 83, 220, 88, 156, 81, 27, 196, 8, 5, 66, 216, 111, 3, 226, 212, 80, 151, 38, 164, 172, 189, 112, 224, 225, 98, 165, 86, 180, 31, 32, 249, 202, 127, 244, 142, 127, 17, 239, 16, 41, 1, 191, 113, 134, 18, 66, 251, 227, 254, 73, 53, 180, 104, 27, 133, 32, 198, 218, 159, 226, 32, 79, 136, 115, 52, 110, 242, 239, 204, 109, 154, 29, 180, 85, 142, 244, 160, 90, 14, 37, 236, 159, 130, 229, 169, 11, 37, 132, 37, 49, 124, 225, 206, 164, 202, 94, 34, 8, 5, 49, 56, 17, 171, 65, 211, 126, 42, 109, 62, 176, 132, 107, 62, 190, 141, 214, 11, 217, 6, 52, 198, 157, 181, 22, 107, 245, 249, 222, 4, 71, 63, 54, 104, 23, 171, 180, 131, 16, 230, 23, 94, 39, 61, 149, 204, 15, 42, 7, 187, 147, 37, 55, 67, 188, 147, 194, 254, 154, 193, 95, 227, 162, 216, 3, 127, 116, 248, 115, 121, 126, 176, 253, 175, 7, 245, 175, 129, 254, 70, 151, 36, 174, 235, 172, 158, 244, 206, 119, 184, 231, 1, 14, 162, 152, 159, 97, 136, 82, 216, 75, 161, 36, 208, 59, 62, 13, 12, 35, 82, 236] +csc_pubkey_redc_param = [85, 174, 126, 117, 33, 220, 72, 0, 109, 30, 197, 185, 103, 14, 48, 128, 1, 71, 50, 56, 40, 168, 230, 184, 224, 196, 82, 184, 162, 160, 53, 185, 220, 250, 11, 57, 198, 14, 141, 23, 98, 80, 210, 165, 146, 5, 203, 252, 187, 156, 244, 57, 67, 46, 33, 120, 203, 8, 133, 252, 82, 131, 169, 28, 83, 36, 35, 159, 124, 3, 0, 154, 43, 162, 241, 149, 17, 157, 153, 68, 109, 56, 149, 128, 46, 28, 244, 50, 120, 150, 55, 94, 92, 102, 194, 28, 166, 22, 141, 199, 118, 134, 191, 136, 37, 199, 243, 151, 188, 192, 222, 136, 134, 203, 129, 120, 74, 135, 114, 234, 140, 42, 21, 85, 253, 41, 125, 43, 2, 145, 23, 177, 229, 127, 129, 206, 214, 166, 113, 230, 134, 209, 252, 244, 105, 197, 4, 143, 197, 93, 14, 96, 162, 128, 118, 251, 229, 222, 200, 161, 143, 27, 121, 154, 137, 18, 42, 167, 183, 7, 30, 94, 125, 65, 216, 82, 53, 135, 129, 51, 80, 117, 67, 184, 131, 170, 178, 94, 54, 27, 142, 196, 245, 168, 37, 167, 10, 87, 162, 174, 150, 31, 208, 99, 91, 84, 113, 205, 17, 46, 131, 26, 5, 39, 184, 236, 236, 16, 181, 151, 175, 115, 131, 128, 21, 48, 55, 106, 38, 246, 184, 208, 155, 3, 213, 254, 41, 69, 131, 254, 137, 220, 179, 75, 221, 9, 140, 15, 41, 184, 106, 184, 110, 116, 61, 85, 69, 206, 136, 143, 101, 37, 82, 47, 27, 59, 53, 119, 119, 62, 217, 248, 83, 78, 200, 95, 161, 127, 247, 243, 251, 78, 62, 86, 9, 153, 20, 191, 154, 52, 93, 174, 80, 141, 137, 85, 137, 191, 185, 86, 81, 191, 237, 79, 113, 98, 113, 68, 111, 16, 32, 21, 11, 97, 188, 15, 139, 81, 66, 92, 154, 146, 178, 245, 195, 131, 133, 138, 149, 90, 208, 124, 131, 231, 41, 255, 210, 57, 252, 71, 188, 64, 164, 6, 253, 198, 24, 73, 11, 239, 143, 249, 36, 214, 209, 160, 110, 20, 131, 27, 106, 127, 136, 129, 62, 33, 204, 209, 187, 203, 191, 49, 182, 104, 118, 209, 86, 59, 210, 129, 104, 56, 151, 178, 126, 11, 150, 164, 44, 150, 16, 148, 197, 243, 135, 58, 147, 41, 120, 136, 32, 20, 196, 224, 70, 173, 7, 77, 248, 169, 180, 250, 194, 17, 172, 250, 250, 55, 88, 47, 100, 24, 211, 26, 118, 212, 89, 175, 215, 231, 120, 17, 28, 252, 217, 160, 94, 174, 210, 12, 67, 152, 93, 120, 156, 246, 87, 48, 60, 168, 30, 238, 76, 148, 221, 14, 242, 79, 11, 250, 107, 5, 127, 142, 139, 96, 13, 253, 211, 225, 205, 229, 250, 195, 246, 188, 31, 214, 190, 7, 249, 26, 92, 146, 187, 174, 178, 123, 211, 57, 222, 227, 156, 4, 58, 138, 98, 125, 134, 33, 75, 97, 46, 132, 147, 64, 236, 248, 52, 48, 141, 75, 176] dsc_signature = [1, 90, 47, 176, 125, 161, 115, 42, 228, 134, 123, 122, 5, 10, 192, 251, 21, 176, 234, 130, 181, 159, 129, 112, 177, 142, 115, 49, 83, 162, 150, 234, 133, 233, 115, 90, 20, 113, 84, 60, 187, 88, 115, 7, 236, 156, 43, 41, 97, 196, 158, 176, 156, 61, 214, 171, 84, 234, 120, 38, 152, 93, 137, 186, 244, 89, 139, 161, 114, 156, 16, 105, 104, 254, 128, 219, 168, 148, 238, 79, 117, 131, 9, 121, 107, 114, 88, 246, 52, 220, 17, 114, 106, 6, 103, 56, 105, 75, 39, 120, 64, 136, 237, 83, 122, 147, 231, 96, 120, 145, 199, 203, 17, 76, 243, 108, 145, 6, 53, 178, 217, 197, 42, 29, 45, 166, 18, 163, 37, 198, 170, 204, 246, 145, 28, 88, 220, 217, 127, 129, 200, 243, 202, 201, 100, 203, 21, 26, 82, 136, 221, 195, 134, 115, 215, 35, 122, 92, 11, 126, 239, 123, 69, 103, 185, 5, 53, 172, 70, 105, 92, 242, 116, 163, 110, 14, 150, 211, 129, 135, 95, 219, 68, 18, 205, 169, 48, 179, 202, 174, 150, 37, 254, 211, 150, 59, 44, 172, 4, 87, 133, 57, 206, 135, 138, 187, 101, 245, 146, 151, 9, 54, 228, 40, 0, 245, 140, 211, 134, 38, 50, 174, 82, 124, 107, 54, 255, 30, 31, 40, 201, 20, 119, 75, 74, 242, 187, 44, 218, 182, 218, 185, 153, 221, 170, 2, 145, 206, 75, 46, 206, 164, 0, 219, 171, 204, 169, 20, 212, 145, 93, 26, 101, 101, 222, 26, 93, 215, 141, 207, 218, 178, 94, 14, 54, 2, 45, 172, 249, 227, 172, 222, 105, 152, 120, 121, 246, 138, 144, 112, 123, 60, 250, 244, 40, 29, 247, 190, 99, 79, 54, 0, 240, 119, 110, 230, 129, 88, 95, 219, 196, 159, 249, 48, 236, 220, 232, 3, 177, 8, 34, 210, 101, 147, 135, 161, 82, 125, 47, 216, 138, 186, 108, 74, 178, 129, 57, 227, 132, 49, 251, 45, 248, 119, 44, 147, 173, 178, 29, 150, 89, 241, 165, 37, 22, 157, 75, 225, 2, 237, 3, 55, 220, 104, 206, 8, 164, 37, 217, 22, 186, 239, 230, 194, 49, 93, 213, 191, 141, 79, 207, 181, 221, 34, 59, 234, 173, 228, 10, 146, 250, 117, 36, 188, 147, 234, 126, 79, 165, 228, 43, 95, 202, 48, 170, 84, 5, 91, 7, 230, 92, 108, 44, 198, 200, 156, 24, 203, 65, 68, 120, 65, 209, 200, 217, 182, 140, 39, 101, 245, 218, 21, 193, 169, 153, 47, 112, 164, 252, 99, 62, 99, 201, 25, 13, 103, 97, 59, 198, 7, 193, 40, 148, 201, 184, 75, 25, 98, 54, 243, 239, 7, 2, 15, 30, 104, 73, 40, 61, 149, 233, 207, 151, 75, 135, 0, 108, 124, 158, 9, 14, 134, 151, 82, 138, 235, 199, 127, 184, 140, 178, 172, 224, 252, 94, 15, 254, 128, 230, 69, 139, 195, 122, 107, 172, 243, 151, 38, 66, 196, 210, 123] exponent = 65537 salt_out = "0x2" \ No newline at end of file diff --git a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_id_data_1300.toml b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_id_data_1300.toml index dc1b77129..bd04c8eeb 100644 --- a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_id_data_1300.toml +++ b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_1300/t_add_id_data_1300.toml @@ -3,7 +3,7 @@ salt_in = "0x2" salt_out = "0x3" dg1 = [97, 91, 95, 31, 88, 80, 60, 85, 84, 79, 68, 79, 69, 60, 60, 74, 79, 72, 78, 60, 77, 79, 67, 75, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 76, 56, 57, 56, 57, 48, 50, 67, 51, 54, 85, 84, 79, 48, 55, 48, 49, 48, 49, 57, 77, 51, 50, 48, 49, 48, 49, 53, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 48, 56, 0, 0] dsc_pubkey = [144, 96, 22, 98, 202, 23, 238, 6, 187, 83, 246, 10, 141, 149, 39, 62, 150, 207, 25, 76, 254, 121, 159, 193, 25, 17, 64, 229, 112, 170, 152, 94, 212, 213, 4, 191, 8, 183, 225, 184, 213, 181, 211, 100, 210, 60, 155, 26, 13, 219, 11, 116, 84, 236, 33, 212, 47, 5, 187, 226, 120, 161, 57, 97, 200, 250, 174, 139, 216, 171, 95, 178, 148, 109, 3, 137, 151, 245, 142, 53, 177, 251, 74, 202, 2, 157, 33, 55, 30, 189, 239, 243, 101, 183, 43, 68, 245, 198, 9, 90, 109, 89, 109, 33, 98, 32, 173, 121, 203, 2, 79, 68, 150, 135, 158, 72, 76, 223, 55, 66, 30, 45, 33, 16, 91, 153, 158, 127, 64, 221, 31, 151, 241, 93, 105, 235, 153, 176, 146, 221, 20, 231, 141, 2, 146, 77, 209, 30, 90, 33, 33, 232, 176, 145, 244, 229, 221, 43, 101, 10, 210, 55, 50, 200, 103, 87, 18, 82, 53, 193, 130, 124, 69, 96, 179, 87, 245, 203, 181, 205, 57, 67, 181, 80, 198, 57, 101, 151, 179, 103, 201, 243, 52, 68, 91, 122, 137, 209, 141, 39, 68, 73, 244, 200, 211, 125, 2, 176, 12, 80, 77, 81, 225, 169, 34, 209, 187, 212, 47, 56, 92, 220, 159, 89, 236, 133, 200, 211, 11, 237, 217, 129, 115, 191, 208, 39, 198, 179, 16, 28, 59, 121, 160, 48, 239, 81, 144, 102, 168, 122, 158, 59, 83, 54, 91, 211] -dsc_pubkey_redc_param = [28, 94, 216, 205, 130, 214, 187, 182, 58, 208, 228, 159, 128, 141, 147, 245, 68, 203, 236, 129, 99, 140, 108, 211, 245, 198, 71, 176, 2, 196, 241, 58, 221, 37, 54, 244, 93, 131, 148, 193, 87, 121, 38, 188, 142, 196, 4, 105, 26, 37, 150, 148, 152, 205, 235, 126, 184, 93, 105, 56, 44, 19, 57, 156, 74, 145, 52, 201, 54, 91, 218, 1, 26, 107, 219, 199, 28, 10, 57, 32, 22, 195, 131, 58, 46, 165, 57, 181, 53, 133, 182, 229, 180, 5, 229, 103, 172, 187, 96, 43, 14, 4, 151, 199, 136, 53, 224, 199, 167, 81, 240, 180, 174, 254, 87, 255, 239, 218, 1, 170, 8, 126, 189, 0, 83, 125, 173, 191, 84, 53, 29, 80, 88, 48, 59, 50, 243, 156, 221, 1, 81, 7, 140, 195, 28, 126, 195, 88, 226, 224, 141, 129, 220, 242, 189, 217, 16, 44, 163, 154, 247, 61, 237, 213, 56, 204, 14, 199, 251, 110, 139, 117, 142, 16, 234, 116, 47, 82, 226, 88, 40, 15, 104, 74, 12, 48, 224, 229, 64, 4, 157, 1, 124, 203, 51, 181, 191, 194, 149, 113, 225, 34, 173, 236, 206, 22, 80, 189, 181, 158, 100, 248, 60, 60, 68, 157, 169, 68, 26, 229, 226, 151, 181, 39, 197, 51, 51, 171, 197, 130, 196, 219, 115, 145, 84, 69, 157, 247, 71, 141, 198, 109, 219, 255, 149, 228, 19, 23, 56, 175, 123, 107, 192, 219, 175, 130, 60] +dsc_pubkey_redc_param = [113, 123, 99, 54, 11, 90, 238, 216, 235, 67, 146, 126, 2, 54, 79, 213, 19, 47, 178, 5, 142, 49, 179, 79, 215, 25, 30, 192, 11, 19, 196, 235, 116, 148, 219, 209, 118, 14, 83, 5, 93, 228, 154, 242, 59, 16, 17, 164, 104, 150, 90, 82, 99, 55, 173, 250, 225, 117, 164, 224, 176, 76, 230, 113, 42, 68, 211, 36, 217, 111, 104, 4, 105, 175, 111, 28, 112, 40, 228, 128, 91, 14, 12, 232, 186, 148, 230, 212, 214, 22, 219, 150, 208, 23, 149, 158, 178, 237, 128, 172, 56, 18, 95, 30, 32, 215, 131, 30, 157, 71, 194, 210, 187, 249, 95, 255, 191, 104, 6, 168, 33, 250, 244, 1, 77, 246, 182, 253, 80, 212, 117, 65, 96, 192, 236, 203, 206, 115, 116, 5, 68, 30, 51, 12, 113, 251, 13, 99, 139, 130, 54, 7, 115, 202, 247, 100, 64, 178, 142, 107, 220, 247, 183, 84, 227, 48, 59, 31, 237, 186, 45, 214, 56, 67, 169, 208, 189, 75, 137, 96, 160, 61, 161, 40, 48, 195, 131, 149, 0, 18, 116, 5, 243, 44, 206, 214, 255, 10, 85, 199, 132, 138, 183, 179, 56, 89, 66, 246, 214, 121, 147, 224, 240, 241, 18, 118, 165, 16, 107, 151, 138, 94, 212, 159, 20, 204, 206, 175, 22, 11, 19, 109, 206, 69, 81, 22, 119, 221, 30, 55, 25, 183, 111, 254, 87, 144, 76, 92, 226, 189, 237, 175, 3, 110, 190, 8, 243] dsc_pubkey_offset_in_dsc_cert = 229 exponent_offset_in_dsc_cert = 487 sod_signature = [55, 125, 38, 168, 223, 78, 57, 118, 228, 58, 135, 97, 165, 230, 168, 0, 91, 69, 158, 155, 110, 40, 239, 57, 178, 211, 54, 96, 253, 10, 240, 107, 184, 122, 27, 253, 124, 73, 89, 217, 97, 144, 99, 173, 170, 199, 64, 96, 11, 143, 50, 90, 234, 133, 108, 224, 104, 98, 171, 85, 251, 138, 248, 6, 241, 193, 212, 242, 58, 208, 107, 18, 239, 246, 157, 218, 85, 217, 68, 118, 211, 205, 230, 40, 68, 3, 2, 171, 231, 247, 10, 101, 21, 250, 17, 217, 56, 254, 79, 109, 61, 190, 241, 168, 231, 49, 118, 0, 114, 237, 216, 227, 110, 117, 137, 176, 223, 146, 29, 1, 172, 234, 23, 186, 203, 18, 188, 210, 42, 156, 133, 107, 124, 3, 244, 173, 53, 85, 75, 225, 4, 106, 118, 111, 35, 16, 133, 227, 31, 148, 60, 113, 230, 201, 147, 83, 236, 179, 245, 84, 84, 144, 62, 29, 198, 38, 19, 237, 145, 183, 6, 72, 247, 172, 73, 108, 87, 50, 128, 85, 152, 180, 222, 24, 88, 18, 149, 23, 217, 196, 219, 198, 93, 53, 3, 189, 190, 34, 221, 60, 73, 108, 54, 42, 162, 49, 195, 65, 119, 194, 214, 101, 35, 101, 247, 27, 29, 143, 169, 47, 249, 107, 101, 202, 185, 231, 48, 223, 63, 20, 164, 24, 38, 103, 147, 80, 168, 152, 159, 186, 58, 107, 188, 155, 29, 221, 45, 107, 173, 106, 69, 98, 155, 39, 194, 22] diff --git a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_dsc_720.toml b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_dsc_720.toml index 995956008..e817a9766 100644 --- a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_dsc_720.toml +++ b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_dsc_720.toml @@ -3,7 +3,7 @@ csc_key_ne_hash = "0x1ca4af41d370d02b729b6a63b4aea3cf29242ad76ac8420c144d7558072 salt = "0x2" country = "UTO" tbs_certificate = [48, 130, 2, 54, 160, 3, 2, 1, 2, 2, 1, 2, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 11, 5, 0, 48, 67, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 84, 49, 32, 48, 30, 6, 3, 85, 4, 10, 12, 23, 77, 111, 99, 107, 32, 80, 97, 115, 115, 112, 111, 114, 116, 32, 65, 117, 116, 104, 111, 114, 105, 116, 121, 49, 18, 48, 16, 6, 3, 85, 4, 3, 12, 9, 77, 111, 99, 107, 32, 67, 83, 67, 65, 48, 30, 23, 13, 50, 49, 48, 51, 50, 54, 49, 51, 53, 52, 49, 56, 90, 23, 13, 51, 49, 48, 51, 50, 52, 49, 51, 53, 52, 49, 56, 90, 48, 66, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 85, 84, 49, 32, 48, 30, 6, 3, 85, 4, 10, 12, 23, 77, 111, 99, 107, 32, 80, 97, 115, 115, 112, 111, 114, 116, 32, 65, 117, 116, 104, 111, 114, 105, 116, 121, 49, 17, 48, 15, 6, 3, 85, 4, 3, 12, 8, 77, 111, 99, 107, 32, 68, 83, 67, 48, 130, 1, 34, 48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0, 3, 130, 1, 15, 0, 48, 130, 1, 10, 2, 130, 1, 1, 0, 144, 96, 22, 98, 202, 23, 238, 6, 187, 83, 246, 10, 141, 149, 39, 62, 150, 207, 25, 76, 254, 121, 159, 193, 25, 17, 64, 229, 112, 170, 152, 94, 212, 213, 4, 191, 8, 183, 225, 184, 213, 181, 211, 100, 210, 60, 155, 26, 13, 219, 11, 116, 84, 236, 33, 212, 47, 5, 187, 226, 120, 161, 57, 97, 200, 250, 174, 139, 216, 171, 95, 178, 148, 109, 3, 137, 151, 245, 142, 53, 177, 251, 74, 202, 2, 157, 33, 55, 30, 189, 239, 243, 101, 183, 43, 68, 245, 198, 9, 90, 109, 89, 109, 33, 98, 32, 173, 121, 203, 2, 79, 68, 150, 135, 158, 72, 76, 223, 55, 66, 30, 45, 33, 16, 91, 153, 158, 127, 64, 221, 31, 151, 241, 93, 105, 235, 153, 176, 146, 221, 20, 231, 141, 2, 146, 77, 209, 30, 90, 33, 33, 232, 176, 145, 244, 229, 221, 43, 101, 10, 210, 55, 50, 200, 103, 87, 18, 82, 53, 193, 130, 124, 69, 96, 179, 87, 245, 203, 181, 205, 57, 67, 181, 80, 198, 57, 101, 151, 179, 103, 201, 243, 52, 68, 91, 122, 137, 209, 141, 39, 68, 73, 244, 200, 211, 125, 2, 176, 12, 80, 77, 81, 225, 169, 34, 209, 187, 212, 47, 56, 92, 220, 159, 89, 236, 133, 200, 211, 11, 237, 217, 129, 115, 191, 208, 39, 198, 179, 16, 28, 59, 121, 160, 48, 239, 81, 144, 102, 168, 122, 158, 59, 83, 54, 91, 211, 2, 3, 1, 0, 1, 163, 78, 48, 76, 48, 15, 6, 3, 85, 29, 19, 1, 1, 255, 4, 5, 48, 3, 1, 1, 0, 48, 14, 6, 3, 85, 29, 15, 1, 1, 255, 4, 4, 3, 2, 7, 128, 48, 41, 6, 3, 85, 29, 14, 4, 34, 4, 32, 236, 115, 196, 36, 236, 2, 138, 16, 34, 153, 224, 23, 230, 87, 56, 253, 158, 235, 14, 147, 38, 52, 87, 5, 72, 19, 213, 247, 131, 38, 127, 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -csc_pubkey_redc_param = [21, 107, 159, 157, 72, 119, 18, 0, 27, 71, 177, 110, 89, 195, 140, 32, 0, 81, 204, 142, 10, 42, 57, 174, 56, 49, 20, 174, 40, 168, 13, 110, 119, 62, 130, 206, 113, 131, 163, 69, 216, 148, 52, 169, 100, 129, 114, 255, 46, 231, 61, 14, 80, 203, 136, 94, 50, 194, 33, 127, 20, 160, 234, 71, 20, 201, 8, 231, 223, 0, 192, 38, 138, 232, 188, 101, 68, 103, 102, 81, 27, 78, 37, 96, 11, 135, 61, 12, 158, 37, 141, 215, 151, 25, 176, 135, 41, 133, 163, 113, 221, 161, 175, 226, 9, 113, 252, 229, 239, 48, 55, 162, 33, 178, 224, 94, 18, 161, 220, 186, 163, 10, 133, 85, 127, 74, 95, 74, 192, 164, 69, 236, 121, 95, 224, 115, 181, 169, 156, 121, 161, 180, 127, 61, 26, 113, 65, 35, 241, 87, 67, 152, 40, 160, 29, 190, 249, 119, 178, 40, 99, 198, 222, 102, 162, 68, 138, 169, 237, 193, 199, 151, 159, 80, 118, 20, 141, 97, 224, 76, 212, 29, 80, 238, 32, 234, 172, 151, 141, 134, 227, 177, 61, 106, 9, 105, 194, 149, 232, 171, 165, 135, 244, 24, 214, 213, 28, 115, 68, 75, 160, 198, 129, 73, 238, 59, 59, 4, 45, 101, 235, 220, 224, 224, 5, 76, 13, 218, 137, 189, 174, 52, 38, 192, 245, 127, 138, 81, 96, 255, 162, 119, 44, 210, 247, 66, 99, 3, 202, 110, 26, 174, 27, 157, 15, 85, 81, 115, 162, 35, 217, 73, 84, 139, 198, 206, 205, 93, 221, 207, 182, 126, 20, 211, 178, 23, 232, 95, 253, 252, 254, 211, 143, 149, 130, 102, 69, 47, 230, 141, 23, 107, 148, 35, 98, 85, 98, 111, 238, 85, 148, 111, 251, 83, 220, 88, 156, 81, 27, 196, 8, 5, 66, 216, 111, 3, 226, 212, 80, 151, 38, 164, 172, 189, 112, 224, 225, 98, 165, 86, 180, 31, 32, 249, 202, 127, 244, 142, 127, 17, 239, 16, 41, 1, 191, 113, 134, 18, 66, 251, 227, 254, 73, 53, 180, 104, 27, 133, 32, 198, 218, 159, 226, 32, 79, 136, 115, 52, 110, 242, 239, 204, 109, 154, 29, 180, 85, 142, 244, 160, 90, 14, 37, 236, 159, 130, 229, 169, 11, 37, 132, 37, 49, 124, 225, 206, 164, 202, 94, 34, 8, 5, 49, 56, 17, 171, 65, 211, 126, 42, 109, 62, 176, 132, 107, 62, 190, 141, 214, 11, 217, 6, 52, 198, 157, 181, 22, 107, 245, 249, 222, 4, 71, 63, 54, 104, 23, 171, 180, 131, 16, 230, 23, 94, 39, 61, 149, 204, 15, 42, 7, 187, 147, 37, 55, 67, 188, 147, 194, 254, 154, 193, 95, 227, 162, 216, 3, 127, 116, 248, 115, 121, 126, 176, 253, 175, 7, 245, 175, 129, 254, 70, 151, 36, 174, 235, 172, 158, 244, 206, 119, 184, 231, 1, 14, 162, 152, 159, 97, 136, 82, 216, 75, 161, 36, 208, 59, 62, 13, 12, 35, 82, 236] +csc_pubkey_redc_param = [85, 174, 126, 117, 33, 220, 72, 0, 109, 30, 197, 185, 103, 14, 48, 128, 1, 71, 50, 56, 40, 168, 230, 184, 224, 196, 82, 184, 162, 160, 53, 185, 220, 250, 11, 57, 198, 14, 141, 23, 98, 80, 210, 165, 146, 5, 203, 252, 187, 156, 244, 57, 67, 46, 33, 120, 203, 8, 133, 252, 82, 131, 169, 28, 83, 36, 35, 159, 124, 3, 0, 154, 43, 162, 241, 149, 17, 157, 153, 68, 109, 56, 149, 128, 46, 28, 244, 50, 120, 150, 55, 94, 92, 102, 194, 28, 166, 22, 141, 199, 118, 134, 191, 136, 37, 199, 243, 151, 188, 192, 222, 136, 134, 203, 129, 120, 74, 135, 114, 234, 140, 42, 21, 85, 253, 41, 125, 43, 2, 145, 23, 177, 229, 127, 129, 206, 214, 166, 113, 230, 134, 209, 252, 244, 105, 197, 4, 143, 197, 93, 14, 96, 162, 128, 118, 251, 229, 222, 200, 161, 143, 27, 121, 154, 137, 18, 42, 167, 183, 7, 30, 94, 125, 65, 216, 82, 53, 135, 129, 51, 80, 117, 67, 184, 131, 170, 178, 94, 54, 27, 142, 196, 245, 168, 37, 167, 10, 87, 162, 174, 150, 31, 208, 99, 91, 84, 113, 205, 17, 46, 131, 26, 5, 39, 184, 236, 236, 16, 181, 151, 175, 115, 131, 128, 21, 48, 55, 106, 38, 246, 184, 208, 155, 3, 213, 254, 41, 69, 131, 254, 137, 220, 179, 75, 221, 9, 140, 15, 41, 184, 106, 184, 110, 116, 61, 85, 69, 206, 136, 143, 101, 37, 82, 47, 27, 59, 53, 119, 119, 62, 217, 248, 83, 78, 200, 95, 161, 127, 247, 243, 251, 78, 62, 86, 9, 153, 20, 191, 154, 52, 93, 174, 80, 141, 137, 85, 137, 191, 185, 86, 81, 191, 237, 79, 113, 98, 113, 68, 111, 16, 32, 21, 11, 97, 188, 15, 139, 81, 66, 92, 154, 146, 178, 245, 195, 131, 133, 138, 149, 90, 208, 124, 131, 231, 41, 255, 210, 57, 252, 71, 188, 64, 164, 6, 253, 198, 24, 73, 11, 239, 143, 249, 36, 214, 209, 160, 110, 20, 131, 27, 106, 127, 136, 129, 62, 33, 204, 209, 187, 203, 191, 49, 182, 104, 118, 209, 86, 59, 210, 129, 104, 56, 151, 178, 126, 11, 150, 164, 44, 150, 16, 148, 197, 243, 135, 58, 147, 41, 120, 136, 32, 20, 196, 224, 70, 173, 7, 77, 248, 169, 180, 250, 194, 17, 172, 250, 250, 55, 88, 47, 100, 24, 211, 26, 118, 212, 89, 175, 215, 231, 120, 17, 28, 252, 217, 160, 94, 174, 210, 12, 67, 152, 93, 120, 156, 246, 87, 48, 60, 168, 30, 238, 76, 148, 221, 14, 242, 79, 11, 250, 107, 5, 127, 142, 139, 96, 13, 253, 211, 225, 205, 229, 250, 195, 246, 188, 31, 214, 190, 7, 249, 26, 92, 146, 187, 174, 178, 123, 211, 57, 222, 227, 156, 4, 58, 138, 98, 125, 134, 33, 75, 97, 46, 132, 147, 64, 236, 248, 52, 48, 141, 75, 176] dsc_signature = [169, 42, 245, 251, 152, 33, 198, 125, 189, 117, 149, 90, 241, 101, 47, 107, 181, 214, 135, 197, 190, 87, 41, 132, 13, 13, 229, 24, 50, 69, 107, 110, 96, 187, 25, 255, 239, 191, 119, 183, 222, 27, 253, 249, 206, 136, 163, 219, 239, 172, 234, 113, 51, 126, 12, 10, 149, 204, 190, 228, 114, 168, 122, 60, 145, 26, 71, 80, 146, 216, 159, 114, 116, 88, 216, 83, 9, 71, 153, 115, 143, 11, 248, 141, 66, 132, 223, 42, 96, 25, 14, 77, 180, 82, 168, 237, 218, 211, 4, 242, 47, 229, 15, 248, 188, 41, 165, 58, 135, 172, 69, 220, 187, 34, 57, 183, 1, 238, 137, 17, 123, 17, 8, 96, 188, 99, 94, 176, 175, 217, 113, 187, 61, 192, 225, 146, 10, 65, 87, 54, 165, 129, 189, 17, 29, 46, 200, 232, 214, 79, 156, 181, 37, 24, 135, 191, 3, 115, 81, 225, 50, 41, 12, 202, 44, 86, 22, 118, 228, 72, 251, 24, 78, 202, 218, 71, 78, 101, 120, 238, 206, 86, 14, 129, 178, 211, 38, 84, 127, 106, 19, 118, 128, 66, 126, 193, 72, 162, 130, 152, 151, 3, 123, 122, 77, 149, 236, 170, 240, 99, 106, 59, 252, 176, 56, 139, 119, 12, 212, 130, 112, 124, 95, 34, 195, 84, 212, 60, 44, 30, 67, 225, 252, 121, 148, 105, 151, 38, 174, 187, 138, 60, 246, 67, 223, 52, 245, 245, 3, 168, 90, 53, 170, 49, 33, 117, 177, 200, 156, 203, 149, 17, 84, 139, 50, 110, 39, 83, 156, 245, 128, 145, 71, 184, 125, 100, 88, 221, 21, 10, 235, 93, 227, 156, 131, 10, 69, 202, 217, 188, 213, 80, 128, 14, 76, 17, 178, 39, 105, 155, 139, 180, 80, 84, 137, 103, 217, 87, 221, 155, 111, 245, 133, 253, 54, 84, 62, 79, 184, 210, 233, 206, 77, 202, 36, 137, 126, 231, 171, 182, 52, 226, 127, 205, 232, 187, 36, 52, 39, 194, 42, 93, 224, 205, 123, 162, 5, 181, 168, 113, 37, 22, 122, 48, 48, 121, 5, 14, 220, 181, 246, 68, 240, 222, 40, 46, 161, 244, 167, 121, 105, 60, 95, 233, 25, 168, 174, 31, 124, 89, 40, 95, 19, 188, 221, 212, 225, 228, 51, 137, 2, 170, 190, 66, 236, 133, 80, 130, 59, 159, 151, 234, 49, 43, 155, 253, 137, 101, 175, 254, 10, 146, 203, 190, 234, 30, 247, 81, 97, 108, 22, 19, 176, 5, 7, 55, 146, 221, 177, 161, 128, 96, 70, 168, 1, 164, 146, 17, 75, 84, 123, 45, 246, 75, 147, 119, 251, 70, 128, 30, 237, 242, 17, 111, 139, 187, 32, 228, 36, 196, 226, 133, 120, 254, 62, 145, 120, 13, 97, 171, 152, 77, 100, 122, 47, 101, 100, 206, 101, 30, 75, 118, 115, 39, 79, 108, 222, 47, 167, 161, 234, 160, 180, 114, 6, 161, 205, 107, 242, 191, 178, 177, 196, 6, 106, 228, 62, 34, 177, 85, 129, 223] exponent = 65537 tbs_certificate_len = 570 diff --git a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_id_data_720.toml b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_id_data_720.toml index 286711b2c..f75cfa27e 100644 --- a/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_id_data_720.toml +++ b/noir-examples/noir-passport/merkle_age_check/benchmark-inputs/tbs_720/t_add_id_data_720.toml @@ -3,7 +3,7 @@ salt_in = "0x2" salt_out = "0x3" dg1 = [97, 91, 95, 31, 88, 80, 60, 85, 84, 79, 68, 79, 69, 60, 60, 74, 79, 72, 78, 60, 77, 79, 67, 75, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 76, 56, 57, 56, 57, 48, 50, 67, 51, 54, 85, 84, 79, 48, 55, 48, 49, 48, 49, 57, 77, 51, 50, 48, 49, 48, 49, 53, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 48, 56, 0, 0] dsc_pubkey = [144, 96, 22, 98, 202, 23, 238, 6, 187, 83, 246, 10, 141, 149, 39, 62, 150, 207, 25, 76, 254, 121, 159, 193, 25, 17, 64, 229, 112, 170, 152, 94, 212, 213, 4, 191, 8, 183, 225, 184, 213, 181, 211, 100, 210, 60, 155, 26, 13, 219, 11, 116, 84, 236, 33, 212, 47, 5, 187, 226, 120, 161, 57, 97, 200, 250, 174, 139, 216, 171, 95, 178, 148, 109, 3, 137, 151, 245, 142, 53, 177, 251, 74, 202, 2, 157, 33, 55, 30, 189, 239, 243, 101, 183, 43, 68, 245, 198, 9, 90, 109, 89, 109, 33, 98, 32, 173, 121, 203, 2, 79, 68, 150, 135, 158, 72, 76, 223, 55, 66, 30, 45, 33, 16, 91, 153, 158, 127, 64, 221, 31, 151, 241, 93, 105, 235, 153, 176, 146, 221, 20, 231, 141, 2, 146, 77, 209, 30, 90, 33, 33, 232, 176, 145, 244, 229, 221, 43, 101, 10, 210, 55, 50, 200, 103, 87, 18, 82, 53, 193, 130, 124, 69, 96, 179, 87, 245, 203, 181, 205, 57, 67, 181, 80, 198, 57, 101, 151, 179, 103, 201, 243, 52, 68, 91, 122, 137, 209, 141, 39, 68, 73, 244, 200, 211, 125, 2, 176, 12, 80, 77, 81, 225, 169, 34, 209, 187, 212, 47, 56, 92, 220, 159, 89, 236, 133, 200, 211, 11, 237, 217, 129, 115, 191, 208, 39, 198, 179, 16, 28, 59, 121, 160, 48, 239, 81, 144, 102, 168, 122, 158, 59, 83, 54, 91, 211] -dsc_pubkey_redc_param = [28, 94, 216, 205, 130, 214, 187, 182, 58, 208, 228, 159, 128, 141, 147, 245, 68, 203, 236, 129, 99, 140, 108, 211, 245, 198, 71, 176, 2, 196, 241, 58, 221, 37, 54, 244, 93, 131, 148, 193, 87, 121, 38, 188, 142, 196, 4, 105, 26, 37, 150, 148, 152, 205, 235, 126, 184, 93, 105, 56, 44, 19, 57, 156, 74, 145, 52, 201, 54, 91, 218, 1, 26, 107, 219, 199, 28, 10, 57, 32, 22, 195, 131, 58, 46, 165, 57, 181, 53, 133, 182, 229, 180, 5, 229, 103, 172, 187, 96, 43, 14, 4, 151, 199, 136, 53, 224, 199, 167, 81, 240, 180, 174, 254, 87, 255, 239, 218, 1, 170, 8, 126, 189, 0, 83, 125, 173, 191, 84, 53, 29, 80, 88, 48, 59, 50, 243, 156, 221, 1, 81, 7, 140, 195, 28, 126, 195, 88, 226, 224, 141, 129, 220, 242, 189, 217, 16, 44, 163, 154, 247, 61, 237, 213, 56, 204, 14, 199, 251, 110, 139, 117, 142, 16, 234, 116, 47, 82, 226, 88, 40, 15, 104, 74, 12, 48, 224, 229, 64, 4, 157, 1, 124, 203, 51, 181, 191, 194, 149, 113, 225, 34, 173, 236, 206, 22, 80, 189, 181, 158, 100, 248, 60, 60, 68, 157, 169, 68, 26, 229, 226, 151, 181, 39, 197, 51, 51, 171, 197, 130, 196, 219, 115, 145, 84, 69, 157, 247, 71, 141, 198, 109, 219, 255, 149, 228, 19, 23, 56, 175, 123, 107, 192, 219, 175, 130, 60] +dsc_pubkey_redc_param = [113, 123, 99, 54, 11, 90, 238, 216, 235, 67, 146, 126, 2, 54, 79, 213, 19, 47, 178, 5, 142, 49, 179, 79, 215, 25, 30, 192, 11, 19, 196, 235, 116, 148, 219, 209, 118, 14, 83, 5, 93, 228, 154, 242, 59, 16, 17, 164, 104, 150, 90, 82, 99, 55, 173, 250, 225, 117, 164, 224, 176, 76, 230, 113, 42, 68, 211, 36, 217, 111, 104, 4, 105, 175, 111, 28, 112, 40, 228, 128, 91, 14, 12, 232, 186, 148, 230, 212, 214, 22, 219, 150, 208, 23, 149, 158, 178, 237, 128, 172, 56, 18, 95, 30, 32, 215, 131, 30, 157, 71, 194, 210, 187, 249, 95, 255, 191, 104, 6, 168, 33, 250, 244, 1, 77, 246, 182, 253, 80, 212, 117, 65, 96, 192, 236, 203, 206, 115, 116, 5, 68, 30, 51, 12, 113, 251, 13, 99, 139, 130, 54, 7, 115, 202, 247, 100, 64, 178, 142, 107, 220, 247, 183, 84, 227, 48, 59, 31, 237, 186, 45, 214, 56, 67, 169, 208, 189, 75, 137, 96, 160, 61, 161, 40, 48, 195, 131, 149, 0, 18, 116, 5, 243, 44, 206, 214, 255, 10, 85, 199, 132, 138, 183, 179, 56, 89, 66, 246, 214, 121, 147, 224, 240, 241, 18, 118, 165, 16, 107, 151, 138, 94, 212, 159, 20, 204, 206, 175, 22, 11, 19, 109, 206, 69, 81, 22, 119, 221, 30, 55, 25, 183, 111, 254, 87, 144, 76, 92, 226, 189, 237, 175, 3, 110, 190, 8, 243] dsc_pubkey_offset_in_dsc_cert = 229 exponent_offset_in_dsc_cert = 487 sod_signature = [55, 125, 38, 168, 223, 78, 57, 118, 228, 58, 135, 97, 165, 230, 168, 0, 91, 69, 158, 155, 110, 40, 239, 57, 178, 211, 54, 96, 253, 10, 240, 107, 184, 122, 27, 253, 124, 73, 89, 217, 97, 144, 99, 173, 170, 199, 64, 96, 11, 143, 50, 90, 234, 133, 108, 224, 104, 98, 171, 85, 251, 138, 248, 6, 241, 193, 212, 242, 58, 208, 107, 18, 239, 246, 157, 218, 85, 217, 68, 118, 211, 205, 230, 40, 68, 3, 2, 171, 231, 247, 10, 101, 21, 250, 17, 217, 56, 254, 79, 109, 61, 190, 241, 168, 231, 49, 118, 0, 114, 237, 216, 227, 110, 117, 137, 176, 223, 146, 29, 1, 172, 234, 23, 186, 203, 18, 188, 210, 42, 156, 133, 107, 124, 3, 244, 173, 53, 85, 75, 225, 4, 106, 118, 111, 35, 16, 133, 227, 31, 148, 60, 113, 230, 201, 147, 83, 236, 179, 245, 84, 84, 144, 62, 29, 198, 38, 19, 237, 145, 183, 6, 72, 247, 172, 73, 108, 87, 50, 128, 85, 152, 180, 222, 24, 88, 18, 149, 23, 217, 196, 219, 198, 93, 53, 3, 189, 190, 34, 221, 60, 73, 108, 54, 42, 162, 49, 195, 65, 119, 194, 214, 101, 35, 101, 247, 27, 29, 143, 169, 47, 249, 107, 101, 202, 185, 231, 48, 223, 63, 20, 164, 24, 38, 103, 147, 80, 168, 152, 159, 186, 58, 107, 188, 155, 29, 221, 45, 107, 173, 106, 69, 98, 155, 39, 194, 22] diff --git a/noir-examples/noir-passport/merkle_age_check/t_add_dsc_720/Nargo.toml b/noir-examples/noir-passport/merkle_age_check/t_add_dsc_720/Nargo.toml index 4069a1a85..f900d19a1 100644 --- a/noir-examples/noir-passport/merkle_age_check/t_add_dsc_720/Nargo.toml +++ b/noir-examples/noir-passport/merkle_age_check/t_add_dsc_720/Nargo.toml @@ -7,4 +7,4 @@ compiler_version = ">=1.0.0" sig_check_rsa = { path = "../../utils/sig-check/rsa" } utils = { path = "../../utils/utils" } commitment = { path = "../../utils/commitment/common" } -poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" } +poseidon = { tag = "v0.3.0", git = "https://github.com/noir-lang/poseidon" } diff --git a/noir-examples/noir-passport/merkle_age_check/t_add_integrity_commit/Nargo.toml b/noir-examples/noir-passport/merkle_age_check/t_add_integrity_commit/Nargo.toml index df5f2a907..90ed3eef9 100644 --- a/noir-examples/noir-passport/merkle_age_check/t_add_integrity_commit/Nargo.toml +++ b/noir-examples/noir-passport/merkle_age_check/t_add_integrity_commit/Nargo.toml @@ -7,4 +7,4 @@ compiler_version = ">=1.0.0" data_check_integrity = { path = "../../utils/data-check/integrity" } common = { path = "../../utils/commitment/common" } utils = { path = "../../utils/utils" } -poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" } +poseidon = { tag = "v0.3.0", git = "https://github.com/noir-lang/poseidon" } diff --git a/noir-examples/noir-passport/merkle_age_check/t_attest/Nargo.toml b/noir-examples/noir-passport/merkle_age_check/t_attest/Nargo.toml index d25a5d50a..c354775fb 100644 --- a/noir-examples/noir-passport/merkle_age_check/t_attest/Nargo.toml +++ b/noir-examples/noir-passport/merkle_age_check/t_attest/Nargo.toml @@ -9,4 +9,4 @@ compare_age_lib = { path = "../../utils/compare/age" } data_check_expiry = { path = "../../utils/data-check/expiry" } scoped_nullifier = { path = "../../utils/commitment/scoped-nullifier" } utils = { path = "../../utils/utils" } -poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" } +poseidon = { tag = "v0.3.0", git = "https://github.com/noir-lang/poseidon" } diff --git a/noir-examples/noir-passport/utils/commitment/scoped-nullifier/Nargo.toml b/noir-examples/noir-passport/utils/commitment/scoped-nullifier/Nargo.toml index 11e7eddc9..cf75ee12a 100644 --- a/noir-examples/noir-passport/utils/commitment/scoped-nullifier/Nargo.toml +++ b/noir-examples/noir-passport/utils/commitment/scoped-nullifier/Nargo.toml @@ -6,4 +6,4 @@ compiler_version = ">=1.0.0" [dependencies] utils = { path = "../../utils" } -poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" } +poseidon = { tag = "v0.3.0", git = "https://github.com/noir-lang/poseidon" } diff --git a/noir-examples/noir-passport/utils/sig-check/common/Nargo.toml b/noir-examples/noir-passport/utils/sig-check/common/Nargo.toml index f397e9f43..ae2f6ea0a 100644 --- a/noir-examples/noir-passport/utils/sig-check/common/Nargo.toml +++ b/noir-examples/noir-passport/utils/sig-check/common/Nargo.toml @@ -6,6 +6,6 @@ compiler_version = ">=1.0.0" [dependencies] utils = { path = "../../utils" } -sha512 = { tag = "v0.1.1", git = "https://github.com/zkpassport/sha512" } +sha512 = { tag = "v0.2.0", git = "https://github.com/zkpassport/sha512" } sha256 = { tag = "v0.3.0", git = "https://github.com/noir-lang/sha256" } -sha1 = { tag = "v0.11", git = "https://github.com/zac-williamson/sha1" } \ No newline at end of file +sha1 = { tag = "v0.11", git = "https://github.com/zac-williamson/sha1" } diff --git a/noir-examples/noir-passport/utils/sig-check/rsa/Nargo.toml b/noir-examples/noir-passport/utils/sig-check/rsa/Nargo.toml index e4be7fd4f..84705495d 100644 --- a/noir-examples/noir-passport/utils/sig-check/rsa/Nargo.toml +++ b/noir-examples/noir-passport/utils/sig-check/rsa/Nargo.toml @@ -5,8 +5,8 @@ authors = ["Theo Madzou", "Michael Elliot"] compiler_version = ">=1.0.0" [dependencies] -rsa = { git = "https://github.com/zkpassport/noir_rsa", tag = "v0.10.0" } -bignum = { git = "https://github.com/noir-lang/noir-bignum", tag = "v0.9.2" } +rsa = { git = "https://github.com/zkpassport/noir_rsa", tag = "v0.11.0" } +bignum = { git = "https://github.com/noir-lang/noir-bignum", tag = "v0.10.0" } utils = { path = "../../utils" } common = { path = "../common" } -poseidon = { tag = "v0.1.1", git = "https://github.com/noir-lang/poseidon" } +poseidon = { tag = "v0.3.0", git = "https://github.com/noir-lang/poseidon" } diff --git a/noir-examples/p256_bigcurve/src/main.nr b/noir-examples/p256_bigcurve/src/main.nr index a6e25d439..4628196bc 100644 --- a/noir-examples/p256_bigcurve/src/main.nr +++ b/noir-examples/p256_bigcurve/src/main.nr @@ -4,13 +4,7 @@ use bigcurve::{ }; use bignum::BigNum; -fn main( - hashed_message: [u8; 32], - pub_key_x: [u8; 32], - pub_key_y: [u8; 32], - signature: [u8; 64], - r_point_y: [u8; 32], -) { +fn main(hashed_message: [u8; 32], pub_key_x: [u8; 32], pub_key_y: [u8; 32], signature: [u8; 64]) { let gen = Secp256r1::one(); let public = Secp256r1 { x: Secp256r1_Fq::from_be_bytes(pub_key_x), @@ -41,7 +35,5 @@ fn main( let s_p = Secp256r1Scalar::from_bignum(r / s); let r_point = Secp256r1::evaluate_linear_expression([gen, public], [s_g, s_p], []); - assert(!r_point.is_infinity); assert(r_point.x == r_x); - assert(r_point.y == Secp256r1_Fq::from_be_bytes(r_point_y)); }