- Add comprehensive AUDIT_COVERAGE.md documenting all 46 audit modules across 8 sections with ~1M+ total assertions - Pure ASCII cleanup: remove all Unicode from source/cmake/script files (box-drawing, arrows, Greek, emoji, BOM, Georgian in comments) - CT fix: RISC-V is_zero_mask (seqz+neg inline asm) - CT fix: ct_compare general path (snez) - All 188 files updated for ASCII-only compliance (Section 17 rule) - Verified: 46/46 audit PASS on X64, ARM64, RISC-V (QEMU + Mars HW) - Verified: 24/24 CTest PASS on X64
1.8 KiB
1.8 KiB
UltrafastSecp256k1 -- Android Port
Full CPU port of UltrafastSecp256k1 for Android (ARM64, ARMv7, x86_64, x86).
Quick Build
# Set NDK path
export ANDROID_NDK_HOME=/path/to/android-ndk-r26c
# Build ARM64 (primary target)
./build_android.sh arm64-v8a
# Build all ABIs
./build_android.sh
Output
output/jniLibs/
+-- arm64-v8a/libsecp256k1_jni.so
+-- armeabi-v7a/libsecp256k1_jni.so
+-- x86_64/libsecp256k1_jni.so
+-- x86/libsecp256k1_jni.so
Usage (Kotlin)
import com.secp256k1.native.Secp256k1
// Initialize once
Secp256k1.init()
// Key generation (constant-time -- side-channel safe)
val pubkey = Secp256k1.ctScalarMulGenerator(privkeyBytes)
// ECDH (constant-time)
val secret = Secp256k1.ctEcdh(myPrivkey, theirPubkey)
// Fast operations (public data only)
val g = Secp256k1.getGenerator()
val sum = Secp256k1.pointAdd(p1, p2)
Project Structure
android/
+-- CMakeLists.txt -- Android CMake build
+-- build_android.sh -- Linux/macOS build script
+-- build_android.ps1 -- Windows build script
+-- jni/secp256k1_jni.cpp -- JNI bridge (C++ <-> Java/Kotlin)
+-- kotlin/.../Secp256k1.kt -- Kotlin wrapper
+-- example/ -- Example Android app
See Android Guide for full documentation.
Benchmarks (RK3588, Cortex-A55/A76, ARM64 ASM)
| Operation | Time |
|---|---|
| field_mul (a*b mod p) | 85 ns |
| field_sqr (a^2 mod p) | 66 ns |
| field_add (a+b mod p) | 18 ns |
| field_sub (a-b mod p) | 16 ns |
| field_inverse | 2,621 ns |
| fast scalar_mul (k*G) | 7.6 us |
| fast scalar_mul (k*P) | 77.6 us |
| CT scalar_mul (k*G) | 545 us |
| ECDH (full CT) | 545 us |
Backend: ARM64 inline assembly (MUL/UMULH). ~5x faster than generic C++.