Skip to content

perf: migrate to internal optimized bbs module#68

Merged
adecaro merged 2 commits into
IBM:mainfrom
neetance:perf/internal-bbs-module
May 25, 2026
Merged

perf: migrate to internal optimized bbs module#68
adecaro merged 2 commits into
IBM:mainfrom
neetance:perf/internal-bbs-module

Conversation

@neetance
Copy link
Copy Markdown
Contributor

Description

This PR migrates the project away from the external github.com/hyperledger/aries-bbs-go dependency by embedding the bbs package directly into the local github.com/IBM/idemix repository.

By taking ownership of the bbs package, we have significantly reduced external dependency bloat and opened the door for direct performance optimizations on core cryptographic operations.

Changes Made:

  • Copied the bbs package into the idemix directory.
  • Rewrote all package imports from "github.com/hyperledger/aries-bbs-go/bbs" to "github.com/IBM/idemix/bbs".
  • Cleaned up go.mod to remove the external aries-bbs-go dependency and track github.com/btcsuite/btcutil (required for tests) locally.

Benchmark results

Running the Benchmark_SignVerify benchmark on my device gave the following results:

  • Before

go test -bench=Benchmark_SignVerify -run=^$ ./bccsp -count=5 
goos: linux
goarch: amd64
pkg: github.com/IBM/idemix/bccsp
cpu: 13th Gen Intel(R) Core(TM) i5-13450HX
Benchmark_SignVerify/sign-legacy-16                 2638            432003 ns/op
Benchmark_SignVerify/sign-legacy-16                 2281            453597 ns/op
Benchmark_SignVerify/sign-legacy-16                 2600            427438 ns/op
Benchmark_SignVerify/sign-legacy-16                 2649            467445 ns/op
Benchmark_SignVerify/sign-legacy-16                 2638            477725 ns/op
Benchmark_SignVerify/verify-legacy-16               1551            733908 ns/op
Benchmark_SignVerify/verify-legacy-16               1666            731943 ns/op
Benchmark_SignVerify/verify-legacy-16               1474            714623 ns/op
Benchmark_SignVerify/verify-legacy-16               1662            703719 ns/op
Benchmark_SignVerify/verify-legacy-16               1584            715447 ns/op
Benchmark_SignVerify/sign-aries-16                  1746            661797 ns/op
Benchmark_SignVerify/sign-aries-16                  1648            683712 ns/op
Benchmark_SignVerify/sign-aries-16                  1713            660566 ns/op
Benchmark_SignVerify/sign-aries-16                  1807            678734 ns/op
Benchmark_SignVerify/sign-aries-16                  1802            680139 ns/op
Benchmark_SignVerify/verify-aries-16                1965            570759 ns/op
Benchmark_SignVerify/verify-aries-16                2078            574635 ns/op
Benchmark_SignVerify/verify-aries-16                2059            578455 ns/op
Benchmark_SignVerify/verify-aries-16                1812            602188 ns/op
Benchmark_SignVerify/verify-aries-16                1885            590320 ns/op
PASS
ok      github.com/IBM/idemix/bccsp     28.441s
  • After

go test -bench=Benchmark_SignVerify -run=^$ ./bccsp -count=5 
goos: linux
goarch: amd64
pkg: github.com/IBM/idemix/bccsp
cpu: 13th Gen Intel(R) Core(TM) i5-13450HX
Benchmark_SignVerify/sign-legacy-16                 2571            488799 ns/op
Benchmark_SignVerify/sign-legacy-16                 2566            470626 ns/op
Benchmark_SignVerify/sign-legacy-16                 2283            487518 ns/op
Benchmark_SignVerify/sign-legacy-16                 2785            433768 ns/op
Benchmark_SignVerify/sign-legacy-16                 2300            446487 ns/op
Benchmark_SignVerify/verify-legacy-16               1592            687993 ns/op
Benchmark_SignVerify/verify-legacy-16               1713            700104 ns/op
Benchmark_SignVerify/verify-legacy-16               1862            756582 ns/op
Benchmark_SignVerify/verify-legacy-16               1454            752009 ns/op
Benchmark_SignVerify/verify-legacy-16               1500            745269 ns/op
Benchmark_SignVerify/sign-aries-16                  1977            570592 ns/op
Benchmark_SignVerify/sign-aries-16                  1903            573711 ns/op
Benchmark_SignVerify/sign-aries-16                  1990            596807 ns/op
Benchmark_SignVerify/sign-aries-16                  1650            610454 ns/op
Benchmark_SignVerify/sign-aries-16                  1858            627655 ns/op
Benchmark_SignVerify/verify-aries-16                1815            596717 ns/op
Benchmark_SignVerify/verify-aries-16                1998            583292 ns/op
Benchmark_SignVerify/verify-aries-16                1942            552465 ns/op
Benchmark_SignVerify/verify-aries-16                1998            553720 ns/op
Benchmark_SignVerify/verify-aries-16                1994            605757 ns/op
PASS
ok      github.com/IBM/idemix/bccsp     25.231s
  • Comparing with benchstat

benchstat original_bench.txt optimized_bench.txt 
goos: linux
goarch: amd64
pkg: github.com/IBM/idemix/bccsp
cpu: 13th Gen Intel(R) Core(TM) i5-13450HX
                             │ original_bench.txt │         optimized_bench.txt         │
                             │       sec/op       │    sec/op     vs base               │
_SignVerify/sign-legacy-16           453.6µ ± ∞ ¹   470.6µ ± ∞ ¹        ~ (p=0.310 n=5)
_SignVerify/verify-legacy-16         715.4µ ± ∞ ¹   745.3µ ± ∞ ¹        ~ (p=0.690 n=5)
_SignVerify/sign-aries-16            678.7µ ± ∞ ¹   596.8µ ± ∞ ¹  -12.07% (p=0.008 n=5)
_SignVerify/verify-aries-16          578.5µ ± ∞ ¹   583.3µ ± ∞ ¹        ~ (p=1.000 n=5)
geomean                              597.5µ         591.1µ         -1.06%

We can observe a 12% improvement in aries signing while other results remain constant.

Testing

All existing tests pass and there is no other foundational change in the idemix repo

Let me know if this is good 🙏

@neetance
Copy link
Copy Markdown
Contributor Author

Hi @adecaro
I have added the aries-bbs implementation directly inside the idemix repo as you requested
Please take a look and let me know if this is what you had in mind
Thanks 🙏

@adecaro adecaro self-requested a review May 25, 2026 05:23
@adecaro adecaro self-assigned this May 25, 2026
@adecaro adecaro added bug Something isn't working modernization and removed bug Something isn't working labels May 25, 2026
@adecaro adecaro force-pushed the perf/internal-bbs-module branch from 45f1d04 to e17fa77 Compare May 25, 2026 05:24
@adecaro
Copy link
Copy Markdown
Member

adecaro commented May 25, 2026

Thanks a lot @neetance 🙏

neetance added 2 commits May 25, 2026 07:39
Signed-off-by: Ankit Basu <ankitbasu14@gmail.com>
Signed-off-by: Ankit Basu <ankitbasu14@gmail.com>
@adecaro adecaro force-pushed the perf/internal-bbs-module branch from e17fa77 to 40943a6 Compare May 25, 2026 05:39
Copy link
Copy Markdown
Member

@adecaro adecaro left a comment

Choose a reason for hiding this comment

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

LGTM

@adecaro adecaro merged commit b8a03df into IBM:main May 25, 2026
2 checks passed
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.

2 participants