Skip to content

update(idemix): hardening - #2136

Open
adecaro wants to merge 4 commits into
mainfrom
idemix-hardening
Open

update(idemix): hardening#2136
adecaro wants to merge 4 commits into
mainfrom
idemix-hardening

Conversation

@adecaro

@adecaro adecaro commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR introduces idemix hardening.

@adecaro adecaro added this to the Q3/26 milestone Aug 4, 2026
@adecaro adecaro self-assigned this Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

📊 Token Validation Benchmark

Comparison of this PR against the base branch. 🟢 improvement · 🔴 regression · ➖ within ±1.0% noise.

Variant Benchmark Params Workers TPS (base → PR) Δ TPS
csp BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 106 → 96 🔴 -8.7%
csp BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 135 → 123 🔴 -9.3%
ipa BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 78 → 72 🔴 -6.7%
ipa BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 68 → 64 🔴 -6.5%

@AkramBitar AkramBitar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adecaro

adecaro commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

waiting for IBM/idemix#89 to get merged

@adecaro adecaro mentioned this pull request Aug 11, 2026
@Effi-S Effi-S self-assigned this Aug 12, 2026
@LFDT-Panurus LFDT-Panurus deleted a comment from github-actions Bot Aug 12, 2026
@LFDT-Panurus LFDT-Panurus deleted a comment from github-actions Bot Aug 12, 2026
@github-actions

Copy link
Copy Markdown

📊 Token Validation Benchmark

Comparison of this PR against the base branch. 🟢 improvement · 🔴 regression · ➖ within ±1.0% noise.

Variant Benchmark Params Workers TPS (base → PR) Δ TPS
csp BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 118 → 107 🔴 -9.3%
csp BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 104 → 94 🔴 -9.4%
ipa BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 78 → 73 🔴 -6.6%
ipa BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 76 → 71 🔴 -6.8%

@Effi-S

Effi-S commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
image

See:
From: https://github.com/IBM/mathlib/blob/v0.3.1/driver/gurvy/bls12381/bls12-381.go#L259-L263

// Mul2 computes [e]g + [f]Q via a joint Strauss-Shamir scalar multiplication.
// Benchmarked against two independent Mul calls plus an Add: allocates far less
// (1 vs ~26 allocs) but is not faster in wall-clock time, because — unlike Mul —
// it does not use the GLV endomorphism speedup, so it forgoes the ~2x speedup that
// GLV gives each individual scalar multiplication.

@Effi-S

Effi-S commented Aug 12, 2026

Copy link
Copy Markdown
Contributor
image

@Effi-S

Effi-S commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Hi @adecaro,

Please see the full benchmarking results (Both CSP/IPA Client-Server Token Validation)
There is a clear degradation introduced by the newer mathlib version .

What do you think?

How do you want to proceed?

@Effi-S Effi-S removed their assignment Aug 12, 2026
@Effi-S
Effi-S requested a review from aaadir August 12, 2026 13:43
@aaadir

aaadir commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

"Token Validation Benchmark" also shows a performance degradation, so unless the new mathlib fixes some bugs - then why would we want to take it?

I also recall when working on the proof optimization that Claud claimed that mathlib (I guess that would be the current version) computed addition with 0 just like any other addition, rather than a trivial nop. This was one of the reasons why the optimization could exploit the 0-padded witness and field values. Now that the optimization is committed, I'm not sure there are many other places that would benefit from a trivial add-0, but may be worth an investigation.

@Effi-S Effi-S closed this Aug 19, 2026
@Effi-S
Effi-S deleted the idemix-hardening branch August 19, 2026 13:33
@Effi-S
Effi-S restored the idemix-hardening branch August 19, 2026 13:36
@Effi-S Effi-S reopened this Aug 19, 2026
@LFDT-Panurus LFDT-Panurus deleted a comment from github-actions Bot Aug 19, 2026
@LFDT-Panurus LFDT-Panurus deleted a comment from github-actions Bot Aug 19, 2026
@LFDT-Panurus LFDT-Panurus deleted a comment from github-actions Bot Aug 19, 2026
@github-actions

This comment was marked as outdated.

@github-actions

Copy link
Copy Markdown

📊 Token Validation Benchmark

Comparison of this PR against the base branch. 🟢 improvement · 🔴 regression · ➖ within ±1.0% noise.

Variant Benchmark Params Workers TPS (base → PR) Δ TPS
csp BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 117 → 105 🔴 -9.9%
csp BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 103 → 94 🔴 -9.0%
ipa BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 70 → 66 🔴 -6.3%
ipa BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 100 → 92 🔴 -7.4%

Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
Picks up the restored always-pairwise sumOfG1Products in IBM/idemix and the
removal of the small-n dispatch threshold from IBM/mathlib's gurvy
MultiScalarMul.

Both thresholds were tuned on single-threaded microbenchmarks, where gnark's
bucket-method MultiExp loses to a pairwise Mul2+Add loop for a handful of
bases. Under concurrent validation the reasoning inverts: MultiExp's
wall-clock win comes from fanning out over runtime.NumCPU() goroutines, which
buys nothing on a saturated process and costs the bucket allocations anyway.

Measured with TestParallelBenchmarkValidatorTransfer (10 workers, 20s, Apple
M1 Max, BLS12_381_BBS_GURVY, 2 reps), allocated bytes per verification drop
~11-12%: bulletproof 618KB -> 546KB, CSP 541KB -> 477KB. CSP throughput
improves ~7% (426 -> 438 ops/s) with p50 down ~1ms; bulletproof throughput is
a wash. The single-worker latency win the thresholds bought (~4%) is given up.

Removing mathlib's threshold also stops it overriding this repo's own
crossover decision: csp.smallMSM special-cases n=1 and n=2 and hands
everything from n=3 up to MultiScalarMul, but the threshold of 7 was quietly
rerouting n=3..6 back to a pairwise loop.

Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
@Effi-S

Effi-S commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@adecaro , Isolated the mathlib here: #2337

@Effi-S

Effi-S commented Sep 1, 2026

Copy link
Copy Markdown
Contributor
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants