Skip to content

Commit

Permalink
Merge pull request #20 from halu5071/develop
Browse files Browse the repository at this point in the history
Update to v0.2.1-alpha
  • Loading branch information
halu5071 authored Nov 21, 2018
2 parents 6fce723 + 61a196b commit 3da099e
Show file tree
Hide file tree
Showing 41 changed files with 155 additions and 92 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ buildscript {
}
dependencies {
compile "io.moatwel.crypto:eddsa:0.2.0-alpha"
compile "io.moatwel.crypto:eddsa:0.2.1-alpha"
}
```

Expand All @@ -94,7 +94,7 @@ dependencies {
<dependency>
<groupId>io.moatwel.crypto</groupId>
<artifactId>eddsa</artifactId>
<version>0.2.0-alpha</version>
<version>0.2.1-alpha</version>
<type>pom</type>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions eddsa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'com.jfrog.bintray'

group = 'io.moatwel.crypto'
archivesBaseName = 'eddsa'
version = '0.2.0-alpha'
version = '0.2.1-alpha'
description = 'Edwards is a crypto library for Edwards-curve Digital Signature Algorithm (EdDSA) written in pure Java. '

def powermock_version = '1.7.4'
Expand Down Expand Up @@ -94,7 +94,7 @@ publishing {
artifact javadocJar
groupId 'io.moatwel.crypto'
artifactId 'eddsa'
version '0.2.0-alpha'
version '0.2.1-alpha'
pom.withXml {
def root = asNode()
root.appendNode('description', project.description)
Expand Down
4 changes: 2 additions & 2 deletions eddsa/src/main/java/io/moatwel/crypto/PublicKey.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.moatwel.crypto;

import io.moatwel.util.HexEncoder;

import java.math.BigInteger;

import io.moatwel.util.HexEncoder;

/**
* @author halu5071 (Yasunori Horii) at 2018/5/29
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package io.moatwel.crypto.eddsa;

import io.moatwel.crypto.EdDsaSigner;
import io.moatwel.crypto.KeyGenerator;
import io.moatwel.crypto.KeyPair;
import io.moatwel.crypto.PrivateKey;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.Curve;
import io.moatwel.crypto.eddsa.EncodedCoordinate;
import io.moatwel.util.ArrayUtils;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

/**
* @author halu5071 (Yasunori Horii) at 2018/06/28
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.Curve;
import io.moatwel.crypto.eddsa.Point;

import java.math.BigInteger;

/**
* Represent Ed25519 curve of twisted Edwards-curve.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.HashAlgorithm;
import io.moatwel.crypto.Hashes;
import io.moatwel.crypto.PrivateKey;
import io.moatwel.crypto.eddsa.Point;
import io.moatwel.crypto.eddsa.PublicKeyDelegate;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

/**
* Delegate class from {@link io.moatwel.crypto.eddsa.EdDsaKeyGenerator}.
* This will be provide from {@link Ed25519SchemeProvider}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

import io.moatwel.crypto.EdDsaSigner;
import io.moatwel.crypto.HashAlgorithm;
import io.moatwel.crypto.KeyGenerator;
import io.moatwel.crypto.KeyPair;
import io.moatwel.crypto.PrivateKey;
import io.moatwel.crypto.eddsa.SchemeProvider;
import io.moatwel.crypto.eddsa.EdKeyAnalyzer;
import io.moatwel.crypto.eddsa.PublicKeyDelegate;
import io.moatwel.crypto.eddsa.SchemeProvider;

/**
* @author halu5071 (Yasunori Horii) at 2018/6/26
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.EdDsaSigner;
import io.moatwel.crypto.HashAlgorithm;
import io.moatwel.crypto.Hashes;
Expand All @@ -12,8 +14,6 @@
import io.moatwel.crypto.eddsa.Point;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

/**
* A Signer on Edwards-curve DSA specified on Ed25519 curve.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.EncodedCoordinate;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

class EncodedCoordinateEd25519 extends EncodedCoordinate {

EncodedCoordinateEd25519(byte[] value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.Curve;
import io.moatwel.crypto.eddsa.DecodeException;
import io.moatwel.crypto.eddsa.EncodedPoint;
import io.moatwel.crypto.eddsa.Point;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

/**
* Encoded Point implementation of the Curve25519. Implements {@link EncodedPoint#decode()}
* operation. This object has byte array whose length is 32, which represents encoded point.
Expand Down Expand Up @@ -48,10 +48,14 @@ public Point decode() {
Coordinate x = xx.powerMod(curve.getPrimePowerP().add(new BigInteger("3")).divide(new BigInteger("8")));

if (x.multiply(x).subtract(xx).mod().getInteger().compareTo(BigInteger.ZERO) != 0) {
x = x.multiply(new CoordinateEd25519(
BigInteger.ONE.shiftLeft(1).modPow(
curve.getPrimePowerP().subtract(BigInteger.ONE).divide(BigInteger.ONE.shiftLeft(2)),
curve.getPrimePowerP()))).mod();
if (x.multiply(x).add(xx).mod().getInteger().compareTo(BigInteger.ZERO) == 0) {
x = x.multiply(new CoordinateEd25519(
BigInteger.ONE.shiftLeft(1).modPow(
curve.getPrimePowerP().subtract(BigInteger.ONE).divide(BigInteger.ONE.shiftLeft(2)),
curve.getPrimePowerP()))).mod();
} else {
throw new DecodeException("EdDsa decoding failed.");
}
}

BigInteger result = x.getInteger().mod(BigInteger.ONE.shiftLeft(1));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.EncodedPoint;
import io.moatwel.crypto.eddsa.Point;
import io.moatwel.util.ArrayUtils;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

class PointEd25519 extends Point {

private static final Coordinate Z1 = new CoordinateEd25519(new BigInteger("1"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.security.SecureRandom;

import io.moatwel.crypto.PrivateKey;
import io.moatwel.util.HexEncoder;

import java.security.SecureRandom;

public class PrivateKeyEd25519 extends PrivateKey {

private PrivateKeyEd25519(byte[] value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.moatwel.crypto.eddsa.ed25519;

import java.math.BigInteger;

import io.moatwel.crypto.Signature;
import io.moatwel.util.ArrayUtils;

import java.math.BigInteger;

/**
* @author halu5071 (Yasunori Horii) at 2018/6/21
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.moatwel.crypto.eddsa.ed448;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.Curve;
import io.moatwel.crypto.eddsa.EncodedCoordinate;

import java.math.BigInteger;

/**
* @author halu5071 (Yasunori Horii) at 2018/06/28
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.moatwel.crypto.eddsa.ed448;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.Curve;
import io.moatwel.crypto.eddsa.Point;

import java.math.BigInteger;

/**
* Represent Ed448 curve of twisted Edwards-curve.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

import io.moatwel.crypto.EdDsaSigner;
import io.moatwel.crypto.HashAlgorithm;
import io.moatwel.crypto.KeyGenerator;
import io.moatwel.crypto.KeyPair;
import io.moatwel.crypto.PrivateKey;
import io.moatwel.crypto.eddsa.SchemeProvider;
import io.moatwel.crypto.eddsa.EdKeyAnalyzer;
import io.moatwel.crypto.eddsa.PublicKeyDelegate;
import io.moatwel.crypto.eddsa.SchemeProvider;

/**
* @author halu5071 (Yasunori Horii) at 2018/6/26
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.moatwel.crypto.eddsa.ed448;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.EncodedCoordinate;
import io.moatwel.util.ByteUtils;

import java.math.BigInteger;

class EncodedCoordinateEd448 extends EncodedCoordinate {

EncodedCoordinateEd448(byte[] value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.moatwel.crypto.eddsa.ed448;

import java.math.BigInteger;

import io.moatwel.crypto.eddsa.Coordinate;
import io.moatwel.crypto.eddsa.EncodedPoint;
import io.moatwel.crypto.eddsa.Point;

import java.math.BigInteger;

class PointEd448 extends Point {

private static final Point ZERO =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.moatwel.crypto.eddsa.ed448;

import io.moatwel.crypto.PrivateKey;

import java.security.SecureRandom;

import io.moatwel.crypto.PrivateKey;

public class PrivateKeyEd448 extends PrivateKey {

private PrivateKeyEd448(byte[] value) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.moatwel.crypto.eddsa.ed448;

import java.math.BigInteger;

import io.moatwel.crypto.Signature;
import io.moatwel.util.ArrayUtils;

import java.math.BigInteger;

/**
* @author halu5071 (Yasunori Horii) at 2018/6/26
*/
Expand Down
3 changes: 2 additions & 1 deletion eddsa/src/test/java/io/moatwel/crypto/HashesTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.moatwel.crypto;

import io.moatwel.util.HexEncoder;
import org.junit.Test;

import io.moatwel.util.HexEncoder;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

Expand Down
5 changes: 3 additions & 2 deletions eddsa/src/test/java/io/moatwel/crypto/KeyPairTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.moatwel.crypto;

import io.moatwel.crypto.eddsa.EdKeyAnalyzer;
import io.moatwel.crypto.eddsa.Edwards;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import io.moatwel.crypto.eddsa.EdKeyAnalyzer;
import io.moatwel.crypto.eddsa.Edwards;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.powermock.api.mockito.PowerMockito.mock;
Expand Down
2 changes: 0 additions & 2 deletions eddsa/src/test/java/io/moatwel/crypto/PrivateKeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import io.moatwel.util.HexEncoder;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

public class PrivateKeyTest {
Expand Down
3 changes: 2 additions & 1 deletion eddsa/src/test/java/io/moatwel/crypto/PublicKeyTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.moatwel.crypto;

import io.moatwel.util.HexEncoder;
import org.junit.Test;

import java.math.BigInteger;

import io.moatwel.util.HexEncoder;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package io.moatwel.crypto.eddsa;

import io.moatwel.crypto.*;
import io.moatwel.crypto.eddsa.ed25519.PrivateKeyEd25519;
import org.junit.Before;
import org.junit.Test;

import io.moatwel.crypto.HashAlgorithm;
import io.moatwel.crypto.KeyGenerator;
import io.moatwel.crypto.PrivateKey;
import io.moatwel.crypto.PublicKey;
import io.moatwel.crypto.eddsa.ed25519.PrivateKeyEd25519;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

Expand Down
Loading

0 comments on commit 3da099e

Please sign in to comment.