Skip to content

fix(idemix): never return a nil error when credential verification fails - #2117

Open
AkramBitar wants to merge 1 commit into
mainfrom
fix-2062-idemix-km-nil-error
Open

fix(idemix): never return a nil error when credential verification fails#2117
AkramBitar wants to merge 1 commit into
mainfrom
fix-2062-idemix-km-nil-error

Conversation

@AkramBitar

Copy link
Copy Markdown
Contributor

NewKeyManagerWithSchema funnelled both credential-verification failure modes through errors.WithMessagef(err, ...). When the BCCSP reports a bad credential as valid == false with a nil error, wrapping nil yields nil, so the constructor returned (nil, nil). Callers checking only err != nil then used a nil *KeyManager and panicked later, far from the real cause.

The branch is now split: an error is wrapped, !valid returns a fresh error. A verification failure is always reported as a non-nil error.

Tests: a BCCSP decorator forcing each outcome ((false, nil) — the bug, (false, err), (true, err)) across both curve configs, a happy-path pin, and an end-to-end case with a tampered credential rejected by the real BCCSP. The (false, nil) case fails before this change and passes after.

Docs: added "Credential Verification at Load Time" to docs/services/identity.md.

Fixes #2062

@AkramBitar AkramBitar added this to the Q3/26 milestone Aug 3, 2026
@AkramBitar AkramBitar self-assigned this Aug 3, 2026
@AkramBitar
AkramBitar force-pushed the fix-2062-idemix-km-nil-error branch from 21512bc to 4d32207 Compare August 3, 2026 19:23
@github-actions

github-actions Bot commented Aug 3, 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 118 → 117 ➖ -0.1%
csp BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 104 → 104 ➖ -0.0%
ipa BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 70 → 70 ➖ +0.1%
ipa BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 76 → 76 ➖ +0.3%

@github-actions

github-actions Bot commented Aug 3, 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 117 → 117 ➖ -0.1%
csp BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 104 → 104 ➖ +0.3%
ipa BenchmarkAPIGRPC f=1, nc=4, w=token-validation-service 4 78 → 78 ➖ +0.2%
ipa BenchmarkLocalTokenValidation out-tokens=2in-tokens=2 4 68 → 68 ➖ +0.6%

@AkramBitar
AkramBitar requested review from SaidAltury-ibm and removed request for HayimShaul August 5, 2026 14:02
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.

identity/idemix: NewKeyManagerWithSchema returns (nil, nil) on a cryptographically invalid credential

1 participant