Skip to content

Commit

Permalink
Merge pull request #4 from cdottori-stark/master
Browse files Browse the repository at this point in the history
JDK1.8+ compatibility
  • Loading branch information
matheuscferraz authored Jan 7, 2020
2 parents 8e803f4 + cfa7770 commit 65f69e0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 29 deletions.
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,39 @@

### Overview

This is a Java fork of [ecdsa-python]
This is a pure Java implementation of the Elliptic Curve Digital Signature Algorithm (ECDSA). It is compatible with Java 8+ and OpenSSL. It uses some elegant math such as Jacobian Coordinates to speed up the ECDSA.

### Installation

[ecdsa-python]: https://github.com/starkbank/ecdsa-python
#### Maven Central
In pom.xml:

```xml
<dependency>
<groupId>com.github.starkbank</groupId>
<artifactId>starkbank-ecdsa</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
```

It is compatible with OpenSSL and is fast.
It uses some elegant math as Jacobian Coordinates to speed up the ECDSA.
Then run:
```sh
mvn clean install
```

### Curves

We currently support `secp256k1`, but it's super easy to add more curves to the project. Just add them on `Curve.java`

### Speed

We ran a test on JDK 13.0.1 on a MAC Pro i5 2019. The libraries ran 100 times and showed the average times displayed bellow:

| Library | sign | verify |
| ------------------ |:-------------:| -------:|
| [java.security] | 0.9ms | 2.4ms |
| starkbank-ecdsa | 4.3ms | 9.9ms |

### Sample Code

How to use it:
Expand Down Expand Up @@ -102,7 +123,7 @@ NOTE: If you want to create a Digital Signature to use in the [Stark Bank], you
openssl base64 -in signatureBinary.txt -out signatureBase64.txt
```

With this library, you can do it:
You can also verify it with this library:

```java
import com.starkbank.ellipticcurve.utils.ByteString;
Expand All @@ -124,18 +145,10 @@ public class GenerateSignature {

[Stark Bank]: https://starkbank.com

### How to install

#### Maven Central
```xml
<dependency>
<groupId>com.github.starkbank</groupId>
<artifactId>ecdsa-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
```

### Run all unit tests
```shell
gradle test
```

[ecdsa-python]: https://github.com/starkbank/ecdsa-python
[java.security]: https://docs.oracle.com/javase/7/docs/api/index.html
14 changes: 4 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ buildscript {
plugins {
id 'java'
id 'maven'
id 'net.saliman.cobertura' version '2.5.4'
id 'net.saliman.cobertura' version '3.0.0'
id 'com.github.kt3k.coveralls' version '2.8.2'
id 'osgi'
}

sourceCompatibility = 1.6
targetCompatibility = 1.6
sourceCompatibility = 1.7
targetCompatibility = 1.7

group = GROUP
version = VERSION_NAME
Expand Down Expand Up @@ -57,11 +56,6 @@ jar {
attributes("Implementation-Title": POM_NAME,
"Implementation-Version": VERSION_NAME,
"Implementation-Vendor": VENDOR_NAME)

version = VERSION_NAME
symbolicName = POM_ARTIFACT_ID

instruction 'Export-Package', '*'
}
}
//Uncomment after setting up maven central account
Expand All @@ -78,4 +72,4 @@ cobertura {
coverageFormats = ['html', 'xml'] // coveralls plugin depends on xml format report
coverageIgnoreTrivial = true // ignore getters/setters in coverage report
coverageIgnoreMethodAnnotations = ["java.lang.Deprecated"]
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ POM_DEVELOPER_NAME=
POM_DEVELOPER_EMAIL=

POM_DESCRIPTION=
POM_NAME=ecdsa-java
POM_ARTIFACT_ID=ecdsa-java
POM_NAME=starkbank-ecdsa
POM_ARTIFACT_ID=starkbank-ecdsa
POM_PACKAGING=jar
POM_ORGANIZATION_URL=

Expand Down
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.starkbank</groupId>
<artifactId>ecdsa-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* in the user guide at https://docs.gradle.org/5.1.1/userguide/multi_project_builds.html
*/

rootProject.name = 'ecdsa-java'
rootProject.name = 'starkbank-ecdsa'

0 comments on commit 65f69e0

Please sign in to comment.