Skip to content

Fix bbs MultiScalarMul small-n regression and cache hash-to-G1 generators - #90

Open
adecaro wants to merge 2 commits into
mainfrom
fix/mathlib-msm-crossover
Open

Fix bbs MultiScalarMul small-n regression and cache hash-to-G1 generators#90
adecaro wants to merge 2 commits into
mainfrom
fix/mathlib-msm-crossover

Conversation

@adecaro

@adecaro adecaro commented Aug 28, 2026

Copy link
Copy Markdown
Member

Summary

  • sumOfG1Products (bbs/bbs12381g2pub.go) unconditionally called curve.MultiScalarMul, which regressed on the gnark-backed curves: gnark's bucket-method MultiExp has a large fixed setup cost tuned for thousands of points, costing ~4x a plain Mul at a single base. Most of this package's hot-path call sites (per-attribute nym/signature proofs) sum well under a dozen bases. Add a pairwise Mul2+Add fallback below a measured n=7 crossover, keeping MultiScalarMul for larger n.
  • publicKeyGeneratorCache (bbs/keys.go) was owned per-*BBSLib instance, but every bccsp/schemes/aries call site constructs a fresh *BBSLib per operation — so the ~69µs hash-to-G1 work for h0 and every message generator was redone on every sign/verify/proof call instead of once per (public key, message count) pair. Made the cache package-wide, keyed by curve ID + data.
  • Added .github/workflows/bench.yml: a non-blocking benchstat comparison posted as a PR comment, so a regression shaped like this one shows up in review.
  • Bumped github.com/IBM/mathlib to a commit (IBM/mathlib#55) that fixes both root causes upstream — the same MultiScalarMul small-n dispatch problem and a NewRandomZr allocation regression. This package's pairwise workaround in sumOfG1Products is kept for now (it's still measurably faster below the crossover, and mathlib's fix hasn't shipped in a tagged release), but can be revisited once mathlib#55 lands in a release.

Test plan

  • go build ./..., go vet ./..., gofmt -l -s clean
  • go test ./... passes with the new mathlib pseudo-version
  • addlicense -check clean
  • BenchmarkSignerSign/EidNymRhNym back down to ~3.5ms (was regressed)
  • New BenchmarkSumOfG1ProductsCrossover backs the msmThreshold=7 constant
  • Once Fix MultiScalarMul small-n pathology and NewRandomZr allocation regression mathlib#55 ships in a tagged release, bump go.mod off the pseudo-version and revisit whether sumOfG1Products's pairwise fallback can be dropped in favor of mathlib's own dispatch (follow-up, not this PR)

…s, bump mathlib

BenchmarkSignerSign regressed after mathlib started unconditionally
dispatching sumOfG1Products to curve.MultiScalarMul: gnark's bucket-method
MultiExp has a large fixed setup cost that a handful of bases (the common
case for per-attribute nym/signature proofs) cannot amortize, costing ~4x
a plain Mul at n=1. Add a pairwise Mul2+Add fallback below a measured n=7
crossover (bbs/bbs12381g2pub.go), backed by a new BenchmarkSumOfG1ProductsCrossover.

Also cache hash-to-G1 generator points across *BBSLib instances (bbs/keys.go):
every sign/verify/proof call constructed a fresh *BBSLib and redid the
~69us hash-to-G1 work for h0 and every message generator, since the cache
was previously owned per-instance rather than shared.

Add .github/workflows/bench.yml to catch a regression like this one in
review via a non-blocking benchstat PR comment.

Bump github.com/IBM/mathlib to a commit that fixes both of these
regressions upstream (IBM/mathlib#55) so the pairwise workaround above can
eventually be dropped in favor of mathlib's own MultiScalarMul dispatch;
kept for now since it is still measurably faster below the crossover and
mathlib's fix has not shipped in a tagged release yet.
@github-actions

Copy link
Copy Markdown

Benchmark comparison (base vs. this PR)

Informational only — noisy GitHub runners, not a merge gate.

goos: linux
goarch: amd64
pkg: github.com/IBM/idemix/bbs
cpu: AMD EPYC 9V74 80-Core Processor                
                                       │ /tmp/base.txt │            /tmp/head.txt            │
                                       │    sec/op     │    sec/op     vs base               │
Sign/msgs=1                               1.125m ± ∞ ¹   1.395m ± ∞ ¹        ~ (p=0.151 n=5)
Sign/msgs=5                               1.371m ± ∞ ¹   2.040m ± ∞ ¹  +48.80% (p=0.008 n=5)
Sign/msgs=10                              1.545m ± ∞ ¹   1.548m ± ∞ ¹        ~ (p=0.841 n=5)
Sign/msgs=20                              1.876m ± ∞ ¹   1.882m ± ∞ ¹        ~ (p=0.151 n=5)
Verify/msgs=1                             1.975m ± ∞ ¹   1.746m ± ∞ ¹  -11.59% (p=0.008 n=5)
Verify/msgs=5                             2.164m ± ∞ ¹   2.177m ± ∞ ¹        ~ (p=0.222 n=5)
Verify/msgs=10                            2.324m ± ∞ ¹   2.350m ± ∞ ¹   +1.09% (p=0.008 n=5)
Verify/msgs=20                            2.640m ± ∞ ¹   2.660m ± ∞ ¹   +0.75% (p=0.032 n=5)
DeriveProof/msgs=1/revealed=1             3.878m ± ∞ ¹   2.784m ± ∞ ¹  -28.22% (p=0.008 n=5)
DeriveProof/msgs=5/revealed=3             4.217m ± ∞ ¹   3.443m ± ∞ ¹  -18.36% (p=0.008 n=5)
DeriveProof/msgs=10/revealed=5            4.539m ± ∞ ¹   3.962m ± ∞ ¹  -12.71% (p=0.008 n=5)
DeriveProof/msgs=20/revealed=10           5.064m ± ∞ ¹   4.501m ± ∞ ¹  -11.13% (p=0.008 n=5)
VerifyProof/msgs=1/revealed=1             2.837m ± ∞ ¹   2.374m ± ∞ ¹  -16.32% (p=0.008 n=5)
VerifyProof/msgs=5/revealed=3             3.161m ± ∞ ¹   2.823m ± ∞ ¹  -10.72% (p=0.008 n=5)
VerifyProof/msgs=10/revealed=5            3.521m ± ∞ ¹   3.298m ± ∞ ¹   -6.34% (p=0.008 n=5)
VerifyProof/msgs=20/revealed=10           4.303m ± ∞ ¹   4.077m ± ∞ ¹   -5.25% (p=0.008 n=5)
SignWithKey/msgs=1                       1115.4µ ± ∞ ¹   874.5µ ± ∞ ¹  -21.60% (p=0.008 n=5)
SignWithKey/msgs=5                        1.368m ± ∞ ¹   1.292m ± ∞ ¹   -5.56% (p=0.008 n=5)
SignWithKey/msgs=10                       1.552m ± ∞ ¹   1.552m ± ∞ ¹        ~ (p=0.421 n=5)
SignWithKey/msgs=20                       1.869m ± ∞ ¹   1.902m ± ∞ ¹   +1.79% (p=0.008 n=5)
ToPublicKeyWithGenerators/msgs=1          193.9µ ± ∞ ¹   194.0µ ± ∞ ¹        ~ (p=1.000 n=5)
ToPublicKeyWithGenerators/msgs=5          590.9µ ± ∞ ¹   590.1µ ± ∞ ¹        ~ (p=1.000 n=5)
ToPublicKeyWithGenerators/msgs=10         1.175m ± ∞ ¹   1.181m ± ∞ ¹        ~ (p=0.690 n=5)
ToPublicKeyWithGenerators/msgs=20         2.468m ± ∞ ¹   2.474m ± ∞ ¹   +0.28% (p=0.008 n=5)
ComputeB/msgs=1                           498.5µ ± ∞ ¹   289.1µ ± ∞ ¹  -42.00% (p=0.008 n=5)
ComputeB/msgs=5                           695.3µ ± ∞ ¹   698.3µ ± ∞ ¹        ~ (p=0.310 n=5)
ComputeB/msgs=10                          858.8µ ± ∞ ¹   862.4µ ± ∞ ¹   +0.42% (p=0.032 n=5)
ComputeB/msgs=20                          1.159m ± ∞ ¹   1.170m ± ∞ ¹   +0.96% (p=0.008 n=5)
FrFromOKM                                 814.7n ± ∞ ¹   647.1n ± ∞ ¹        ~ (p=0.690 n=5)
MessagesToFr/msgs=1                       874.5n ± ∞ ¹   636.8n ± ∞ ¹  -27.18% (p=0.008 n=5)
MessagesToFr/msgs=5                       3.178µ ± ∞ ¹   4.019µ ± ∞ ¹        ~ (p=0.151 n=5)
MessagesToFr/msgs=10                      6.730µ ± ∞ ¹   6.793µ ± ∞ ¹        ~ (p=1.000 n=5)
MessagesToFr/msgs=20                      12.20µ ± ∞ ¹   12.09µ ± ∞ ¹        ~ (p=1.000 n=5)
NewCommitmentBuilder/bases=1             402.79µ ± ∞ ¹   96.32µ ± ∞ ¹  -76.09% (p=0.008 n=5)
NewCommitmentBuilder/bases=5              652.3µ ± ∞ ¹   498.7µ ± ∞ ¹  -23.55% (p=0.008 n=5)
NewCommitmentBuilder/bases=10             828.9µ ± ∞ ¹   825.1µ ± ∞ ¹        ~ (p=0.690 n=5)
NewCommitmentBuilder/bases=20             1.128m ± ∞ ¹   1.140m ± ∞ ¹   +1.05% (p=0.016 n=5)
ParseSignature                            71.67µ ± ∞ ¹   71.71µ ± ∞ ¹        ~ (p=0.690 n=5)
SignatureToBytes                          213.8n ± ∞ ¹   211.5n ± ∞ ¹        ~ (p=0.310 n=5)
GenerateKeyPair                           230.2µ ± ∞ ¹   229.0µ ± ∞ ¹        ~ (p=1.000 n=5)
PublicKeyMarshal                          140.4n ± ∞ ¹   193.2n ± ∞ ¹  +37.61% (p=0.008 n=5)
UnmarshalPublicKey                        107.3µ ± ∞ ¹   107.6µ ± ∞ ¹        ~ (p=0.079 n=5)
ParseSignatureProof                       358.9µ ± ∞ ¹   358.6µ ± ∞ ¹        ~ (p=0.421 n=5)
Pairing                                   788.1µ ± ∞ ¹   791.4µ ± ∞ ¹        ~ (p=0.056 n=5)
Pairing2                                  1.034m ± ∞ ¹   1.038m ± ∞ ¹   +0.40% (p=0.008 n=5)
G1ScalarMul                               96.99µ ± ∞ ¹   97.87µ ± ∞ ¹        ~ (p=0.151 n=5)
G1Add                                     3.991µ ± ∞ ¹   4.114µ ± ∞ ¹        ~ (p=0.841 n=5)
HashToG1                                  96.60µ ± ∞ ¹   95.83µ ± ∞ ¹   -0.80% (p=0.008 n=5)
NewRandomZr                                              200.7n ± ∞ ¹
SumOfG1ProductsCrossover/n=1/pairwise                    96.09µ ± ∞ ¹
SumOfG1ProductsCrossover/n=1/msm                         95.77µ ± ∞ ¹
SumOfG1ProductsCrossover/n=2/pairwise                    189.4µ ± ∞ ¹
SumOfG1ProductsCrossover/n=2/msm                         188.7µ ± ∞ ¹
SumOfG1ProductsCrossover/n=3/pairwise                    298.0µ ± ∞ ¹
SumOfG1ProductsCrossover/n=3/msm                         296.8µ ± ∞ ¹
SumOfG1ProductsCrossover/n=4/pairwise                    396.5µ ± ∞ ¹
SumOfG1ProductsCrossover/n=4/msm                         394.8µ ± ∞ ¹
SumOfG1ProductsCrossover/n=5/msm                         496.3µ ± ∞ ¹
SumOfG1ProductsCrossover/n=5/pairwise                    498.0µ ± ∞ ¹
SumOfG1ProductsCrossover/n=6/pairwise                    590.6µ ± ∞ ¹
SumOfG1ProductsCrossover/n=6/msm                         588.0µ ± ∞ ¹
SumOfG1ProductsCrossover/n=7/pairwise                    695.8µ ± ∞ ¹
SumOfG1ProductsCrossover/n=7/msm                         725.5µ ± ∞ ¹
SumOfG1ProductsCrossover/n=8/pairwise                    791.1µ ± ∞ ¹
SumOfG1ProductsCrossover/n=8/msm                         766.4µ ± ∞ ¹
SumOfG1ProductsCrossover/n=9/pairwise                    899.3µ ± ∞ ¹
SumOfG1ProductsCrossover/n=9/msm                         795.4µ ± ∞ ¹
SumOfG1ProductsCrossover/n=10/pairwise                   998.9µ ± ∞ ¹
SumOfG1ProductsCrossover/n=10/msm                        828.5µ ± ∞ ¹
SumOfG1ProductsCrossover/n=12/pairwise                   1.195m ± ∞ ¹
SumOfG1ProductsCrossover/n=12/msm                        892.1µ ± ∞ ¹
SumOfG1ProductsCrossover/n=16/pairwise                   1.605m ± ∞ ¹
SumOfG1ProductsCrossover/n=16/msm                        1.024m ± ∞ ¹
SumOfG1ProductsCrossover/n=20/pairwise                   2.016m ± ∞ ¹
SumOfG1ProductsCrossover/n=20/msm                        1.139m ± ∞ ¹
SumOfG1ProductsCrossover/n=32/pairwise                   3.481m ± ∞ ¹
SumOfG1ProductsCrossover/n=32/msm                        1.487m ± ∞ ¹
geomean                                   346.5µ         372.9µ         -6.34%
¹ need >= 6 samples for confidence interval at level 0.95

                                       │ /tmp/base.txt  │             /tmp/head.txt              │
                                       │      B/op      │     B/op       vs base                 │
Sign/msgs=1                              39.147Ki ± ∞ ¹   8.454Ki ± ∞ ¹  -78.40% (p=0.008 n=5)
Sign/msgs=5                               46.92Ki ± ∞ ¹   16.85Ki ± ∞ ¹  -64.09% (p=0.008 n=5)
Sign/msgs=10                              56.54Ki ± ∞ ¹   60.81Ki ± ∞ ¹   +7.55% (p=0.008 n=5)
Sign/msgs=20                              75.62Ki ± ∞ ¹   83.95Ki ± ∞ ¹  +11.02% (p=0.008 n=5)
Verify/msgs=1                             41.37Ki ± ∞ ¹   10.76Ki ± ∞ ¹  -74.00% (p=0.008 n=5)
Verify/msgs=5                             47.39Ki ± ∞ ¹   48.61Ki ± ∞ ¹   +2.57% (p=0.008 n=5)
Verify/msgs=10                            54.71Ki ± ∞ ¹   56.95Ki ± ∞ ¹   +4.08% (p=0.008 n=5)
Verify/msgs=20                            69.92Ki ± ∞ ¹   74.18Ki ± ∞ ¹   +6.10% (p=0.008 n=5)
DeriveProof/msgs=1/revealed=1            147.42Ki ± ∞ ¹   22.30Ki ± ∞ ¹  -84.88% (p=0.008 n=5)
DeriveProof/msgs=5/revealed=3            156.89Ki ± ∞ ¹   62.84Ki ± ∞ ¹  -59.94% (p=0.008 n=5)
DeriveProof/msgs=10/revealed=5            170.4Ki ± ∞ ¹   109.0Ki ± ∞ ¹  -36.07% (p=0.008 n=5)
DeriveProof/msgs=20/revealed=10           192.1Ki ± ∞ ¹   132.1Ki ± ∞ ¹  -31.21% (p=0.008 n=5)
VerifyProof/msgs=1/revealed=1             78.26Ki ± ∞ ¹   16.63Ki ± ∞ ¹  -78.75% (p=0.008 n=5)
VerifyProof/msgs=5/revealed=3             84.09Ki ± ∞ ¹   22.77Ki ± ∞ ¹  -72.92% (p=0.008 n=5)
VerifyProof/msgs=10/revealed=5            91.24Ki ± ∞ ¹   62.46Ki ± ∞ ¹  -31.54% (p=0.008 n=5)
VerifyProof/msgs=20/revealed=10          106.06Ki ± ∞ ¹   79.31Ki ± ∞ ¹  -25.22% (p=0.008 n=5)
SignWithKey/msgs=1                       39.062Ki ± ∞ ¹   8.368Ki ± ∞ ¹  -78.58% (p=0.008 n=5)
SignWithKey/msgs=5                        46.83Ki ± ∞ ¹   16.76Ki ± ∞ ¹  -64.20% (p=0.008 n=5)
SignWithKey/msgs=10                       56.45Ki ± ∞ ¹   60.72Ki ± ∞ ¹   +7.57% (p=0.008 n=5)
SignWithKey/msgs=20                       75.53Ki ± ∞ ¹   83.86Ki ± ∞ ¹  +11.03% (p=0.008 n=5)
ToPublicKeyWithGenerators/msgs=1          3.918Ki ± ∞ ¹   3.918Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=5          10.96Ki ± ∞ ¹   10.96Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=10         19.74Ki ± ∞ ¹   19.74Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=20         37.32Ki ± ∞ ¹   37.32Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ComputeB/msgs=1                           32633.0 ± ∞ ¹     875.0 ± ∞ ¹  -97.32% (p=0.008 n=5)
ComputeB/msgs=5                           33.16Ki ± ∞ ¹   33.16Ki ± ∞ ¹   +0.01% (p=0.008 n=5)
ComputeB/msgs=10                          34.59Ki ± ∞ ¹   34.60Ki ± ∞ ¹   +0.01% (p=0.008 n=5)
ComputeB/msgs=20                          38.00Ki ± ∞ ¹   38.00Ki ± ∞ ¹   +0.00% (p=0.008 n=5)
FrFromOKM                                   760.0 ± ∞ ¹     760.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=1                         784.0 ± ∞ ¹     784.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=5                       3.836Ki ± ∞ ¹   3.836Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=10                      7.656Ki ± ∞ ¹   7.656Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=20                      15.31Ki ± ∞ ¹   15.31Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
NewCommitmentBuilder/bases=1              31841.0 ± ∞ ¹     648.0 ± ∞ ¹  -97.96% (p=0.008 n=5)
NewCommitmentBuilder/bases=5              33241.0 ± ∞ ¹     971.0 ± ∞ ¹  -97.08% (p=0.008 n=5)
NewCommitmentBuilder/bases=10             33.99Ki ± ∞ ¹   34.00Ki ± ∞ ¹   +0.01% (p=0.008 n=5)
NewCommitmentBuilder/bases=20             37.15Ki ± ∞ ¹   37.15Ki ± ∞ ¹   +0.01% (p=0.008 n=5)
ParseSignature                              296.0 ± ∞ ¹     296.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
SignatureToBytes                            224.0 ± ∞ ¹     224.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
GenerateKeyPair                           2.931Ki ± ∞ ¹   2.931Ki ± ∞ ¹        ~ (p=1.000 n=5)
PublicKeyMarshal                            96.00 ± ∞ ¹     96.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
UnmarshalPublicKey                          232.0 ± ∞ ¹     232.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ParseSignatureProof                       1.430Ki ± ∞ ¹   1.430Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing                                   5.438Ki ± ∞ ¹   5.438Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing2                                  6.000Ki ± ∞ ¹   6.000Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
G1ScalarMul                                 608.0 ± ∞ ¹     608.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
G1Add                                       97.00 ± ∞ ¹     97.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
HashToG1                                  1.551Ki ± ∞ ¹   1.551Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
NewRandomZr                                                 80.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/pairwise                       633.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/msm                            665.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/pairwise                       124.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/msm                            188.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/pairwise                       756.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/msm                            828.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/pairwise                       244.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/msm                            348.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/msm                            988.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/pairwise                       876.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=6/pairwise                       364.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=6/msm                            508.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/pairwise                       996.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/msm                          32.97Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=8/pairwise                       484.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=8/msm                          33.22Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=9/pairwise                     1.090Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=9/msm                          33.53Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=10/pairwise                      604.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=10/msm                         33.84Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=12/pairwise                      724.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=12/msm                         34.34Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=16/pairwise                      964.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=16/msm                         35.47Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=20/pairwise                    1.176Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=20/msm                         36.84Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=32/pairwise                    1.879Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=32/msm                         39.97Ki ± ∞ ¹
geomean                                   13.79Ki         4.579Ki        -39.58%
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal

                                       │ /tmp/base.txt │            /tmp/head.txt             │
                                       │   allocs/op   │  allocs/op   vs base                 │
Sign/msgs=1                                254.0 ± ∞ ¹   110.0 ± ∞ ¹  -56.69% (p=0.008 n=5)
Sign/msgs=5                                324.0 ± ∞ ¹   188.0 ± ∞ ¹  -41.98% (p=0.008 n=5)
Sign/msgs=10                               406.0 ± ∞ ¹   422.0 ± ∞ ¹   +3.94% (p=0.008 n=5)
Sign/msgs=20                               568.0 ± ∞ ¹   604.0 ± ∞ ¹   +6.34% (p=0.008 n=5)
Verify/msgs=1                             216.00 ± ∞ ¹   88.00 ± ∞ ¹  -59.26% (p=0.008 n=5)
Verify/msgs=5                              274.0 ± ∞ ¹   280.0 ± ∞ ¹   +2.19% (p=0.008 n=5)
Verify/msgs=10                             344.0 ± ∞ ¹   355.0 ± ∞ ¹   +3.20% (p=0.008 n=5)
Verify/msgs=20                             484.0 ± ∞ ¹   505.0 ± ∞ ¹   +4.34% (p=0.008 n=5)
DeriveProof/msgs=1/revealed=1              841.0 ± ∞ ¹   269.0 ± ∞ ¹  -68.01% (p=0.008 n=5)
DeriveProof/msgs=5/revealed=3              933.0 ± ∞ ¹   487.0 ± ∞ ¹  -47.80% (p=0.008 n=5)
DeriveProof/msgs=10/revealed=5            1047.0 ± ∞ ¹   741.0 ± ∞ ¹  -29.23% (p=0.008 n=5)
DeriveProof/msgs=20/revealed=10           1257.0 ± ∞ ¹   946.0 ± ∞ ¹  -24.74% (p=0.008 n=5)
VerifyProof/msgs=1/revealed=1              428.0 ± ∞ ¹   170.0 ± ∞ ¹  -60.28% (p=0.008 n=5)
VerifyProof/msgs=5/revealed=3              498.0 ± ∞ ¹   244.0 ± ∞ ¹  -51.00% (p=0.008 n=5)
VerifyProof/msgs=10/revealed=5             571.0 ± ∞ ¹   452.0 ± ∞ ¹  -20.84% (p=0.008 n=5)
VerifyProof/msgs=20/revealed=10            735.0 ± ∞ ¹   626.0 ± ∞ ¹  -14.83% (p=0.008 n=5)
SignWithKey/msgs=1                         251.0 ± ∞ ¹   107.0 ± ∞ ¹  -57.37% (p=0.008 n=5)
SignWithKey/msgs=5                         321.0 ± ∞ ¹   185.0 ± ∞ ¹  -42.37% (p=0.008 n=5)
SignWithKey/msgs=10                        403.0 ± ∞ ¹   419.0 ± ∞ ¹   +3.97% (p=0.008 n=5)
SignWithKey/msgs=20                        565.0 ± ∞ ¹   601.0 ± ∞ ¹   +6.37% (p=0.008 n=5)
ToPublicKeyWithGenerators/msgs=1           55.00 ± ∞ ¹   55.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=5           159.0 ± ∞ ¹   159.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=10          289.0 ± ∞ ¹   289.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=20          549.0 ± ∞ ¹   549.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ComputeB/msgs=1                           150.00 ± ∞ ¹   20.00 ± ∞ ¹  -86.67% (p=0.008 n=5)
ComputeB/msgs=5                            152.0 ± ∞ ¹   152.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ComputeB/msgs=10                           152.0 ± ∞ ¹   152.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ComputeB/msgs=20                           152.0 ± ∞ ¹   152.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
FrFromOKM                                  11.00 ± ∞ ¹   11.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=1                        13.00 ± ∞ ¹   13.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=5                        61.00 ± ∞ ¹   61.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=10                       121.0 ± ∞ ¹   121.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=20                       241.0 ± ∞ ¹   241.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
NewCommitmentBuilder/bases=1              144.00 ± ∞ ¹   16.00 ± ∞ ¹  -88.89% (p=0.008 n=5)
NewCommitmentBuilder/bases=5              150.00 ± ∞ ¹   20.00 ± ∞ ¹  -86.67% (p=0.008 n=5)
NewCommitmentBuilder/bases=10              150.0 ± ∞ ¹   150.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
NewCommitmentBuilder/bases=20              150.0 ± ∞ ¹   150.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ParseSignature                             7.000 ± ∞ ¹   7.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
SignatureToBytes                           4.000 ± ∞ ¹   4.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
GenerateKeyPair                            42.00 ± ∞ ¹   42.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
PublicKeyMarshal                           1.000 ± ∞ ¹   1.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
UnmarshalPublicKey                         3.000 ± ∞ ¹   3.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
ParseSignatureProof                        34.00 ± ∞ ¹   34.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing                                    25.00 ± ∞ ¹   25.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing2                                   25.00 ± ∞ ¹   25.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
G1ScalarMul                                13.00 ± ∞ ¹   13.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
G1Add                                      1.000 ± ∞ ¹   1.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
HashToG1                                   25.00 ± ∞ ¹   25.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
NewRandomZr                                              2.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/pairwise                    14.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/msm                         16.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/pairwise                    2.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/msm                         4.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/pairwise                    16.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/msm                         17.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/pairwise                    4.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/msm                         5.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/msm                         18.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/pairwise                    18.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=6/pairwise                    6.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=6/msm                         6.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/pairwise                    20.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=8/pairwise                    8.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=8/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=9/pairwise                    22.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=9/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=10/pairwise                   10.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=10/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=12/pairwise                   12.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=12/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=16/pairwise                   16.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=16/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=20/pairwise                   20.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=20/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=32/pairwise                   32.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=32/msm                        148.0 ± ∞ ¹
geomean                                    114.6         50.41        -25.40%
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal

pkg: github.com/IBM/idemix/bccsp
                          │ /tmp/base.txt │            /tmp/head.txt            │
                          │    sec/op     │    sec/op     vs base               │
_SignVerify/sign-legacy      3.299m ± ∞ ¹   3.303m ± ∞ ¹        ~ (p=0.056 n=5)
_SignVerify/verify-legacy    5.215m ± ∞ ¹   5.209m ± ∞ ¹        ~ (p=0.548 n=5)
_SignVerify/sign-aries       6.660m ± ∞ ¹   4.712m ± ∞ ¹  -29.25% (p=0.008 n=5)
_SignVerify/verify-aries     5.437m ± ∞ ¹   4.362m ± ∞ ¹  -19.77% (p=0.008 n=5)
geomean                      4.996m         4.337m        -13.19%
¹ need >= 6 samples for confidence interval at level 0.95

pkg: github.com/IBM/idemix/bccsp/schemes/aries
                               │ /tmp/base.txt │            /tmp/head.txt            │
                               │    sec/op     │    sec/op     vs base               │
IssuerNewKey                      949.1µ ± ∞ ¹   950.2µ ± ∞ ¹        ~ (p=0.841 n=5)
IssuerNewKeyFromBytes             824.1µ ± ∞ ¹   833.5µ ± ∞ ¹   +1.14% (p=0.016 n=5)
IssuerNewPublicKeyFromBytes       698.4µ ± ∞ ¹   698.6µ ± ∞ ¹        ~ (p=1.000 n=5)
UserMakeNym                       514.1µ ± ∞ ¹   216.1µ ± ∞ ¹  -57.96% (p=0.008 n=5)
CredRequestBlind                  1.658m ± ∞ ¹   1.053m ± ∞ ¹  -36.51% (p=0.008 n=5)
CredRequestBlindVerify            1.384m ± ∞ ¹   1.125m ± ∞ ¹  -18.75% (p=0.008 n=5)
CredRequestUnblind                73.15µ ± ∞ ¹   74.32µ ± ∞ ¹   +1.60% (p=0.008 n=5)
CredSign                          2.734m ± ∞ ¹   2.002m ± ∞ ¹  -26.75% (p=0.008 n=5)
CredVerify                        2.019m ± ∞ ¹   2.013m ± ∞ ¹        ~ (p=0.095 n=5)
SignerSign/Standard               4.638m ± ∞ ¹   3.625m ± ∞ ¹  -21.84% (p=0.008 n=5)
SignerSign/EidNym                 5.655m ± ∞ ¹   4.067m ± ∞ ¹  -28.08% (p=0.008 n=5)
SignerSign/EidNymRhNym            6.660m ± ∞ ¹   4.510m ± ∞ ¹  -32.28% (p=0.008 n=5)
SignerVerify/Basic                3.485m ± ∞ ¹   2.925m ± ∞ ¹  -16.09% (p=0.008 n=5)
SignerVerify/ExpectEidNym         4.299m ± ∞ ¹   3.440m ± ∞ ¹  -19.97% (p=0.008 n=5)
SignerVerify/ExpectEidNymRhNym    5.011m ± ∞ ¹   3.981m ± ∞ ¹  -20.56% (p=0.008 n=5)
NymSignerSign                     522.9µ ± ∞ ¹   223.2µ ± ∞ ¹  -57.31% (p=0.008 n=5)
NymSignerVerify                   640.0µ ± ∞ ¹   377.2µ ± ∞ ¹  -41.05% (p=0.008 n=5)
RevocationSign                    266.1µ ± ∞ ¹   266.8µ ± ∞ ¹        ~ (p=0.421 n=5)
RevocationVerify                  764.2µ ± ∞ ¹   763.7µ ± ∞ ¹        ~ (p=0.690 n=5)
AuditNymEid                       248.0µ ± ∞ ¹   247.7µ ± ∞ ¹        ~ (p=0.841 n=5)
AuditNymRh                        248.2µ ± ∞ ¹   248.8µ ± ∞ ¹        ~ (p=0.841 n=5)
geomean                           1.135m         903.8µ        -20.38%
¹ need >= 6 samples for confidence interval at level 0.95

sumOfG1Products dispatched to curve.MultiScalarMul from 7 bases up, on the
strength of single-threaded microbenchmarks. That win does not survive
concurrent load: gnark's bucket-method MultiExp is faster in wall-clock
terms only because it fans out over runtime.NumCPU() goroutines and
allocates buckets to do it, and a process already saturated with concurrent
verifications has no spare cores to fan out onto - it just pays the extra
allocations.

Measured end to end on Panurus' zkatdlog transfer validation (10 workers,
Apple M1 Max, BLS12_381_BBS_GURVY): this package's verification path only
ever calls sumOfG1Products with 2, 3, 7 or 8 bases, straddling the
threshold, and removing the dispatch cuts allocated bytes per verification
by ~11-12% (bulletproof 618KB -> 546KB, CSP 541KB -> 477KB) while improving
CSP throughput ~7% (426 -> 438 ops/s). The cost is a ~4% single-worker
latency win given up, which is the case that matters least.

So fold sumOfG1ProductsPairwise back into sumOfG1Products and drop
msmThreshold. The FrToRepr calls the original loop made are omitted since
FrToRepr is the identity function (see fr.go). Behavior is unchanged: the
loop's odd tail handles a single base with Mul exactly as the old n==1 case
did, and an empty input still yields nil.

The companion mathlib change (IBM/mathlib) removes the same threshold from
the gurvy drivers' MultiScalarMul, so bump to it.

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

Copy link
Copy Markdown

Benchmark comparison (base vs. this PR)

Informational only — noisy GitHub runners, not a merge gate.

goos: linux
goarch: amd64
pkg: github.com/IBM/idemix/bbs
cpu: AMD EPYC 7763 64-Core Processor                
                                       │ /tmp/base.txt │             /tmp/head.txt             │
                                       │    sec/op     │    sec/op      vs base                │
Sign/msgs=1                               1.003m ± ∞ ¹    1.353m ± ∞ ¹         ~ (p=0.151 n=5)
Sign/msgs=5                               1.221m ± ∞ ¹    1.967m ± ∞ ¹   +61.14% (p=0.008 n=5)
Sign/msgs=10                              1.384m ± ∞ ¹    2.010m ± ∞ ¹   +45.15% (p=0.008 n=5)
Sign/msgs=20                              1.689m ± ∞ ¹    2.704m ± ∞ ¹   +60.11% (p=0.008 n=5)
Verify/msgs=1                             1.770m ± ∞ ¹    1.552m ± ∞ ¹   -12.27% (p=0.008 n=5)
Verify/msgs=5                             1.936m ± ∞ ¹    1.923m ± ∞ ¹    -0.71% (p=0.008 n=5)
Verify/msgs=10                            2.095m ± ∞ ¹    2.456m ± ∞ ¹   +17.24% (p=0.008 n=5)
Verify/msgs=20                            2.371m ± ∞ ¹    3.478m ± ∞ ¹   +46.65% (p=0.008 n=5)
DeriveProof/msgs=1/revealed=1             3.505m ± ∞ ¹    2.493m ± ∞ ¹   -28.86% (p=0.008 n=5)
DeriveProof/msgs=5/revealed=3             3.807m ± ∞ ¹    3.101m ± ∞ ¹   -18.54% (p=0.008 n=5)
DeriveProof/msgs=10/revealed=5            4.098m ± ∞ ¹    3.887m ± ∞ ¹    -5.16% (p=0.008 n=5)
DeriveProof/msgs=20/revealed=10           4.568m ± ∞ ¹    5.368m ± ∞ ¹   +17.51% (p=0.008 n=5)
VerifyProof/msgs=1/revealed=1             2.567m ± ∞ ¹    2.117m ± ∞ ¹   -17.55% (p=0.008 n=5)
VerifyProof/msgs=5/revealed=3             2.864m ± ∞ ¹    2.514m ± ∞ ¹   -12.21% (p=0.008 n=5)
VerifyProof/msgs=10/revealed=5            3.182m ± ∞ ¹    3.015m ± ∞ ¹         ~ (p=0.151 n=5)
VerifyProof/msgs=20/revealed=10           3.856m ± ∞ ¹    4.043m ± ∞ ¹    +4.86% (p=0.008 n=5)
SignWithKey/msgs=1                       1005.1µ ± ∞ ¹    770.9µ ± ∞ ¹   -23.30% (p=0.008 n=5)
SignWithKey/msgs=5                        1.231m ± ∞ ¹    1.144m ± ∞ ¹    -7.12% (p=0.008 n=5)
SignWithKey/msgs=10                       1.390m ± ∞ ¹    1.656m ± ∞ ¹   +19.10% (p=0.008 n=5)
SignWithKey/msgs=20                       1.700m ± ∞ ¹    2.684m ± ∞ ¹   +57.87% (p=0.008 n=5)
ToPublicKeyWithGenerators/msgs=1          175.5µ ± ∞ ¹    175.3µ ± ∞ ¹         ~ (p=0.841 n=5)
ToPublicKeyWithGenerators/msgs=5          594.1µ ± ∞ ¹    588.8µ ± ∞ ¹    -0.88% (p=0.032 n=5)
ToPublicKeyWithGenerators/msgs=10         1.131m ± ∞ ¹    1.125m ± ∞ ¹    -0.48% (p=0.032 n=5)
ToPublicKeyWithGenerators/msgs=20         2.196m ± ∞ ¹    2.196m ± ∞ ¹         ~ (p=1.000 n=5)
ComputeB/msgs=1                           467.2µ ± ∞ ¹    247.4µ ± ∞ ¹   -47.06% (p=0.008 n=5)
ComputeB/msgs=5                           624.7µ ± ∞ ¹    599.4µ ± ∞ ¹    -4.05% (p=0.008 n=5)
ComputeB/msgs=10                          767.5µ ± ∞ ¹   1093.8µ ± ∞ ¹   +42.53% (p=0.008 n=5)
ComputeB/msgs=20                          1.034m ± ∞ ¹    2.094m ± ∞ ¹  +102.48% (p=0.008 n=5)
FrFromOKM                                 699.2n ± ∞ ¹    779.1n ± ∞ ¹         ~ (p=0.151 n=5)
MessagesToFr/msgs=1                       791.4n ± ∞ ¹    716.6n ± ∞ ¹    -9.45% (p=0.016 n=5)
MessagesToFr/msgs=5                       3.146µ ± ∞ ¹    3.054µ ± ∞ ¹         ~ (p=1.000 n=5)
MessagesToFr/msgs=10                      6.185µ ± ∞ ¹    5.854µ ± ∞ ¹         ~ (p=0.310 n=5)
MessagesToFr/msgs=20                      12.08µ ± ∞ ¹    11.65µ ± ∞ ¹         ~ (p=0.095 n=5)
NewCommitmentBuilder/bases=1             374.28µ ± ∞ ¹    88.45µ ± ∞ ¹   -76.37% (p=0.008 n=5)
NewCommitmentBuilder/bases=5              573.9µ ± ∞ ¹    439.5µ ± ∞ ¹   -23.42% (p=0.008 n=5)
NewCommitmentBuilder/bases=10             742.3µ ± ∞ ¹    886.3µ ± ∞ ¹   +19.40% (p=0.008 n=5)
NewCommitmentBuilder/bases=20             1.008m ± ∞ ¹    1.912m ± ∞ ¹   +89.69% (p=0.008 n=5)
ParseSignature                            64.14µ ± ∞ ¹    64.12µ ± ∞ ¹         ~ (p=1.000 n=5)
SignatureToBytes                          203.7n ± ∞ ¹    201.1n ± ∞ ¹         ~ (p=0.310 n=5)
GenerateKeyPair                           203.5µ ± ∞ ¹    198.6µ ± ∞ ¹    -2.41% (p=0.032 n=5)
PublicKeyMarshal                          124.2n ± ∞ ¹    131.4n ± ∞ ¹         ~ (p=0.151 n=5)
UnmarshalPublicKey                        95.34µ ± ∞ ¹    95.55µ ± ∞ ¹         ~ (p=0.056 n=5)
ParseSignatureProof                       320.8µ ± ∞ ¹    321.6µ ± ∞ ¹         ~ (p=0.151 n=5)
Pairing                                   709.6µ ± ∞ ¹    707.4µ ± ∞ ¹         ~ (p=0.310 n=5)
Pairing2                                  928.5µ ± ∞ ¹    925.1µ ± ∞ ¹    -0.37% (p=0.008 n=5)
G1ScalarMul                               87.82µ ± ∞ ¹    86.43µ ± ∞ ¹         ~ (p=1.000 n=5)
G1Add                                     3.658µ ± ∞ ¹    3.673µ ± ∞ ¹         ~ (p=0.841 n=5)
HashToG1                                  87.74µ ± ∞ ¹    86.84µ ± ∞ ¹    -1.03% (p=0.008 n=5)
NewRandomZr                                               214.1n ± ∞ ¹
SumOfG1ProductsCrossover/n=1/pairwise                     85.20µ ± ∞ ¹
SumOfG1ProductsCrossover/n=1/msm                          85.41µ ± ∞ ¹
SumOfG1ProductsCrossover/n=2/pairwise                     172.2µ ± ∞ ¹
SumOfG1ProductsCrossover/n=2/msm                          450.3µ ± ∞ ¹
SumOfG1ProductsCrossover/n=3/pairwise                     264.7µ ± ∞ ¹
SumOfG1ProductsCrossover/n=3/msm                          510.4µ ± ∞ ¹
SumOfG1ProductsCrossover/n=4/pairwise                     348.2µ ± ∞ ¹
SumOfG1ProductsCrossover/n=4/msm                          558.5µ ± ∞ ¹
SumOfG1ProductsCrossover/n=5/pairwise                     442.1µ ± ∞ ¹
SumOfG1ProductsCrossover/n=5/msm                          595.8µ ± ∞ ¹
SumOfG1ProductsCrossover/n=6/msm                          628.4µ ± ∞ ¹
SumOfG1ProductsCrossover/n=6/pairwise                     522.3µ ± ∞ ¹
SumOfG1ProductsCrossover/n=7/pairwise                     607.1µ ± ∞ ¹
SumOfG1ProductsCrossover/n=7/msm                          651.7µ ± ∞ ¹
SumOfG1ProductsCrossover/n=8/pairwise                     695.4µ ± ∞ ¹
SumOfG1ProductsCrossover/n=8/msm                          678.2µ ± ∞ ¹
SumOfG1ProductsCrossover/n=9/msm                          710.5µ ± ∞ ¹
SumOfG1ProductsCrossover/n=9/pairwise                     786.2µ ± ∞ ¹
SumOfG1ProductsCrossover/n=10/pairwise                    884.6µ ± ∞ ¹
SumOfG1ProductsCrossover/n=10/msm                         737.0µ ± ∞ ¹
SumOfG1ProductsCrossover/n=12/pairwise                    1.120m ± ∞ ¹
SumOfG1ProductsCrossover/n=12/msm                         788.9µ ± ∞ ¹
SumOfG1ProductsCrossover/n=16/pairwise                    1.524m ± ∞ ¹
SumOfG1ProductsCrossover/n=16/msm                         908.5µ ± ∞ ¹
SumOfG1ProductsCrossover/n=20/pairwise                    1.919m ± ∞ ¹
SumOfG1ProductsCrossover/n=20/msm                         1.007m ± ∞ ¹
SumOfG1ProductsCrossover/n=32/msm                         1.341m ± ∞ ¹
SumOfG1ProductsCrossover/n=32/pairwise                    3.108m ± ∞ ¹
geomean                                   314.4µ          367.6µ          +1.91%
¹ need >= 6 samples for confidence interval at level 0.95

                                       │ /tmp/base.txt  │             /tmp/head.txt              │
                                       │      B/op      │     B/op       vs base                 │
Sign/msgs=1                              39.147Ki ± ∞ ¹   8.455Ki ± ∞ ¹  -78.40% (p=0.008 n=5)
Sign/msgs=5                               46.92Ki ± ∞ ¹   16.85Ki ± ∞ ¹  -64.09% (p=0.008 n=5)
Sign/msgs=10                              56.54Ki ± ∞ ¹   27.85Ki ± ∞ ¹  -50.74% (p=0.008 n=5)
Sign/msgs=20                              75.62Ki ± ∞ ¹   48.77Ki ± ∞ ¹  -35.51% (p=0.008 n=5)
Verify/msgs=1                             41.37Ki ± ∞ ¹   10.76Ki ± ∞ ¹  -74.00% (p=0.008 n=5)
Verify/msgs=5                             47.39Ki ± ∞ ¹   16.62Ki ± ∞ ¹  -64.94% (p=0.008 n=5)
Verify/msgs=10                            54.71Ki ± ∞ ¹   23.31Ki ± ∞ ¹  -57.39% (p=0.008 n=5)
Verify/msgs=20                            69.92Ki ± ∞ ¹   37.89Ki ± ∞ ¹  -45.81% (p=0.008 n=5)
DeriveProof/msgs=1/revealed=1            147.42Ki ± ∞ ¹   22.30Ki ± ∞ ¹  -84.88% (p=0.008 n=5)
DeriveProof/msgs=5/revealed=3            156.89Ki ± ∞ ¹   30.85Ki ± ∞ ¹  -80.34% (p=0.008 n=5)
DeriveProof/msgs=10/revealed=5           170.45Ki ± ∞ ¹   43.33Ki ± ∞ ¹  -74.58% (p=0.008 n=5)
DeriveProof/msgs=20/revealed=10          192.08Ki ± ∞ ¹   62.19Ki ± ∞ ¹  -67.62% (p=0.008 n=5)
VerifyProof/msgs=1/revealed=1             78.26Ki ± ∞ ¹   16.63Ki ± ∞ ¹  -78.75% (p=0.008 n=5)
VerifyProof/msgs=5/revealed=3             84.09Ki ± ∞ ¹   22.77Ki ± ∞ ¹  -72.92% (p=0.008 n=5)
VerifyProof/msgs=10/revealed=5            91.24Ki ± ∞ ¹   29.71Ki ± ∞ ¹  -67.43% (p=0.008 n=5)
VerifyProof/msgs=20/revealed=10          106.06Ki ± ∞ ¹   45.86Ki ± ∞ ¹  -56.76% (p=0.008 n=5)
SignWithKey/msgs=1                       39.062Ki ± ∞ ¹   8.368Ki ± ∞ ¹  -78.58% (p=0.008 n=5)
SignWithKey/msgs=5                        46.83Ki ± ∞ ¹   16.76Ki ± ∞ ¹  -64.20% (p=0.008 n=5)
SignWithKey/msgs=10                       56.45Ki ± ∞ ¹   27.77Ki ± ∞ ¹  -50.81% (p=0.008 n=5)
SignWithKey/msgs=20                       75.53Ki ± ∞ ¹   48.69Ki ± ∞ ¹  -35.54% (p=0.008 n=5)
ToPublicKeyWithGenerators/msgs=1          3.918Ki ± ∞ ¹   3.918Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=5          10.96Ki ± ∞ ¹   10.96Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=10         19.74Ki ± ∞ ¹   19.74Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=20         37.32Ki ± ∞ ¹   37.32Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
ComputeB/msgs=1                           32633.0 ± ∞ ¹     875.0 ± ∞ ¹  -97.32% (p=0.008 n=5)
ComputeB/msgs=5                          33.157Ki ± ∞ ¹   1.167Ki ± ∞ ¹  -96.48% (p=0.008 n=5)
ComputeB/msgs=10                          35427.0 ± ∞ ¹     987.0 ± ∞ ¹  -97.21% (p=0.008 n=5)
ComputeB/msgs=20                         38.003Ki ± ∞ ¹   1.706Ki ± ∞ ¹  -95.51% (p=0.008 n=5)
FrFromOKM                                   760.0 ± ∞ ¹     760.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=1                         784.0 ± ∞ ¹     784.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=5                       3.836Ki ± ∞ ¹   3.836Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=10                      7.656Ki ± ∞ ¹   7.656Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=20                      15.31Ki ± ∞ ¹   15.31Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
NewCommitmentBuilder/bases=1              31841.0 ± ∞ ¹     648.0 ± ∞ ¹  -97.96% (p=0.008 n=5)
NewCommitmentBuilder/bases=5              33241.0 ± ∞ ¹     971.0 ± ∞ ¹  -97.08% (p=0.008 n=5)
NewCommitmentBuilder/bases=10             34809.0 ± ∞ ¹     763.0 ± ∞ ¹  -97.81% (p=0.008 n=5)
NewCommitmentBuilder/bases=20            37.150Ki ± ∞ ¹   1.487Ki ± ∞ ¹  -96.00% (p=0.008 n=5)
ParseSignature                              296.0 ± ∞ ¹     296.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
SignatureToBytes                            224.0 ± ∞ ¹     224.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
GenerateKeyPair                           2.931Ki ± ∞ ¹   2.931Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
PublicKeyMarshal                            96.00 ± ∞ ¹     96.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
UnmarshalPublicKey                          232.0 ± ∞ ¹     232.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ParseSignatureProof                       1.430Ki ± ∞ ¹   1.430Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing                                   5.438Ki ± ∞ ¹   5.438Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing2                                  6.000Ki ± ∞ ¹   6.000Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
G1ScalarMul                                 608.0 ± ∞ ¹     608.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
G1Add                                       97.00 ± ∞ ¹     97.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
HashToG1                                  1.551Ki ± ∞ ¹   1.551Ki ± ∞ ¹        ~ (p=1.000 n=5) ²
NewRandomZr                                                 80.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/pairwise                       633.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/msm                            665.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/pairwise                       124.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/msm                          31.42Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=3/pairwise                       756.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/msm                          31.75Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=4/pairwise                       244.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/msm                          32.09Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=5/pairwise                       876.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/msm                          32.37Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=6/msm                          32.65Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=6/pairwise                       364.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/pairwise                       996.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/msm                          32.97Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=8/pairwise                       484.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=8/msm                          33.22Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=9/msm                          33.53Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=9/pairwise                     1.090Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=10/pairwise                      604.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=10/msm                         33.84Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=12/pairwise                      724.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=12/msm                         34.34Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=16/pairwise                      964.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=16/msm                         35.47Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=20/pairwise                    1.176Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=20/msm                         36.84Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=32/msm                         39.97Ki ± ∞ ¹
SumOfG1ProductsCrossover/n=32/pairwise                    1.879Ki ± ∞ ¹
geomean                                   13.79Ki         4.292Ki        -64.88%
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal

                                       │ /tmp/base.txt │            /tmp/head.txt             │
                                       │   allocs/op   │  allocs/op   vs base                 │
Sign/msgs=1                                254.0 ± ∞ ¹   110.0 ± ∞ ¹  -56.69% (p=0.008 n=5)
Sign/msgs=5                                324.0 ± ∞ ¹   188.0 ± ∞ ¹  -41.98% (p=0.008 n=5)
Sign/msgs=10                               406.0 ± ∞ ¹   298.0 ± ∞ ¹  -26.60% (p=0.008 n=5)
Sign/msgs=20                               568.0 ± ∞ ¹   490.0 ± ∞ ¹  -13.73% (p=0.008 n=5)
Verify/msgs=1                             216.00 ± ∞ ¹   88.00 ± ∞ ¹  -59.26% (p=0.008 n=5)
Verify/msgs=5                              274.0 ± ∞ ¹   152.0 ± ∞ ¹  -44.53% (p=0.008 n=5)
Verify/msgs=10                             344.0 ± ∞ ¹   219.0 ± ∞ ¹  -36.34% (p=0.008 n=5)
Verify/msgs=20                             484.0 ± ∞ ¹   379.0 ± ∞ ¹  -21.69% (p=0.008 n=5)
DeriveProof/msgs=1/revealed=1              841.0 ± ∞ ¹   269.0 ± ∞ ¹  -68.01% (p=0.008 n=5)
DeriveProof/msgs=5/revealed=3              933.0 ± ∞ ¹   359.0 ± ∞ ¹  -61.52% (p=0.008 n=5)
DeriveProof/msgs=10/revealed=5            1047.0 ± ∞ ¹   477.0 ± ∞ ¹  -54.44% (p=0.008 n=5)
DeriveProof/msgs=20/revealed=10           1257.0 ± ∞ ¹   684.0 ± ∞ ¹  -45.58% (p=0.008 n=5)
VerifyProof/msgs=1/revealed=1              428.0 ± ∞ ¹   170.0 ± ∞ ¹  -60.28% (p=0.008 n=5)
VerifyProof/msgs=5/revealed=3              498.0 ± ∞ ¹   244.0 ± ∞ ¹  -51.00% (p=0.008 n=5)
VerifyProof/msgs=10/revealed=5             571.0 ± ∞ ¹   312.0 ± ∞ ¹  -45.36% (p=0.008 n=5)
VerifyProof/msgs=20/revealed=10            735.0 ± ∞ ¹   504.0 ± ∞ ¹  -31.43% (p=0.008 n=5)
SignWithKey/msgs=1                         251.0 ± ∞ ¹   107.0 ± ∞ ¹  -57.37% (p=0.008 n=5)
SignWithKey/msgs=5                         321.0 ± ∞ ¹   185.0 ± ∞ ¹  -42.37% (p=0.008 n=5)
SignWithKey/msgs=10                        403.0 ± ∞ ¹   295.0 ± ∞ ¹  -26.80% (p=0.008 n=5)
SignWithKey/msgs=20                        565.0 ± ∞ ¹   487.0 ± ∞ ¹  -13.81% (p=0.008 n=5)
ToPublicKeyWithGenerators/msgs=1           55.00 ± ∞ ¹   55.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=5           159.0 ± ∞ ¹   159.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=10          289.0 ± ∞ ¹   289.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ToPublicKeyWithGenerators/msgs=20          549.0 ± ∞ ¹   549.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
ComputeB/msgs=1                           150.00 ± ∞ ¹   20.00 ± ∞ ¹  -86.67% (p=0.008 n=5)
ComputeB/msgs=5                           152.00 ± ∞ ¹   24.00 ± ∞ ¹  -84.21% (p=0.008 n=5)
ComputeB/msgs=10                          152.00 ± ∞ ¹   16.00 ± ∞ ¹  -89.47% (p=0.008 n=5)
ComputeB/msgs=20                          152.00 ± ∞ ¹   26.00 ± ∞ ¹  -82.89% (p=0.008 n=5)
FrFromOKM                                  11.00 ± ∞ ¹   11.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=1                        13.00 ± ∞ ¹   13.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=5                        61.00 ± ∞ ¹   61.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=10                       121.0 ± ∞ ¹   121.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
MessagesToFr/msgs=20                       241.0 ± ∞ ¹   241.0 ± ∞ ¹        ~ (p=1.000 n=5) ²
NewCommitmentBuilder/bases=1              144.00 ± ∞ ¹   16.00 ± ∞ ¹  -88.89% (p=0.008 n=5)
NewCommitmentBuilder/bases=5              150.00 ± ∞ ¹   20.00 ± ∞ ¹  -86.67% (p=0.008 n=5)
NewCommitmentBuilder/bases=10             150.00 ± ∞ ¹   12.00 ± ∞ ¹  -92.00% (p=0.008 n=5)
NewCommitmentBuilder/bases=20             150.00 ± ∞ ¹   22.00 ± ∞ ¹  -85.33% (p=0.008 n=5)
ParseSignature                             7.000 ± ∞ ¹   7.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
SignatureToBytes                           4.000 ± ∞ ¹   4.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
GenerateKeyPair                            42.00 ± ∞ ¹   42.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
PublicKeyMarshal                           1.000 ± ∞ ¹   1.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
UnmarshalPublicKey                         3.000 ± ∞ ¹   3.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
ParseSignatureProof                        34.00 ± ∞ ¹   34.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing                                    25.00 ± ∞ ¹   25.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
Pairing2                                   25.00 ± ∞ ¹   25.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
G1ScalarMul                                13.00 ± ∞ ¹   13.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
G1Add                                      1.000 ± ∞ ¹   1.000 ± ∞ ¹        ~ (p=1.000 n=5) ²
HashToG1                                   25.00 ± ∞ ¹   25.00 ± ∞ ¹        ~ (p=1.000 n=5) ²
NewRandomZr                                              2.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/pairwise                    14.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=1/msm                         16.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/pairwise                    2.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=2/msm                         144.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/pairwise                    16.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=3/msm                         146.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/pairwise                    4.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=4/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/pairwise                    18.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=5/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=6/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=6/pairwise                    6.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/pairwise                    20.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=7/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=8/pairwise                    8.000 ± ∞ ¹
SumOfG1ProductsCrossover/n=8/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=9/msm                         148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=9/pairwise                    22.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=10/pairwise                   10.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=10/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=12/pairwise                   12.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=12/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=16/pairwise                   16.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=16/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=20/pairwise                   20.00 ± ∞ ¹
SumOfG1ProductsCrossover/n=20/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=32/msm                        148.0 ± ∞ ¹
SumOfG1ProductsCrossover/n=32/pairwise                   32.00 ± ∞ ¹
geomean                                    114.6         50.39        -44.81%
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal

pkg: github.com/IBM/idemix/bccsp
                          │ /tmp/base.txt │            /tmp/head.txt            │
                          │    sec/op     │    sec/op     vs base               │
_SignVerify/sign-legacy      2.950m ± ∞ ¹   2.942m ± ∞ ¹        ~ (p=0.548 n=5)
_SignVerify/verify-legacy    4.666m ± ∞ ¹   4.680m ± ∞ ¹        ~ (p=0.690 n=5)
_SignVerify/sign-aries       6.053m ± ∞ ¹   4.219m ± ∞ ¹  -30.29% (p=0.008 n=5)
_SignVerify/verify-aries     4.895m ± ∞ ¹   4.011m ± ∞ ¹  -18.05% (p=0.008 n=5)
geomean                      4.494m         3.907m        -13.06%
¹ need >= 6 samples for confidence interval at level 0.95

pkg: github.com/IBM/idemix/bccsp/schemes/aries
                               │ /tmp/base.txt │            /tmp/head.txt            │
                               │    sec/op     │    sec/op     vs base               │
IssuerNewKey                      842.8µ ± ∞ ¹   842.6µ ± ∞ ¹        ~ (p=0.421 n=5)
IssuerNewKeyFromBytes             792.1µ ± ∞ ¹   795.1µ ± ∞ ¹        ~ (p=0.690 n=5)
IssuerNewPublicKeyFromBytes       685.5µ ± ∞ ¹   690.5µ ± ∞ ¹        ~ (p=0.095 n=5)
UserMakeNym                       466.6µ ± ∞ ¹   191.9µ ± ∞ ¹  -58.87% (p=0.008 n=5)
CredRequestBlind                 1546.5µ ± ∞ ¹   991.0µ ± ∞ ¹  -35.92% (p=0.008 n=5)
CredRequestBlindVerify            1.324m ± ∞ ¹   1.097m ± ∞ ¹  -17.15% (p=0.008 n=5)
CredRequestUnblind                65.60µ ± ∞ ¹   65.95µ ± ∞ ¹        ~ (p=0.310 n=5)
CredSign                          2.568m ± ∞ ¹   1.843m ± ∞ ¹  -28.24% (p=0.008 n=5)
CredVerify                        1.817m ± ∞ ¹   1.801m ± ∞ ¹   -0.86% (p=0.008 n=5)
SignerSign/Standard               4.193m ± ∞ ¹   3.287m ± ∞ ¹  -21.62% (p=0.008 n=5)
SignerSign/EidNym                 5.103m ± ∞ ¹   3.659m ± ∞ ¹  -28.30% (p=0.008 n=5)
SignerSign/EidNymRhNym            6.016m ± ∞ ¹   4.072m ± ∞ ¹  -32.32% (p=0.008 n=5)
SignerVerify/Basic                3.228m ± ∞ ¹   2.718m ± ∞ ¹  -15.80% (p=0.008 n=5)
SignerVerify/ExpectEidNym         3.902m ± ∞ ¹   3.143m ± ∞ ¹  -19.45% (p=0.008 n=5)
SignerVerify/ExpectEidNymRhNym    4.559m ± ∞ ¹   3.571m ± ∞ ¹  -21.68% (p=0.008 n=5)
NymSignerSign                     475.7µ ± ∞ ¹   197.0µ ± ∞ ¹  -58.59% (p=0.008 n=5)
NymSignerVerify                   579.5µ ± ∞ ¹   337.2µ ± ∞ ¹  -41.81% (p=0.008 n=5)
RevocationSign                    241.5µ ± ∞ ¹   244.7µ ± ∞ ¹        ~ (p=0.095 n=5)
RevocationVerify                  687.8µ ± ∞ ¹   688.3µ ± ∞ ¹        ~ (p=1.000 n=5)
AuditNymEid                       220.8µ ± ∞ ¹   220.7µ ± ∞ ¹        ~ (p=0.841 n=5)
AuditNymRh                        219.6µ ± ∞ ¹   221.0µ ± ∞ ¹        ~ (p=0.056 n=5)
geomean                           1.038m         824.1µ        -20.62%
¹ need >= 6 samples for confidence interval at level 0.95

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant