Skip to content

Commit

Permalink
Rename secp256k1 to secp for modules, packages, directories
Browse files Browse the repository at this point in the history
And related places in the build files and documentation

This eliminates warnings from the compiler about module names ending
in a digit and reduces general verbosity.

The current intention is to leave full Secp256K1 prefix on the types
(classes) because they do refer to that specific ECC curve.
  • Loading branch information
msgilligan committed Aug 20, 2024
1 parent 8ce53d5 commit bfcdeca
Show file tree
Hide file tree
Showing 77 changed files with 237 additions and 237 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
- name: Build with Gradle
run: ./gradlew build
- name: Run Java (Schnorr) Example
run: ./gradlew secp256k1-examples-java:run
run: ./gradlew secp-examples-java:run
- name: Run Kotlin (Schnorr) Example
run: ./gradlew secp256k1-examples-kotlin:run
run: ./gradlew secp-examples-kotlin:run
12 changes: 6 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ WARNING:: This prototype software has had limited testing and has not been revie
The API is based on the `C-language` API of https://github.com/bitcoin-core/secp256k1[bitcoin-core/secp256k1], but adapted
to modern, idiomatic, functional-style Java and to use Elliptic Curve types from the Java Class Library, such as https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/interfaces/ECPublicKey.html[ECPublicKey] where appropriate.

The API is distributed as an API-only JAR (```secp256k1-api-_version_.jar```) and we expect that there will be multiple implementations of the API. The API JAR currently requires JDK 17 or later but we may backport it to an earlier version (possibly JDK 11) in a future release depending upon feedback from the community.
The API is distributed as an API-only JAR (```secp-api-_version_.jar```) and we expect that there will be multiple implementations of the API. The API JAR currently requires JDK 17 or later but we may backport it to an earlier version (possibly JDK 11) in a future release depending upon feedback from the community.

NOTE:: At this point, we are especially interested in feedback on the API.

== libsecp256k1 Panama Implementation (JDK 22+)

The provided proof-of-concept implementation uses the https://github.com/bitcoin-core/secp256k1[bitcoin-core/secp256k1] C-language library via https://openjdk.org/jeps/454[JEP-454: Foreign Function & Memory API] (known as **Panama**.) It is provided in a separate JAR (```secp256k1-foreign-_version_.jar```) that requires JDK 22 or later.

Panama is available in https://openjdk.org/projects/jdk/22/[OpenJDK 22] and later. We anticipate `secp256k1-foreign` will be
the recommended/preferred `secp256k1-api` implementation for use in projects using modern JVMs.
Panama is available in https://openjdk.org/projects/jdk/22/[OpenJDK 22] and later. We anticipate `secp256k1-ffm` will be
the recommended/preferred `secp-api` implementation for use in projects using modern JVMs.

The minimum required JDK for this module will likely be incremented with each new JDK release, with a target of requiring JDK 25 (the next LTS release of the JDK) for the 1.0 release of `secp256k1-foreign`.
The minimum required JDK for this module will likely be incremented with each new JDK release, with a target of requiring JDK 25 (the next LTS release of the JDK) for the 1.0 release of `secp256k1-ffm`.

WARNING:: This is a preliminary implementation provided for experimentation and feedback and should not be used in real applications.

Expand Down Expand Up @@ -116,9 +116,9 @@ To extract the libsecp256k1 headers into Java classes via `jextract` using the `
. `nix develop`
. `./extract-headers.sh`

The extracted headers will be writen to `./build/org/bitcoinj/secp256k1/foreign/jextract`. You can compare the generated headers with the checked-in headers with:
The extracted headers will be writen to `./build/org/bitcoinj/secp/ffm/jextract`. You can compare the generated headers with the checked-in headers with:

. `diff -r secp256k1-foreign/src/main/java/org/bitcoinj/secp256k1/foreign/jextract build/org/bitcoinj/secp256k1/foreign/jextract`
. `diff -r secp-ffm/src/main/java/org/bitcoinj/secp/ffm/jextract build/org/bitcoinj/secp/ffm/jextract`


== Reporting a vulnerability
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ subprojects {
apply plugin: 'groovy'
//apply plugin: 'test-report-aggregation'

version = secp256k1Version // set in gradle.properties
group = 'org.bitcoinj.secp256k1'
version = secpVersion // set in gradle.properties
group = 'org.bitcoinj.secp'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion extract-headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# `nix profile install jextract`)
INC_PATH="$HOME/.nix-profile/include/"
mkdir -p build
jextract --target-package org.bitcoinj.secp256k1.foreign.jextract \
jextract --target-package org.bitcoinj.secp.ffm.jextract \
--output build \
--use-system-load-library \
-lsecp256k1 \
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
secp256k1Version = 0.0.1
secpVersion = 0.0.1

# Major (whole number) version of JDK to use for javac, jlink, jpackage, etc.
javaToolchainVersion = 22
Expand Down
2 changes: 1 addition & 1 deletion secp256k1-api/build.gradle → secp-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tasks.withType(JavaCompile).configureEach {
options.release = 17
}

ext.moduleName = 'org.bitcoinj.secp256k1.api'
ext.moduleName = 'org.bitcoinj.secp.api'

dependencies {
api("org.jspecify:jspecify:1.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
* limitations under the License.
*/
@org.jspecify.annotations.NullMarked
module org.bitcoinj.secp256k1.bitcoinj {
requires org.bitcoinj.secp256k1.api;
requires org.bitcoinj.secp256k1.foreign;
module org.bitcoinj.secp.api {
requires org.jspecify;

exports org.bitcoinj.secp.api;

uses org.bitcoinj.secp.api.Secp256k1Provider;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

/**
* A single object with a private and public key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

import java.math.BigInteger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

import java.math.BigInteger;
import java.security.interfaces.ECPrivateKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

import java.math.BigInteger;
import java.security.interfaces.ECPublicKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

/**
* Functional-style result for secp256k1. Returns either {@link Ok} or {@link Err}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

import java.io.Closeable;
import java.math.BigInteger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

import java.util.NoSuchElementException;
import java.util.Optional;
Expand Down Expand Up @@ -72,7 +72,7 @@ static Optional<Secp256k1Provider> findFirst(Predicate<Secp256k1Provider> filter
}

/**
* Find the default provider. This is currently the "ffm" (foreign) provider.
* Find the default provider. This is currently the "ffm" provider.
* @param provider a candidate provider
* @return true if it should be "found"
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.api;
package org.bitcoinj.secp.api;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ tasks.withType(JavaCompile).configureEach {
//options.release = 22
}

ext.moduleName = 'org.bitcoinj.secp256k1.bitcoinj'
ext.moduleName = 'org.bitcoinj.secp.bitcoinj'

dependencies {
api project(':secp256k1-api')
api project(':secp-api')
api("org.bitcoinj:bitcoinj-core:0.17-alpha3");

implementation project(':secp256k1-bouncy')
implementation project(':secp256k1-ffm')
implementation project(':secp-bouncy')
implementation project(':secp-ffm')
}

jar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
* limitations under the License.
*/
@org.jspecify.annotations.NullMarked
module org.bitcoinj.secp256k1.api {
module org.bitcoinj.secp.bitcoinj {
requires org.bitcoinj.secp.api;
requires org.bitcoinj.secp.ffm;
requires org.jspecify;

exports org.bitcoinj.secp256k1.api;

uses org.bitcoinj.secp256k1.api.Secp256k1Provider;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.bitcoinj;
package org.bitcoinj.secp.bitcoinj;

import org.bitcoinj.secp256k1.api.P256K1XOnlyPubKey;
import org.bitcoinj.secp256k1.api.P256k1PubKey;
import org.bitcoinj.secp256k1.api.Secp256k1;
import org.bitcoinj.secp256k1.ffm.PubKeyPojo;
import org.bitcoinj.secp.api.P256K1XOnlyPubKey;
import org.bitcoinj.secp.api.P256k1PubKey;
import org.bitcoinj.secp.api.Secp256k1;
import org.bitcoinj.secp.ffm.PubKeyPojo;

import java.math.BigInteger;
import java.nio.ByteBuffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
* If/when a future version of bitcoinj supports secp256k1-jdk and/or Schnorr signatures, this package will likely
* no longer be needed and will be deprecated.
*/
package org.bitcoinj.secp256k1.bitcoinj;
package org.bitcoinj.secp.bitcoinj;
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.bitcoinj;
package org.bitcoinj.secp.bitcoinj;

import org.bitcoinj.base.Address;
import org.bitcoinj.base.BitcoinNetwork;
import org.bitcoinj.base.Network;
import org.bitcoinj.base.SegwitAddress;
import org.bitcoinj.crypto.ECKey;
import org.bitcoinj.secp256k1.api.P256K1KeyPair;
import org.bitcoinj.secp256k1.api.P256K1XOnlyPubKey;
import org.bitcoinj.secp256k1.api.P256k1PubKey;
import org.bitcoinj.secp256k1.api.Secp256k1;
import org.bitcoinj.secp256k1.bouncy.Bouncy256k1;
import org.bitcoinj.secp256k1.bouncy.BouncyPrivKey;
import org.bitcoinj.secp256k1.bouncy.BouncyPubKey;
import org.bitcoinj.secp256k1.ffm.PubKeyPojo;
import org.bitcoinj.secp.api.P256K1KeyPair;
import org.bitcoinj.secp.api.P256K1XOnlyPubKey;
import org.bitcoinj.secp.api.P256k1PubKey;
import org.bitcoinj.secp.api.Secp256k1;
import org.bitcoinj.secp.bouncy.Bouncy256k1;
import org.bitcoinj.secp.bouncy.BouncyPrivKey;
import org.bitcoinj.secp.bouncy.BouncyPubKey;
import org.bitcoinj.secp.ffm.PubKeyPojo;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -39,7 +39,7 @@
import java.util.HexFormat;
import java.util.stream.Stream;

import static org.bitcoinj.secp256k1.bitcoinj.WitnessMaker.calcTweak;
import static org.bitcoinj.secp.bitcoinj.WitnessMaker.calcTweak;

/**
*
Expand Down
4 changes: 2 additions & 2 deletions secp256k1-bouncy/build.gradle → secp-bouncy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ tasks.withType(JavaCompile).configureEach {
options.release = 17
}

ext.moduleName = 'org.bitcoinj.secp256k1.bouncy'
ext.moduleName = 'org.bitcoinj.secp.bouncy'

dependencies {
api project(':secp256k1-api')
api project(':secp-api')
api 'org.bouncycastle:bcprov-jdk18on:1.77' // TODO: Make this a non-API dependency, see BouncyPrivKey
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/
@org.jspecify.annotations.NullMarked
module org.bitcoinj.secp256k1.bouncy {
requires org.bitcoinj.secp256k1.api;
module org.bitcoinj.secp.bouncy {
requires org.bitcoinj.secp.api;
requires org.bouncycastle.provider;
requires org.jspecify;

provides org.bitcoinj.secp256k1.api.Secp256k1Provider with org.bitcoinj.secp256k1.bouncy.BouncyProvider;
provides org.bitcoinj.secp.api.Secp256k1Provider with org.bitcoinj.secp.bouncy.BouncyProvider;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.bouncy;

import org.bitcoinj.secp256k1.api.CompressedPubKeyData;
import org.bitcoinj.secp256k1.api.CompressedSignatureData;
import org.bitcoinj.secp256k1.api.P256K1KeyPair;
import org.bitcoinj.secp256k1.api.P256K1XOnlyPubKey;
import org.bitcoinj.secp256k1.api.P256k1PrivKey;
import org.bitcoinj.secp256k1.api.P256k1PubKey;
import org.bitcoinj.secp256k1.api.Result;
import org.bitcoinj.secp256k1.api.Secp256k1;
import org.bitcoinj.secp256k1.api.SignatureData;
package org.bitcoinj.secp.bouncy;

import org.bitcoinj.secp.api.CompressedPubKeyData;
import org.bitcoinj.secp.api.CompressedSignatureData;
import org.bitcoinj.secp.api.P256K1KeyPair;
import org.bitcoinj.secp.api.P256K1XOnlyPubKey;
import org.bitcoinj.secp.api.P256k1PrivKey;
import org.bitcoinj.secp.api.P256k1PubKey;
import org.bitcoinj.secp.api.Result;
import org.bitcoinj.secp.api.Secp256k1;
import org.bitcoinj.secp.api.SignatureData;
import org.bouncycastle.asn1.x9.X9ECParameters;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.ec.CustomNamedCurves;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.bouncy;
package org.bitcoinj.secp.bouncy;

import org.bitcoinj.secp256k1.api.P256K1KeyPair;
import org.bitcoinj.secp.api.P256K1KeyPair;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.bouncy;
package org.bitcoinj.secp.bouncy;

import org.bitcoinj.secp256k1.api.P256k1PrivKey;
import org.bitcoinj.secp.api.P256k1PrivKey;
import org.bouncycastle.math.ec.custom.sec.SecP256K1FieldElement;

import java.math.BigInteger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.bitcoinj.secp256k1.bouncy;
package org.bitcoinj.secp.bouncy;

import org.bitcoinj.secp256k1.api.Secp256k1;
import org.bitcoinj.secp256k1.api.Secp256k1Provider;
import org.bitcoinj.secp.api.Secp256k1;
import org.bitcoinj.secp.api.Secp256k1Provider;

/**
*
Expand Down
Loading

0 comments on commit bfcdeca

Please sign in to comment.