fix: align all 3 benchmarks to identical operation set

All 3 platform benchmarks (Android, JVM, K/Native) now measure the
same core operations for cross-platform comparability:

  verifySchnorr        — strict BIP-340
  verifySchnorrFast    — Nostr x-check only (no y-parity inversion)
  signSchnorr          — derives pubkey each time
  signSchnorr(cached)  — pre-computed x-only pubkey
  compressedPubKeyFor  — create + compress
  secKeyVerify         — key validation
  privKeyTweakAdd      — BIP-32 key derivation
  ecdhXOnly            — Nostr ECDH (NIP-04/44)
  batch verify (8, 16) — same-pubkey batch

Changes:
- Android: added signSchnorrCachedPkOurs, ecdhXOnly/ecdhXOnlyOurs
  (replaced pubKeyTweakMulCompact naming)
- JVM: removed pubkeyCreate and pubKeyCompress (subsets of
  compressedPubKeyFor, not measured on other platforms)
- K/Native: added verifySchnorrFast

K/Native retains field micro-benchmarks (FieldP.mul/sqr/add/sub/inv,
unsignedMultiplyHigh, uLt) as a K/N-specific diagnostic tool.

https://claude.ai/code/session_01EMY5RnXb9rnsyU2KbXrSaY
This commit is contained in:
Claude
2026-04-09 15:02:39 +00:00
parent b3206b8e48
commit da64a4a4d3
3 changed files with 38 additions and 59 deletions
@@ -201,36 +201,6 @@ class Secp256k1Benchmark {
},
)
// --- pubkeyCreate ---
results +=
bench(
name = "pubkeyCreate",
warmup = 1000,
iterations = 5000,
nativeOp = { native.pubkeyCreate(privKey) },
kotlinOp = {
com.vitorpamplona.quartz.utils.secp256k1.Secp256k1
.pubkeyCreate(privKey)
},
)
// --- pubKeyCompress ---
val uncompressedNative = native.pubkeyCreate(privKey)
val uncompressedKotlin =
com.vitorpamplona.quartz.utils.secp256k1.Secp256k1
.pubkeyCreate(privKey)
results +=
bench(
name = "pubKeyCompress",
warmup = 2000,
iterations = 50000,
nativeOp = { native.pubKeyCompress(uncompressedNative) },
kotlinOp = {
com.vitorpamplona.quartz.utils.secp256k1.Secp256k1
.pubKeyCompress(uncompressedKotlin)
},
)
// --- compressedPubKeyFor (create + compress combined) ---
results +=
bench(
@@ -125,6 +125,12 @@ class Secp256k1NativeBenchmark {
Secp256k1.verifySchnorr(sig, msg32, xOnlyPub)
}
// --- verifySchnorrFast (Nostr: x-check only, no y-parity inversion) ---
results +=
bench("verifySchnorrFast", 2000, 5000) {
Secp256k1.verifySchnorrFast(sig, msg32, xOnlyPub)
}
// --- signSchnorr (derives pubkey each time) ---
results +=
bench("signSchnorr", 1000, 3000) {