bitcoinj / secp256k1-jdk

Java library providing Bitcoin-related Elliptic Curve Cryptography
Apache License 2.0
8 stars 3 forks source link

WIP: Graal native-image build of Java Schnorr Example #29

Open msgilligan opened 5 months ago

msgilligan commented 5 months ago

To build native image use:

./gradlew secp256k1-examples-java:nativeCompile

Build currently fails on macOS with:

Error: Support for the Foreign Function and Memory API is currently available only on the AMD64 architecture

Note: the implementation of FF&M (Panama) in native-image is incomplete. See: https://github.com/oracle/graal/issues/8113

msgilligan commented 5 months ago

It also looks like some additional build configuration will be required: https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/ForeignInterface.md

Update: The PR now includes this work (a somewhat rushed job of it, I must admit) but should build and run on AMD64 machines.

schildbach commented 5 months ago

As already mentioned elsewhere, I was able to build and run this successfully:

$ LD_LIBRARY_PATH=/nix/store/1c403w3lffz5p21lqqcvryh56ib0i28q-secp256k1-0.4.1/lib time -v secp256k1-examples-java/build/schnorrRunning secp256k1-jdk Schnorr example...
Is the signature valid? true
Secret Key: c6bf161b6530f588451b3790140722eb6de756164efc49baa1387f16b9089dac
Public Key (as ECPoint): 70176dcf4283032d089003785fce826ed7fa8e58c6a6a82ac27db4378d46ce50
Signature: 7ec2637314505842493670018a2e9b67ac0f63faf207640da4c206c2b2e89dcdaf0349608d40bec4c9f18ea2028eee70defd2e5bae1b7cada886ae88cfa7badd
    Command being timed: "secp256k1-examples-java/build/schnorr"
    User time (seconds): 0.00
    System time (seconds): 0.00
    Percent of CPU this job got: 100%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
    Average shared text size (kbytes): 0
    Average unshared data size (kbytes): 0
    Average stack size (kbytes): 0
    Average total size (kbytes): 0
    Maximum resident set size (kbytes): 19520
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 1225
    Voluntary context switches: 12
    Involuntary context switches: 1
    Swaps: 0
    File system inputs: 0
    File system outputs: 0
    Socket messages sent: 0
    Socket messages received: 0
    Signals delivered: 0
    Page size (bytes): 4096
    Exit status: 0