Compare commits

...
10 Commits
4 changed files with 83 additions and 45 deletions
+19
View File
@@ -0,0 +1,19 @@
[![Build Status](https://travis-ci.org/zmarko/sss.svg?branch=master)](https://travis-ci.org/zmarko/sss)
sss
===
This library contains Java implementation of the [Shamir's Secret Sharing](http://en.wikipedia.org/wiki/Shamir%27s_Secret_Sharing) algorithm.
You can use it to split arbitrary data into a number of shares.
In order to join shares back into the secret data, certain, minimum number of shares must be present.
The library contains utlity functions for serializing and de-serializing shares into binary messages, for compact and easy storing and sharing.
Artifacts are available in Maven Central repository at the following coordinates:
<dependency>
<groupId>rs.in.zivanovic</groupId>
<artifactId>sss</artifactId>
<version>1.0.0</version>
</dependency>
+62 -40
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>rs.in.zivanovic</groupId>
<artifactId>sss</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>1.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
@@ -41,7 +41,8 @@
<connection>scm:git:git@github.com:zmarko/sss.git</connection>
<developerConnection>scm:git:git@github.com:zmarko/sss.git</developerConnection>
<url>git@github.com:zmarko/sss.git</url>
</scm>
<tag>HEAD</tag>
</scm>
<dependencies>
<dependency>
@@ -55,44 +56,15 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.5</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -108,4 +80,54 @@
</plugins>
</build>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -49,7 +49,7 @@ public final class SasUtils {
public static BigInteger encodeStringToInteger(String str) {
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
byte[] res;
if ((bytes[0] & 0b10000000) >> 7 == 1) {
if ((bytes[0] & 0b1000_0000) >> 7 == 1) {
res = new byte[bytes.length + 1];
res[0] = 0;
System.arraycopy(bytes, 0, res, 1, bytes.length);
@@ -84,10 +84,7 @@ public final class SecretShare {
if (!Objects.equals(this.share, other.share)) {
return false;
}
if (!Objects.equals(this.prime, other.prime)) {
return false;
}
return true;
return Objects.equals(this.prime, other.prime);
}
@Override