2ad1a48123
The custom C secp256k1 implementation under quartz/src/main/c/ was never
wired into Gradle (no externalNativeBuild block) and only existed for the
3-way benchmark + cross-validation test against ACINQ on JVM/Android.
The C library has been split out to vitorpamplona/libschnorr256k1{,-kmp},
so the in-repo copy is dead weight.
This change replaces it with the published Maven Central artifact
`com.vitorpamplona:schnorr256k1-kmp:1.0.0`, scoped to test/benchmark
configurations only — production crypto continues to use ACINQ
secp256k1-kmp on JVM/Android and the pure-Kotlin Secp256k1 on native.
The Android AAR ships libschnorr256k1_jni.so for arm64-v8a and x86_64,
so the Android benchmark now exercises the C row automatically (no more
manual build_android.sh). On JVM the .so still has to be installed by the
developer; the cross-validation test and triple-benchmark gracefully skip
the C row when System.loadLibrary fails, matching prior behavior.
Verified on JVM: all 13 secp256k1 jvmTest classes pass (188 tests), and
ACINQ vs pure-Kotlin benchmark numbers match the documented baseline
within sandbox noise (verifySchnorr ~15k ops/s, signSchnorr cached
~33k ops/s, pubkeyCreate+Compress ~36k ops/s).
Removes ~5,100 LOC: quartz/src/main/c/ (4,500), Secp256k1InstanceC.*
expect/actual shim (560), Secp256k1C JNI declaration object.
https://claude.ai/code/session_01KnvpK2amcVZKfFiZJvHjVe
74 lines
2.5 KiB
Groovy
74 lines
2.5 KiB
Groovy
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
|
|
|
plugins {
|
|
alias(libs.plugins.androidLibrary)
|
|
alias(libs.plugins.androidBenchmark)
|
|
}
|
|
|
|
android {
|
|
namespace = 'com.vitorpamplona.amethyst.benchmark'
|
|
compileSdk = libs.versions.android.compileSdk.get().toInteger()
|
|
|
|
defaultConfig {
|
|
minSdk = libs.versions.android.minSdk.get().toInteger()
|
|
targetSdk = libs.versions.android.targetSdk.get().toInteger()
|
|
|
|
// Enable measuring on an emulator, or devices with low battery
|
|
testInstrumentationRunner 'androidx.benchmark.junit4.AndroidBenchmarkRunner'
|
|
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "EMULATOR,LOW-BATTERY"
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility JavaVersion.VERSION_21
|
|
targetCompatibility JavaVersion.VERSION_21
|
|
}
|
|
|
|
sourceSets.androidTest.resources.srcDirs += ["../quartz/src/androidDeviceTest/resources"]
|
|
|
|
testBuildType = "benchmark"
|
|
buildTypes {
|
|
debug {
|
|
// Since debuggable can"t be modified by gradle for library modules,
|
|
// it must be done in a manifest - see src/androidTest/AndroidManifest.xml
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "benchmark-proguard-rules.pro"
|
|
}
|
|
release {
|
|
isDefault = false
|
|
minifyEnabled = true
|
|
}
|
|
create("benchmark") {
|
|
isDefault = true
|
|
initWith(getByName("release"))
|
|
signingConfig = signingConfigs.debug
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
jvmTarget = JvmTarget.JVM_21
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation libs.androidx.core.ktx
|
|
androidTestImplementation platform(libs.androidx.compose.bom)
|
|
androidTestImplementation libs.androidx.runner
|
|
androidTestImplementation libs.androidx.junit
|
|
androidTestImplementation libs.junit
|
|
androidTestImplementation libs.androidx.benchmark.junit4
|
|
androidTestImplementation project(path: ':quartz')
|
|
androidTestImplementation project(path: ':commons')
|
|
androidTestImplementation project(path: ':ammolite')
|
|
|
|
// Custom C secp256k1 (libschnorr256k1) for the 3-way Android benchmark
|
|
androidTestImplementation libs.schnorr256k1.kmp
|
|
|
|
androidTestImplementation libs.androidx.compose.foundation
|
|
|
|
// Add your dependencies here. Note that you cannot benchmark code
|
|
// in an app module this way - you will need to move any code you
|
|
// want to benchmark to a library module:
|
|
// https://developer.android.com/studio/projects/android-library#Convert
|
|
} |