| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>base</artifactId> | |||
| </project> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>binary-proto</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>consensus</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>consensus-bftsmart</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>consensus</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>consensus-framework</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>consensus</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>consensus-mq</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>consensus</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -0,0 +1,47 @@ | |||
| <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> | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-compiler</artifactId> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-model</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.sun</groupId> | |||
| <artifactId>tools</artifactId> | |||
| <version>1.8.0</version> | |||
| <scope>system</scope> | |||
| <systemPath>${java.home}/../lib/tools.jar</systemPath> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.github.javaparser</groupId> | |||
| <artifactId>javaparser-core</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>junit</groupId> | |||
| <artifactId>junit</artifactId> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>commons-io</groupId> | |||
| <artifactId>commons-io</artifactId> | |||
| <version>${commons-io.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.esotericsoftware</groupId> | |||
| <artifactId>reflectasm</artifactId> | |||
| <version>1.10.1</version> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -0,0 +1,107 @@ | |||
| <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> | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-engine</artifactId> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-model</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-compiler</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>junit</groupId> | |||
| <artifactId>junit</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.mockito</groupId> | |||
| <artifactId>mockito-core</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-jar</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.sun</groupId> | |||
| <artifactId>plugin</artifactId> | |||
| <version>1.8</version> | |||
| <scope>system</scope> | |||
| <systemPath>${java.home}/lib/plugin.jar</systemPath> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.slf4j</groupId> | |||
| <artifactId>slf4j-simple</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-web</artifactId> | |||
| <scope>provided</scope> | |||
| <exclusions> | |||
| <exclusion> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-logging</artifactId> | |||
| </exclusion> | |||
| </exclusions> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-cache</artifactId> | |||
| </dependency> | |||
| <!-- ehcache缓存 --> | |||
| <dependency> | |||
| <groupId>org.ehcache</groupId> | |||
| <artifactId>ehcache</artifactId> | |||
| <version>${ehcache.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>javax.cache</groupId> | |||
| <artifactId>cache-api</artifactId> | |||
| <version>${cache-api.version}</version> | |||
| </dependency> | |||
| <!-- 测试依赖 --> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-starter-test</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-tools</artifactId> | |||
| <version>${project.version}</version> | |||
| <!--<scope>test</scope>--> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| <plugins> | |||
| <plugin> | |||
| <groupId>org.apache.maven.plugins</groupId> | |||
| <artifactId>maven-surefire-plugin</artifactId> | |||
| <version>2.5</version> | |||
| <configuration> | |||
| <skipTests>true</skipTests> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| </project> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-framework</artifactId> | |||
| @@ -0,0 +1,41 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <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"> | |||
| <parent> | |||
| <artifactId>contract</artifactId> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <artifactId>contract-jar</artifactId> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-compiler</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>commons-io</groupId> | |||
| <artifactId>commons-io</artifactId> | |||
| <version>${commons-io.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>junit</groupId> | |||
| <artifactId>junit</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.mockito</groupId> | |||
| <artifactId>mockito-core</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.slf4j</groupId> | |||
| <artifactId>slf4j-log4j12</artifactId> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-jvm</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-maven-plugin</artifactId> | |||
| <packaging>maven-plugin</packaging> | |||
| @@ -15,7 +15,7 @@ | |||
| <junit.version>4.12</junit.version> | |||
| </properties> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>junit</groupId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-model</artifactId> | |||
| @@ -0,0 +1,80 @@ | |||
| <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> | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract</artifactId> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract-tools</artifactId> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-compiler</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>contract-jar</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>commons-io</groupId> | |||
| <artifactId>commons-io</artifactId> | |||
| <version>${commons-io.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>junit</groupId> | |||
| <artifactId>junit</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.mockito</groupId> | |||
| <artifactId>mockito-core</artifactId> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.slf4j</groupId> | |||
| <artifactId>slf4j-log4j12</artifactId> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| <plugins> | |||
| <plugin> | |||
| <groupId>org.apache.maven.plugins</groupId> | |||
| <artifactId>maven-surefire-plugin</artifactId> | |||
| <version>2.5</version> | |||
| <configuration> | |||
| <skipTests>true</skipTests> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| <!--<build>--> | |||
| <!--<plugins>--> | |||
| <!--<plugin>--> | |||
| <!--<groupId>org.apache.maven.plugins</groupId>--> | |||
| <!--<artifactId>maven-compiler-plugin</artifactId>--> | |||
| <!--<version>3.1</version>--> | |||
| <!--<configuration>--> | |||
| <!--<source>1.8</source>--> | |||
| <!--<target>1.8</target>--> | |||
| <!--<encoding>UTF-8</encoding>--> | |||
| <!--<compilerArgs>--> | |||
| <!--<!–<arg>-verbose</arg>–>--> | |||
| <!--<!–<arg>-Xlint:unchecked</arg>–>--> | |||
| <!--<!–<arg>-Xlint:deprecation</arg>–>--> | |||
| <!--<!–<arg>-bootclasspath</arg>–>--> | |||
| <!--<!–<arg>${env.JAVA_HOME}/jre/lib/rt.jar</arg>–>--> | |||
| <!--<arg>-extdirs</arg>--> | |||
| <!--<arg>${project.basedir}/../contract/contract-libs;$JAVA_HOME/jre/lib/ext</arg>--> | |||
| <!--</compilerArgs>--> | |||
| <!--</configuration>--> | |||
| <!--</plugin>--> | |||
| <!--</plugins>--> | |||
| <!--</build>--> | |||
| </project> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>contract</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -3,7 +3,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>crypto</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>crypto-adv</artifactId> | |||
| @@ -0,0 +1,118 @@ | |||
| package com.jd.blockchain.crypto.elgamal; | |||
| import org.bouncycastle.crypto.AsymmetricCipherKeyPair; | |||
| import org.bouncycastle.crypto.engines.ElGamalEngine; | |||
| import org.bouncycastle.crypto.generators.ElGamalKeyPairGenerator; | |||
| import org.bouncycastle.crypto.params.*; | |||
| import java.math.BigInteger; | |||
| import java.security.SecureRandom; | |||
| public class ElGamalUtils { | |||
| private static final BigInteger g512 = new BigInteger("153d5d6172adb43045b68ae8e1de1070b6137005686d29d3d73a7749199681ee5b212c9b96bfdcfa5b20cd5e3fd2044895d609cf9b410b7a0f12ca1cb9a428cc", 16); | |||
| private static final BigInteger p512 = new BigInteger("9494fec095f3b85ee286542b3836fc81a5dd0a0349b4c239dd38744d488cf8e31db8bcb7d33b41abb9e5a33cca9144b1cef332c94bf0573bf047a3aca98cdf3b", 16); | |||
| private static final ElGamalParameters dhParams = new ElGamalParameters(p512, g512, 0); | |||
| //-----------------Key Pair Generation Algorithm----------------- | |||
| /** | |||
| * key generation | |||
| * | |||
| * @return key pair | |||
| */ | |||
| public static AsymmetricCipherKeyPair generateKeyPair(){ | |||
| SecureRandom random = new SecureRandom(); | |||
| return generateKeyPair(random); | |||
| } | |||
| public static AsymmetricCipherKeyPair generateKeyPair(SecureRandom random){ | |||
| ElGamalKeyGenerationParameters params = new ElGamalKeyGenerationParameters(random, dhParams); | |||
| ElGamalKeyPairGenerator kpGen = new ElGamalKeyPairGenerator(); | |||
| // To generate the key pair | |||
| kpGen.init(params); | |||
| return kpGen.generateKeyPair(); | |||
| } | |||
| public static byte[] retrievePublicKey(byte[] privateKey) | |||
| { | |||
| BigInteger g = dhParams.getG(); | |||
| BigInteger p = dhParams.getP(); | |||
| BigInteger pubKey = g.modPow(new BigInteger(1,privateKey), p); | |||
| byte[] pubKey2Bytes = pubKey.toByteArray(); | |||
| int pubKeySize = (p.bitLength() + 7)/8; | |||
| byte[] result = new byte[pubKeySize]; | |||
| if (pubKey2Bytes.length > result.length) | |||
| { | |||
| System.arraycopy(pubKey2Bytes, 1, result, result.length - (pubKey2Bytes.length - 1), pubKey2Bytes.length - 1); | |||
| } | |||
| else | |||
| { | |||
| System.arraycopy(pubKey2Bytes, 0, result, result.length - pubKey2Bytes.length, pubKey2Bytes.length); | |||
| } | |||
| return result; | |||
| } | |||
| //-----------------Public Key Encryption Algorithm----------------- | |||
| /** | |||
| * encryption | |||
| * | |||
| * @param plainBytes plaintext | |||
| * @param publicKey public key | |||
| * @return ciphertext | |||
| */ | |||
| public static byte[] encrypt(byte[] plainBytes, byte[] publicKey){ | |||
| SecureRandom random = new SecureRandom(); | |||
| return encrypt(plainBytes,publicKey,random); | |||
| } | |||
| public static byte[] encrypt(byte[] plainBytes, byte[] publicKey, SecureRandom random){ | |||
| BigInteger pubKey = new BigInteger(1,publicKey); | |||
| ElGamalPublicKeyParameters pubKeyParams = new ElGamalPublicKeyParameters(pubKey,dhParams); | |||
| return encrypt(plainBytes, pubKeyParams, random); | |||
| } | |||
| public static byte[] encrypt(byte[] plainBytes, ElGamalPublicKeyParameters pubKeyParams){ | |||
| SecureRandom random = new SecureRandom(); | |||
| return encrypt(plainBytes, pubKeyParams, random); | |||
| } | |||
| public static byte[] encrypt(byte[] plainBytes, ElGamalPublicKeyParameters pubKeyParams, SecureRandom random){ | |||
| ParametersWithRandom params = new ParametersWithRandom(pubKeyParams, random); | |||
| ElGamalEngine encryptor = new ElGamalEngine(); | |||
| encryptor.init(true, params); | |||
| return encryptor.processBlock(plainBytes,0,plainBytes.length); | |||
| } | |||
| public static byte[] decrypt(byte[] cipherBytes, byte[] privateKey){ | |||
| BigInteger privKey = new BigInteger(1,privateKey); | |||
| ElGamalPrivateKeyParameters privKeyParams = new ElGamalPrivateKeyParameters(privKey,dhParams); | |||
| ElGamalEngine decryptor = new ElGamalEngine(); | |||
| decryptor.init(false,privKeyParams); | |||
| return decryptor.processBlock(cipherBytes,0,cipherBytes.length); | |||
| } | |||
| public static ElGamalParameters getElGamalParameters(){return dhParams;} | |||
| } | |||
| @@ -0,0 +1,107 @@ | |||
| package com.jd.blockchain.crypto.mpc; | |||
| import com.jd.blockchain.crypto.elgamal.ElGamalUtils; | |||
| import com.jd.blockchain.utils.io.BytesUtils; | |||
| import org.bouncycastle.crypto.AsymmetricCipherKeyPair; | |||
| import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; | |||
| import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; | |||
| import java.math.BigInteger; | |||
| import java.util.Arrays; | |||
| public class EqualVerify { | |||
| private static final int ELEMENTLENGTH = 64; | |||
| private static BigInteger p; | |||
| private static byte[] sponsorEPubKeyBytes; | |||
| private static byte[] sponsorEPrivKeyBytes; | |||
| private static byte[] responderEPubKeyBytes; | |||
| private static byte[] responderEPrivKeyBytes; | |||
| public static void generateParams(){ | |||
| p = ElGamalUtils.getElGamalParameters().getP(); | |||
| } | |||
| public static void generateSponsorKeyPair(){ | |||
| AsymmetricCipherKeyPair keyPair = ElGamalUtils.generateKeyPair(); | |||
| ElGamalPublicKeyParameters pubKeyParams = (ElGamalPublicKeyParameters) keyPair.getPublic(); | |||
| ElGamalPrivateKeyParameters privKeyParams = (ElGamalPrivateKeyParameters) keyPair.getPrivate(); | |||
| sponsorEPubKeyBytes = bigIntegerTo64Bytes(pubKeyParams.getY()); | |||
| sponsorEPrivKeyBytes = bigIntegerTo64Bytes(privKeyParams.getX()); | |||
| } | |||
| public static void generateResponderKeyPair(){ | |||
| AsymmetricCipherKeyPair keyPair = ElGamalUtils.generateKeyPair(); | |||
| ElGamalPublicKeyParameters pubKeyParams = (ElGamalPublicKeyParameters) keyPair.getPublic(); | |||
| ElGamalPrivateKeyParameters privKeyParams = (ElGamalPrivateKeyParameters) keyPair.getPrivate(); | |||
| responderEPubKeyBytes = bigIntegerTo64Bytes(pubKeyParams.getY()); | |||
| responderEPrivKeyBytes = bigIntegerTo64Bytes(privKeyParams.getX()); | |||
| } | |||
| public static byte[] sponsor(int sponsorInput, byte[] sponsorEPubKeyBytes){ | |||
| BigInteger sponsorBigInt = BigInteger.valueOf(sponsorInput); | |||
| BigInteger sponsorEPubKey = new BigInteger(1, sponsorEPubKeyBytes); | |||
| BigInteger result = sponsorBigInt.multiply(sponsorEPubKey).mod(p); | |||
| return bigIntegerTo64Bytes(result); | |||
| } | |||
| public static byte[] responder(int responderInput, byte[] sponsorOutput, byte[] responderEPubKeyBytes, | |||
| byte[] responderEPrivKeyBytes) { | |||
| if (sponsorOutput.length != ELEMENTLENGTH) | |||
| throw new IllegalArgumentException("The sponsorOutput' length is not 64!"); | |||
| BigInteger responderBigInt = BigInteger.valueOf(responderInput); | |||
| BigInteger responderEPubKey = new BigInteger(1,responderEPubKeyBytes); | |||
| BigInteger responderCipher = responderBigInt.multiply(responderEPubKey).mod(p); | |||
| BigInteger responderInputInverse = BigInteger.valueOf(responderInput).modInverse(p); | |||
| BigInteger tmp = new BigInteger(1, sponsorOutput).multiply(responderInputInverse).mod(p); | |||
| BigInteger dhValue = tmp.modPow(new BigInteger(1,responderEPrivKeyBytes), p); | |||
| return BytesUtils.concat(bigIntegerTo64Bytes(responderCipher), bigIntegerTo64Bytes(dhValue)); | |||
| } | |||
| public static boolean sponsorCheck(int sponsorInput, byte[] responderOutput, byte[] sponsorEPrivKeyBytes){ | |||
| if (responderOutput.length != 2 * ELEMENTLENGTH) | |||
| throw new IllegalArgumentException("The responderOutput's length is not 128!"); | |||
| byte[] responderCipherBytes = new byte[ELEMENTLENGTH]; | |||
| byte[] dhValueBytes = new byte[ELEMENTLENGTH]; | |||
| System.arraycopy(responderOutput, 0, responderCipherBytes, 0, responderCipherBytes.length); | |||
| System.arraycopy(responderOutput, responderCipherBytes.length, dhValueBytes, 0,dhValueBytes.length); | |||
| BigInteger sponsorInputInverse = BigInteger.valueOf(sponsorInput).modInverse(p); | |||
| BigInteger tmp = new BigInteger(1, responderCipherBytes).multiply(sponsorInputInverse); | |||
| BigInteger dhVerifier = tmp.modPow(new BigInteger(1,sponsorEPrivKeyBytes), p); | |||
| return Arrays.equals(dhValueBytes, bigIntegerTo64Bytes(dhVerifier)); | |||
| } | |||
| public static byte[] getSponsorEPubKeyBytes(){return sponsorEPubKeyBytes;} | |||
| public static byte[] getSponsorEPrivKeyBytes(){return sponsorEPrivKeyBytes;} | |||
| public static byte[] getResponderEPubKeyBytes(){return responderEPubKeyBytes;} | |||
| public static byte[] getResponderEPrivKeyBytes(){return responderEPrivKeyBytes;} | |||
| // To convert BigInteger to byte[] whose length is 64 | |||
| private static byte[] bigIntegerTo64Bytes(BigInteger b){ | |||
| byte[] tmp = b.toByteArray(); | |||
| byte[] result = new byte[64]; | |||
| if (tmp.length > result.length) | |||
| System.arraycopy(tmp, tmp.length-result.length, result, 0, result.length); | |||
| else System.arraycopy(tmp,0,result,result.length-tmp.length,tmp.length); | |||
| return result; | |||
| } | |||
| } | |||
| @@ -0,0 +1,270 @@ | |||
| package com.jd.blockchain.crypto.mpc; | |||
| import com.jd.blockchain.crypto.elgamal.ElGamalUtils; | |||
| import com.jd.blockchain.utils.io.BytesUtils; | |||
| import org.bouncycastle.crypto.AsymmetricCipherKeyPair; | |||
| import org.bouncycastle.crypto.params.ElGamalParameters; | |||
| import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; | |||
| import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; | |||
| import java.math.BigInteger; | |||
| import java.security.SecureRandom; | |||
| import java.util.Random; | |||
| public class IntCompare { | |||
| private static final int INTLENGTH = 32; | |||
| private static final int ELEMENTLENGTH = 64; | |||
| private static final int CIPHERLENGTH = 128; | |||
| private static BigInteger p; | |||
| private static byte[] pubKeyBytes; | |||
| private static byte[] privKeyBytes; | |||
| public static void generateKeyPair(){ | |||
| ElGamalParameters dhParams = ElGamalUtils.getElGamalParameters(); | |||
| p = dhParams.getP(); | |||
| AsymmetricCipherKeyPair keyPair = ElGamalUtils.generateKeyPair(); | |||
| ElGamalPublicKeyParameters pubKeyParams = (ElGamalPublicKeyParameters) keyPair.getPublic(); | |||
| ElGamalPrivateKeyParameters privKeyParams = (ElGamalPrivateKeyParameters) keyPair.getPrivate(); | |||
| pubKeyBytes = bigIntegerTo64Bytes(pubKeyParams.getY()); | |||
| privKeyBytes = bigIntegerTo64Bytes(privKeyParams.getX()); | |||
| } | |||
| public static byte[][] sponsor(int sponsorInput, byte[] pubKeyBytes){ | |||
| String sponsorBinaryStr = to32BinaryString(sponsorInput); | |||
| byte[][] cipherArray = new byte[INTLENGTH * 2][CIPHERLENGTH]; | |||
| byte[] unitMsg = bigIntegerTo64Bytes(BigInteger.ONE); | |||
| byte[] randMsg = new byte[ELEMENTLENGTH - 1]; | |||
| int i; | |||
| for (i = 0; i < INTLENGTH; i++){ | |||
| SecureRandom random = new SecureRandom(); | |||
| random.nextBytes(randMsg); | |||
| if (sponsorBinaryStr.charAt(i) == '1'){ | |||
| cipherArray[i] = ElGamalUtils.encrypt(unitMsg, pubKeyBytes); | |||
| cipherArray[i + INTLENGTH] = ElGamalUtils.encrypt(randMsg, pubKeyBytes); | |||
| } | |||
| else { | |||
| cipherArray[i] = ElGamalUtils.encrypt(randMsg, pubKeyBytes); | |||
| cipherArray[i + INTLENGTH] = ElGamalUtils.encrypt(unitMsg, pubKeyBytes); | |||
| } | |||
| } | |||
| return cipherArray; | |||
| } | |||
| public static byte[][] responder(int responderInt, byte[][] cipherArray, byte[] pubKeyBytes){ | |||
| if (cipherArray.length != 2 * INTLENGTH) | |||
| throw new IllegalArgumentException("The cipherArray has wrong format!"); | |||
| int i,j; | |||
| for (i = 0; i < cipherArray.length; i++){ | |||
| if(cipherArray[i].length != CIPHERLENGTH) | |||
| throw new IllegalArgumentException("The cipherArray has wrong format!"); | |||
| } | |||
| String[] responderStrSet = encoding(responderInt, false); | |||
| BigInteger tmpLeftBigInteger; | |||
| BigInteger tmpRightBigInteger; | |||
| BigInteger leftBigInteger; | |||
| BigInteger rightBigInteger; | |||
| byte[] tmpCipherArray = new byte[CIPHERLENGTH]; | |||
| byte[] randMsg = new byte[ELEMENTLENGTH -1 ]; | |||
| byte[][] aggregatedCipherArray = new byte[INTLENGTH][CIPHERLENGTH]; | |||
| for (i = 0; i < aggregatedCipherArray.length; i++){ | |||
| if (responderStrSet[i] != null){ | |||
| tmpLeftBigInteger = BigInteger.ONE; | |||
| tmpRightBigInteger = BigInteger.ONE; | |||
| for (j = 0; j < responderStrSet[i].length(); j++){ | |||
| if (responderStrSet[i].charAt(j) == '1'){ | |||
| System.arraycopy(cipherArray[j], 0, tmpCipherArray, 0, tmpCipherArray.length); | |||
| } | |||
| else{ | |||
| System.arraycopy(cipherArray[j + INTLENGTH], 0,tmpCipherArray, 0, tmpCipherArray.length); | |||
| } | |||
| leftBigInteger = getLeftBigIntegerFrom128Bytes(tmpCipherArray); | |||
| tmpLeftBigInteger = tmpLeftBigInteger.multiply(leftBigInteger).mod(p); | |||
| rightBigInteger = getRightBigIntegerFrom128Bytes(tmpCipherArray); | |||
| tmpRightBigInteger = tmpRightBigInteger.multiply(rightBigInteger).mod(p); | |||
| } | |||
| aggregatedCipherArray[i] = BytesUtils.concat(bigIntegerTo64Bytes(tmpLeftBigInteger),bigIntegerTo64Bytes(tmpRightBigInteger)); | |||
| } | |||
| else { | |||
| SecureRandom random = new SecureRandom(); | |||
| random.nextBytes(randMsg); | |||
| aggregatedCipherArray[i] = ElGamalUtils.encrypt(randMsg, pubKeyBytes); | |||
| } | |||
| } | |||
| int[] permutation = randPermute(INTLENGTH); | |||
| for (i = 0; i < INTLENGTH; i++){ | |||
| System.arraycopy(aggregatedCipherArray[i], 0, tmpCipherArray, 0, CIPHERLENGTH); | |||
| System.arraycopy(aggregatedCipherArray[permutation[i]-1], 0, aggregatedCipherArray[i], 0, CIPHERLENGTH); | |||
| System.arraycopy(tmpCipherArray, 0, aggregatedCipherArray[permutation[i]-1], 0, CIPHERLENGTH); | |||
| } | |||
| return aggregatedCipherArray; | |||
| } | |||
| public static int sponsorOutput(byte[][] aggregatedCipherArray, byte[] privKeyBytes){ | |||
| if (aggregatedCipherArray.length != INTLENGTH) | |||
| throw new IllegalArgumentException("The aggregatedCipherArray has wrong format!"); | |||
| int i; | |||
| byte[] plaintext; | |||
| for (i = 0; i < aggregatedCipherArray.length; i++){ | |||
| if(aggregatedCipherArray[i].length != CIPHERLENGTH) | |||
| throw new IllegalArgumentException("The aggregatedCipherArray has wrong format!"); | |||
| plaintext = ElGamalUtils.decrypt(aggregatedCipherArray[i], privKeyBytes); | |||
| if ((plaintext.length ==1) && (BigInteger.ONE.equals(BigInteger.valueOf((int) plaintext[0])))){ | |||
| return 1; | |||
| } | |||
| } | |||
| return 0; | |||
| } | |||
| public static byte[] getPubKeyBytes(){return pubKeyBytes;} | |||
| public static byte[] getPrivKeyBytes(){return privKeyBytes;} | |||
| private static String[] encoding(int integer, boolean encodingOpts){ | |||
| String str = to32BinaryString(integer); | |||
| String[] strArray = new String[INTLENGTH]; | |||
| int i; | |||
| // 1-encoding | |||
| if (encodingOpts){ | |||
| for (i = 0; i < INTLENGTH; i++){ | |||
| if (str.charAt(i) == '1'){ | |||
| strArray[i] = str.substring(0, i + 1); | |||
| } | |||
| } | |||
| } | |||
| // 0-encoding | |||
| else { | |||
| for (i = 0; i < INTLENGTH; i++) { | |||
| if (str.charAt(i) == '0') { | |||
| strArray[i] = str.substring(0, i) + "1"; | |||
| } | |||
| } | |||
| } | |||
| return strArray; | |||
| } | |||
| private static String to32BinaryString(int integer) { | |||
| if (integer < 0) | |||
| throw new IllegalArgumentException("integer must be non-negative!"); | |||
| int i; | |||
| String str = Integer.toBinaryString(integer); | |||
| StringBuilder result = new StringBuilder(); | |||
| for (i = 0; i < INTLENGTH - str.length(); i++) { | |||
| result.append("0"); | |||
| } | |||
| return result.append(str).toString(); | |||
| } | |||
| /** | |||
| * @param min the lower bound (inclusive). Must be non-negative. | |||
| * @param max the upper bound (inclusive). Must be positive. | |||
| * @return the next pseudorandom, uniformly distributed {@code int} | |||
| * value between min (inclusive) and max (inclusive) | |||
| * from this random number generator's sequence | |||
| * @throws IllegalArgumentException if min is not non-negative, | |||
| * max is not positive, or min is bigger than max | |||
| */ | |||
| private static int randInt(int min, int max) { | |||
| if (min < 0) | |||
| throw new IllegalArgumentException("min must be non-negative!"); | |||
| if (max <= 0) | |||
| throw new IllegalArgumentException("max must be positive!"); | |||
| if (min > max) | |||
| throw new IllegalArgumentException("min must not be greater than max"); | |||
| Random random = new Random(); | |||
| return random.nextInt(max) % (max - min + 1) + min; | |||
| } | |||
| private static int[] randPermute(int num) { | |||
| int[] array = new int[num]; | |||
| int i; | |||
| int rand; | |||
| int tmp; | |||
| for (i = 0; i < num; i++) { | |||
| array[i] = i + 1; | |||
| } | |||
| for (i = 0; i < num; i++) { | |||
| rand = randInt(1, num); | |||
| tmp = array[i]; | |||
| array[i] = array[rand - 1]; | |||
| array[rand - 1] = tmp; | |||
| } | |||
| return array; | |||
| } | |||
| // To convert BigInteger to byte[] whose length is 64 | |||
| private static byte[] bigIntegerTo64Bytes(BigInteger b){ | |||
| byte[] tmp = b.toByteArray(); | |||
| byte[] result = new byte[64]; | |||
| if (tmp.length > result.length) | |||
| System.arraycopy(tmp, tmp.length-result.length, result, 0, result.length); | |||
| else System.arraycopy(tmp,0,result,result.length-tmp.length,tmp.length); | |||
| return result; | |||
| } | |||
| private static BigInteger getLeftBigIntegerFrom128Bytes(byte[] byteArray){ | |||
| if (byteArray.length != 128) | |||
| throw new IllegalArgumentException("The byteArray's length must be 128!"); | |||
| byte[] tmp = new byte[64]; | |||
| System.arraycopy(byteArray, 0, tmp, 0, tmp.length); | |||
| return new BigInteger(1, tmp); | |||
| } | |||
| private static BigInteger getRightBigIntegerFrom128Bytes(byte[] byteArray){ | |||
| if (byteArray.length != 128) | |||
| throw new IllegalArgumentException("The byteArray's length must be 128!"); | |||
| byte[] tmp = new byte[64]; | |||
| System.arraycopy(byteArray, 64, tmp, 0, tmp.length); | |||
| return new BigInteger(1, tmp); | |||
| } | |||
| } | |||
| @@ -0,0 +1,73 @@ | |||
| package test.com.jd.blockchain.crypto.elgamal; | |||
| import com.jd.blockchain.crypto.elgamal.ElGamalUtils; | |||
| import org.bouncycastle.crypto.AsymmetricCipherKeyPair; | |||
| import org.bouncycastle.crypto.params.ElGamalPrivateKeyParameters; | |||
| import org.bouncycastle.crypto.params.ElGamalPublicKeyParameters; | |||
| import org.bouncycastle.util.encoders.Hex; | |||
| import org.junit.Test; | |||
| import java.math.BigInteger; | |||
| import static org.junit.Assert.*; | |||
| public class ElGamalUtilsTest { | |||
| @Test | |||
| public void testGenerateKeyPair() { | |||
| AsymmetricCipherKeyPair keyPair = ElGamalUtils.generateKeyPair(); | |||
| ElGamalPublicKeyParameters pubKeyParams = (ElGamalPublicKeyParameters) keyPair.getPublic(); | |||
| ElGamalPrivateKeyParameters privKeyParams = (ElGamalPrivateKeyParameters) keyPair.getPrivate(); | |||
| byte[] privKeyBytes = bigIntegerTo64Bytes(privKeyParams.getX()); | |||
| byte[] pubKeyBytes = bigIntegerTo64Bytes(pubKeyParams.getY()); | |||
| byte[] retrievedPubKeyBytes = ElGamalUtils.retrievePublicKey(privKeyBytes); | |||
| assertEquals(64,privKeyBytes.length); | |||
| assertEquals(64,pubKeyBytes.length); | |||
| assertArrayEquals(retrievedPubKeyBytes,pubKeyBytes); | |||
| } | |||
| // To convert BigInteger to byte[] whose length is 64 | |||
| private byte[] bigIntegerTo64Bytes(BigInteger b){ | |||
| byte[] tmp = b.toByteArray(); | |||
| byte[] result = new byte[64]; | |||
| if (tmp.length > result.length) | |||
| System.arraycopy(tmp, tmp.length-result.length, result, 0, result.length); | |||
| else System.arraycopy(tmp,0,result,result.length-tmp.length,tmp.length); | |||
| return result; | |||
| } | |||
| @Test | |||
| public void testDecrypt() { | |||
| AsymmetricCipherKeyPair keyPair = ElGamalUtils.generateKeyPair(); | |||
| ElGamalPublicKeyParameters pubKeyParams = (ElGamalPublicKeyParameters) keyPair.getPublic(); | |||
| ElGamalPrivateKeyParameters privKeyParams = (ElGamalPrivateKeyParameters) keyPair.getPrivate(); | |||
| byte[] privKeyBytes = bigIntegerTo64Bytes(privKeyParams.getX()); | |||
| byte[] pubKeyBytes = bigIntegerTo64Bytes(pubKeyParams.getY()); | |||
| byte[] message = Hex.decode("5468697320697320612074657374"); | |||
| byte[] ciphertext = ElGamalUtils.encrypt(message,pubKeyBytes); | |||
| byte[] plaintext = ElGamalUtils.decrypt(ciphertext,privKeyBytes); | |||
| assertEquals(128,ciphertext.length); | |||
| assertArrayEquals(plaintext,message); | |||
| BigInteger one = BigInteger.ONE; | |||
| ciphertext = ElGamalUtils.encrypt(bigIntegerTo64Bytes(one),pubKeyBytes); | |||
| plaintext = ElGamalUtils.decrypt(ciphertext,privKeyBytes); | |||
| assertEquals(one,BigInteger.valueOf((int) plaintext[0])); | |||
| assertTrue(BigInteger.ONE.equals(BigInteger.valueOf((int) plaintext[0]))); | |||
| } | |||
| } | |||
| @@ -0,0 +1,73 @@ | |||
| package test.com.jd.blockchain.crypto.mpc; | |||
| import com.jd.blockchain.crypto.mpc.EqualVerify; | |||
| import org.junit.Before; | |||
| import org.junit.Test; | |||
| import static org.junit.Assert.*; | |||
| public class EqualVerifyTest { | |||
| private byte[] sponsorEPubKeyBytes; | |||
| private byte[] sponsorEPrivKeyBytes; | |||
| private byte[] responderEPubKeyBytes; | |||
| private byte[] responderEPrivKeyBytes; | |||
| @Before | |||
| public void init() { | |||
| EqualVerify.generateParams(); | |||
| EqualVerify.generateSponsorKeyPair(); | |||
| EqualVerify.generateResponderKeyPair(); | |||
| sponsorEPubKeyBytes = EqualVerify.getSponsorEPubKeyBytes(); | |||
| sponsorEPrivKeyBytes = EqualVerify.getSponsorEPrivKeyBytes(); | |||
| responderEPubKeyBytes = EqualVerify.getResponderEPubKeyBytes(); | |||
| responderEPrivKeyBytes = EqualVerify.getResponderEPrivKeyBytes(); | |||
| } | |||
| @Test | |||
| public void testIntCompare() { | |||
| int sponsorInput; | |||
| int responderInput; | |||
| byte[] sponsorOutput; | |||
| byte[] responderOutput; | |||
| boolean isEqual; | |||
| int i; | |||
| for (i = 0; i < 1000; i++) { | |||
| sponsorInput = 666; | |||
| responderInput = 666; | |||
| sponsorOutput = EqualVerify.sponsor(sponsorInput,sponsorEPubKeyBytes); | |||
| responderOutput = EqualVerify.responder(responderInput,sponsorOutput, | |||
| responderEPubKeyBytes,responderEPrivKeyBytes); | |||
| isEqual = EqualVerify.sponsorCheck(sponsorInput,responderOutput,sponsorEPrivKeyBytes); | |||
| assertTrue(isEqual); | |||
| } | |||
| for (i = 0; i < 1000; i++){ | |||
| sponsorInput = 666; | |||
| responderInput = 667; | |||
| sponsorOutput = EqualVerify.sponsor(sponsorInput,sponsorEPubKeyBytes); | |||
| responderOutput = EqualVerify.responder(responderInput,sponsorOutput, | |||
| responderEPubKeyBytes,responderEPrivKeyBytes); | |||
| isEqual = EqualVerify.sponsorCheck(sponsorInput,responderOutput,sponsorEPrivKeyBytes); | |||
| assertTrue(!isEqual); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package test.com.jd.blockchain.crypto.mpc; | |||
| import com.jd.blockchain.crypto.mpc.IntCompare; | |||
| import org.junit.Before; | |||
| import org.junit.Test; | |||
| import static org.junit.Assert.*; | |||
| public class IntCompareTest { | |||
| private byte[] pubKeyBytes; | |||
| private byte[] privKeyBytes; | |||
| @Before | |||
| public void init() { | |||
| IntCompare.generateKeyPair(); | |||
| pubKeyBytes = IntCompare.getPubKeyBytes(); | |||
| privKeyBytes = IntCompare.getPrivKeyBytes(); | |||
| } | |||
| @Test | |||
| public void testIntCompare() { | |||
| byte[][] cipherArray; | |||
| byte[][] aggregatedCipherArray; | |||
| int output; | |||
| int i; | |||
| for (i = 0; i < 1000; i++) { | |||
| int sponsorInput = 10000; | |||
| int responderInput = 9999; | |||
| cipherArray = IntCompare.sponsor(sponsorInput, pubKeyBytes); | |||
| aggregatedCipherArray = IntCompare.responder(responderInput, cipherArray, pubKeyBytes); | |||
| output = IntCompare.sponsorOutput(aggregatedCipherArray, privKeyBytes); | |||
| assertEquals(1, output); | |||
| } | |||
| for (i = 0; i < 1000; i++) { | |||
| int sponsorInput = 10000; | |||
| int responderInput = 19999; | |||
| cipherArray = IntCompare.sponsor(sponsorInput, pubKeyBytes); | |||
| aggregatedCipherArray = IntCompare.responder(responderInput, cipherArray, pubKeyBytes); | |||
| output = IntCompare.sponsorOutput(aggregatedCipherArray, privKeyBytes); | |||
| assertEquals(0, output); | |||
| } | |||
| } | |||
| } | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>crypto</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>crypto-framework</artifactId> | |||
| @@ -61,6 +61,16 @@ public interface AsymmetricCryptography { | |||
| SignatureDigest tryResolveSignatureDigest(byte[] digestBytes); | |||
| /** | |||
| * 由私钥恢复公钥; | |||
| * | |||
| * @param privKeyBytes 包含算法标识、密钥掩码和私钥的字节数组 | |||
| * @return 包含算法标识、密钥掩码和公钥的字节数组 | |||
| */ | |||
| byte[] retrievePubKeyBytes(byte[] privKeyBytes); | |||
| byte[] tryRetrievePubKeyBytes(byte[] privKeyBytes); | |||
| PubKey resolvePubKey(byte[] pubKeyBytes); | |||
| PubKey tryResolvePubKey(byte[] pubKeyBytes); | |||
| @@ -23,6 +23,14 @@ public interface AsymmetricEncryptionFunction extends CryptoKeyPairGenerator, Cr | |||
| */ | |||
| byte[] decrypt(PrivKey privKey, Ciphertext ciphertext); | |||
| /** | |||
| * 使用字节数组形式的私钥生成字节数组形式的公钥; | |||
| * | |||
| * @param privKeyBytes 包含算法标识、密钥掩码和私钥的字节数组 | |||
| * @return 包含算法标识、密钥掩码和公钥的字节数组 | |||
| */ | |||
| byte[] retrievePubKeyBytes(byte[] privKeyBytes); | |||
| /** | |||
| * 校验私钥格式是否满足要求; | |||
| * | |||
| @@ -22,6 +22,14 @@ public interface SignatureFunction extends CryptoKeyPairGenerator, CryptoFunctio | |||
| */ | |||
| boolean verify(SignatureDigest digest, PubKey pubKey, byte[] data); | |||
| /** | |||
| * 使用字节数组形式的私钥生成字节数组形式的公钥; | |||
| * | |||
| * @param privKeyBytes 包含算法标识、密钥掩码和私钥的字节数组 | |||
| * @return 包含算法标识、密钥掩码和公钥的字节数组 | |||
| */ | |||
| byte[] retrievePubKeyBytes(byte[] privKeyBytes); | |||
| /** | |||
| * 校验私钥格式是否满足要求; | |||
| * | |||
| @@ -135,6 +135,30 @@ public class AsymmtricCryptographyImpl implements AsymmetricCryptography { | |||
| return null; | |||
| } | |||
| @Override | |||
| public byte[] retrievePubKeyBytes(byte[] privKeyBytes) { | |||
| byte[] pubKeyBytes = tryRetrievePubKeyBytes(privKeyBytes); | |||
| if (pubKeyBytes == null) | |||
| throw new IllegalArgumentException("The specified algorithm in privKeyBytes is not signature or asymmetric encryption algorithm!"); | |||
| else return pubKeyBytes; | |||
| } | |||
| @Override | |||
| public byte[] tryRetrievePubKeyBytes(byte[] privKeyBytes) { | |||
| //解析私钥获得算法标识 | |||
| CryptoAlgorithm algorithm = resolvePrivKey(privKeyBytes).getAlgorithm(); | |||
| //判断算法是签名算法还是非对称加密算法,并根据算法生成密钥对,否则抛出异常 | |||
| if (algorithm.isSignable() && algorithm.isAsymmetric()){ | |||
| return getSignatureFunction(algorithm).retrievePubKeyBytes(privKeyBytes); | |||
| } | |||
| else if (algorithm.isEncryptable() && algorithm.isAsymmetric()){ | |||
| return getAsymmetricEncryptionFunction(algorithm).retrievePubKeyBytes(privKeyBytes); | |||
| } | |||
| //否则返回null | |||
| return null; | |||
| } | |||
| @Override | |||
| public PubKey resolvePubKey(byte[] pubKeyBytes) { | |||
| PubKey pubKey = tryResolvePubKey(pubKeyBytes); | |||
| @@ -15,6 +15,11 @@ public class ECDSASignatureFunction implements SignatureFunction { | |||
| return false; | |||
| } | |||
| @Override | |||
| public byte[] retrievePubKeyBytes(byte[] privKeyBytes) { | |||
| return new byte[0]; | |||
| } | |||
| @Override | |||
| public boolean supportPrivKey(byte[] privKeyBytes) { | |||
| return false; | |||
| @@ -7,6 +7,9 @@ import com.jd.blockchain.utils.security.Ed25519Utils; | |||
| import net.i2p.crypto.eddsa.EdDSAPrivateKey; | |||
| import net.i2p.crypto.eddsa.EdDSAPublicKey; | |||
| import net.i2p.crypto.eddsa.KeyPairGenerator; | |||
| import net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable; | |||
| import net.i2p.crypto.eddsa.spec.EdDSAParameterSpec; | |||
| import net.i2p.crypto.eddsa.spec.EdDSAPrivateKeySpec; | |||
| import java.security.KeyPair; | |||
| @@ -68,6 +71,16 @@ public class ED25519SignatureFunction implements SignatureFunction { | |||
| return Ed25519Utils.verify(data, rawPubKeyBytes, rawDigestBytes); | |||
| } | |||
| @Override | |||
| public byte[] retrievePubKeyBytes(byte[] privKeyBytes) { | |||
| byte[] rawPrivKeyBytes = resolvePrivKey(privKeyBytes).getRawKeyBytes(); | |||
| EdDSAParameterSpec spec = EdDSANamedCurveTable.getByName(EdDSANamedCurveTable.CURVE_ED25519_SHA512); | |||
| EdDSAPrivateKeySpec privateKeySpec = new EdDSAPrivateKeySpec(rawPrivKeyBytes, spec); | |||
| byte[] rawPubKeyBytes = privateKeySpec.getA().toByteArray(); | |||
| return new PubKey(ED25519,rawPubKeyBytes).toBytes(); | |||
| } | |||
| @Override | |||
| public boolean supportPrivKey(byte[] privKeyBytes) { | |||
| // 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应ED25519签名算法,并且密钥类型是私钥 | |||
| @@ -3,6 +3,7 @@ package com.jd.blockchain.crypto.impl.jni.asymmetric; | |||
| import com.jd.blockchain.crypto.CryptoAlgorithm; | |||
| import com.jd.blockchain.crypto.asymmetric.*; | |||
| import com.jd.blockchain.crypto.jniutils.asymmetric.JNIED25519Utils; | |||
| import com.jd.blockchain.utils.io.BytesUtils; | |||
| import static com.jd.blockchain.crypto.CryptoAlgorithm.JNIED25519; | |||
| import static com.jd.blockchain.crypto.CryptoBytes.ALGORYTHM_BYTES; | |||
| @@ -70,6 +71,15 @@ public class JNIED25519SignatureFunction implements SignatureFunction { | |||
| return ed25519.verify(data, rawPubKeyBytes, rawDigestBytes); | |||
| } | |||
| @Override | |||
| public byte[] retrievePubKeyBytes(byte[] privKeyBytes) { | |||
| JNIED25519Utils ed25519 = new JNIED25519Utils(); | |||
| byte[] rawPrivKeyBytes = resolvePrivKey(privKeyBytes).getRawKeyBytes(); | |||
| byte[] rawPubKeyBytes = ed25519.getPubKey(rawPrivKeyBytes); | |||
| return new PubKey(JNIED25519,rawPubKeyBytes).toBytes(); | |||
| } | |||
| @Override | |||
| public boolean supportPrivKey(byte[] privKeyBytes) { | |||
| // 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应JNIED25519签名算法,并且密钥类型是私钥 | |||
| @@ -7,7 +7,6 @@ import com.jd.blockchain.crypto.smutils.asymmetric.SM2Utils; | |||
| import org.bouncycastle.crypto.AsymmetricCipherKeyPair; | |||
| import org.bouncycastle.crypto.params.ECPrivateKeyParameters; | |||
| import org.bouncycastle.crypto.params.ECPublicKeyParameters; | |||
| import org.bouncycastle.util.encoders.Hex; | |||
| import static com.jd.blockchain.crypto.CryptoAlgorithm.SM2; | |||
| import static com.jd.blockchain.crypto.CryptoBytes.ALGORYTHM_BYTES; | |||
| @@ -65,6 +64,14 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur | |||
| return SM2Utils.decrypt(rawCiphertextBytes,rawPrivKeyBytes); | |||
| } | |||
| @Override | |||
| public byte[] retrievePubKeyBytes(byte[] privKeyBytes) { | |||
| byte[] rawPrivKeyBytes = resolvePrivKey(privKeyBytes).getRawKeyBytes(); | |||
| byte[] rawPubKeyBytes = SM2Utils.retrievePublicKey(rawPrivKeyBytes); | |||
| return new PubKey(SM2,rawPubKeyBytes).toBytes(); | |||
| } | |||
| @Override | |||
| public boolean supportPrivKey(byte[] privKeyBytes) { | |||
| // 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应SM2算法,并且密钥类型是私钥 | |||
| @@ -171,12 +178,13 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur | |||
| System.arraycopy(privKeyBytesD,privKeyBytesD.length-PRIVKEY_SIZE,privKeyBytes,0,PRIVKEY_SIZE); | |||
| else System.arraycopy(privKeyBytesD,0,privKeyBytes,PRIVKEY_SIZE-privKeyBytesD.length,privKeyBytesD.length); | |||
| byte[] pubKeyBytesX = ecPub.getQ().getAffineXCoord().getEncoded(); | |||
| byte[] pubKeyBytesY = ecPub.getQ().getAffineYCoord().getEncoded(); | |||
| byte[] pubKeyBytes = new byte[ECPOINT_SIZE]; | |||
| System.arraycopy(Hex.decode("04"),0,pubKeyBytes,0,1); | |||
| System.arraycopy(pubKeyBytesX,0,pubKeyBytes,1,32); | |||
| System.arraycopy(pubKeyBytesY,0,pubKeyBytes,1+32,32); | |||
| // byte[] pubKeyBytesX = ecPub.getQ().getAffineXCoord().getEncoded(); | |||
| // byte[] pubKeyBytesY = ecPub.getQ().getAffineYCoord().getEncoded(); | |||
| // byte[] pubKeyBytes = new byte[ECPOINT_SIZE]; | |||
| // System.arraycopy(Hex.decode("04"),0,pubKeyBytes,0,1); | |||
| // System.arraycopy(pubKeyBytesX,0,pubKeyBytes,1,32); | |||
| // System.arraycopy(pubKeyBytesY,0,pubKeyBytes,1+32,32); | |||
| byte[] pubKeyBytes = ecPub.getQ().getEncoded(false); | |||
| return new CryptoKeyPair(new PubKey(SM2,pubKeyBytes),new PrivKey(SM2,privKeyBytes)); | |||
| } | |||
| @@ -13,7 +13,9 @@ import org.bouncycastle.crypto.generators.ECKeyPairGenerator; | |||
| import org.bouncycastle.crypto.params.*; | |||
| import org.bouncycastle.crypto.signers.SM2Signer; | |||
| import org.bouncycastle.math.ec.ECCurve; | |||
| import org.bouncycastle.math.ec.ECMultiplier; | |||
| import org.bouncycastle.math.ec.ECPoint; | |||
| import org.bouncycastle.math.ec.FixedPointCombMultiplier; | |||
| import java.io.IOException; | |||
| import java.math.BigInteger; | |||
| @@ -66,6 +68,13 @@ public class SM2Utils { | |||
| return keyPairGenerator.generateKeyPair(); | |||
| } | |||
| public static byte[] retrievePublicKey(byte[] privateKey) | |||
| { | |||
| ECMultiplier createBasePointMultiplier = new FixedPointCombMultiplier(); | |||
| ECPoint publicKeyPoint = createBasePointMultiplier.multiply(domainParams.getG(), new BigInteger(1,privateKey)).normalize(); | |||
| return publicKeyPoint.getEncoded(false); | |||
| } | |||
| //-----------------Digital Signature Algorithm----------------- | |||
| @@ -265,14 +274,9 @@ public class SM2Utils { | |||
| // To retrieve the public key point from publicKey in byte array mode | |||
| private static ECPoint resolvePubKeyBytes(byte[] publicKey){ | |||
| byte[] pubKeyX = new byte[COORDS_SIZE]; | |||
| byte[] pubKeyY = new byte[COORDS_SIZE]; | |||
| System.arraycopy(publicKey,1,pubKeyX,0,COORDS_SIZE); | |||
| System.arraycopy(publicKey,1+COORDS_SIZE,pubKeyY,0,COORDS_SIZE); | |||
| return curve.createPoint(new BigInteger(1,pubKeyX), new BigInteger(1,pubKeyY)); | |||
| return curve.decodePoint(publicKey); | |||
| } | |||
| public static ECCurve getCurve(){return curve;} | |||
| public static ECDomainParameters getDomainParams(){return domainParams;} | |||
| } | |||
| @@ -678,6 +678,52 @@ public class AsymmtricCryptographyImplTest { | |||
| public void testTryResolveSignatureDigest() { | |||
| } | |||
| @Test | |||
| public void testRetrievePubKeyBytes() { | |||
| AsymmetricCryptography asymmetricCrypto = new AsymmtricCryptographyImpl(); | |||
| //test ED25519 | |||
| CryptoAlgorithm algorithm = CryptoAlgorithm.ED25519; | |||
| CryptoKeyPair keyPair = asymmetricCrypto.generateKeyPair(algorithm); | |||
| byte[] expectedPrivKeyBytes = keyPair.getPrivKey().toBytes(); | |||
| byte[] expectedPubKeyBytes = keyPair.getPubKey().toBytes(); | |||
| byte[] pubKeyBytes = asymmetricCrypto.retrievePubKeyBytes(expectedPrivKeyBytes); | |||
| assertArrayEquals(expectedPubKeyBytes,pubKeyBytes); | |||
| //test SM2 | |||
| algorithm = CryptoAlgorithm.SM2; | |||
| keyPair = asymmetricCrypto.generateKeyPair(algorithm); | |||
| expectedPrivKeyBytes = keyPair.getPrivKey().toBytes(); | |||
| expectedPubKeyBytes = keyPair.getPubKey().toBytes(); | |||
| pubKeyBytes = asymmetricCrypto.retrievePubKeyBytes(expectedPrivKeyBytes); | |||
| assertArrayEquals(expectedPubKeyBytes,pubKeyBytes); | |||
| //test JNIED25519 | |||
| algorithm = CryptoAlgorithm.JNIED25519; | |||
| keyPair = asymmetricCrypto.generateKeyPair(algorithm); | |||
| expectedPrivKeyBytes = keyPair.getPrivKey().toBytes(); | |||
| expectedPubKeyBytes = keyPair.getPubKey().toBytes(); | |||
| pubKeyBytes = asymmetricCrypto.retrievePubKeyBytes(expectedPrivKeyBytes); | |||
| assertArrayEquals(expectedPubKeyBytes,pubKeyBytes); | |||
| } | |||
| @Test | |||
| public void testResolvePubKey() { | |||
| @@ -34,6 +34,18 @@ public class SM2UtilsTest { | |||
| assertArrayEquals(Hex.decode(expectedPublicKey),pubKeyBytes); | |||
| } | |||
| @Test | |||
| public void testPubKeyRetrieve() { | |||
| String expectedPrivateKey = "3945208f7b2144b13f36e38ac6d39f95889393692860b51a42fb81ef4df7c5b8"; | |||
| String expectedPublicKey = "04"+"09f9df311e5421a150dd7d161e4bc5c672179fad1833fc076bb08ff356f35020"+"ccea490ce26775a52dc6ea718cc1aa600aed05fbf35e084a6632f6072da9ad13"; | |||
| byte[] privateKey = Hex.decode(expectedPrivateKey); | |||
| byte[] publicKey = SM2Utils.retrievePublicKey(privateKey); | |||
| assertEquals(expectedPublicKey,Hex.toHexString(publicKey)); | |||
| } | |||
| @Test | |||
| public void testSign() { | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>crypto</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>deployment</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>deployment-gateway</artifactId> | |||
| @@ -1440,85 +1440,7 @@ http://localhost/ledgers/657TQAw6ssVoeKniWGwbovk7njvCTvikPambM9eBv6ezs/accounts/ | |||
| |type|value类型| | |||
| |value|值| | |||
| ### 6.8 查询某数据账户键数量 | |||
| ```http | |||
| GET /ledgers/{ledger}/accounts/address/{address}/keys/count/search?keyword={keyword} | |||
| ``` | |||
| #### 参数 | |||
| |请求类型|名称|是否必需|说明|数据类型| | |||
| |---|---|---|---|---| | |||
| |**path**|**ledger**|是|所要搜索的账本,需要完整的账本哈希|string| | |||
| |**path**|**address**|是|所要搜索的数据账户地址,需要完整的数据账户地址|string| | |||
| |**query**|**keyword**|否|键的部分字符,空表示全部|string| | |||
| #### 请求实例 | |||
| ```http | |||
| http://localhost/ledgers/657TQAw6ssVoeKniWGwbovk7njvCTvikPambM9eBv6ezs/accounts/address/5Sm4gWXrNpDWW9Boi4xZCzZMHboRvEDm29Fa/keys/count/search?keyword=j | |||
| ``` | |||
| #### 返回实例 | |||
| ```json | |||
| { | |||
| "data": 66, | |||
| "success": true | |||
| } | |||
| ``` | |||
| 说明 | |||
| |名称|说明| | |||
| |---|---| | |||
| |data|条件查询键总数| | |||
| ### 6.9 查询某数据账户键 | |||
| ```http | |||
| GET /ledgers/{ledger}/accounts/address/{address}/keys/search?keyword={keyword}&fromIndex={start_index}&count={count} | |||
| ``` | |||
| #### 参数 | |||
| |请求类型|名称|是否必需|说明|数据类型| | |||
| |---|---|---|---|---| | |||
| |**path**|**ledger**|是|所要搜索的账本,需要完整的账本哈希|string| | |||
| |**path**|**address**|是|所要搜索的数据账户地址,需要完整的数据账户地址|string| | |||
| |**query**|**keyword**|否|键的部分字符,空表示全部|string| | |||
| |**query**|**start_index**|否|查询数据账户对应Key的起始序号,默认为0|数字| | |||
| |**query**|**count**|否|查询返回数据账户对应Key的数量,默认最大返回值为100,小于0或大于100均返回最大可返回结果集|数字| | |||
| #### 请求实例 | |||
| ```http | |||
| http://localhost/ledgers/657TQAw6ssVoeKniWGwbovk7njvCTvikPambM9eBv6ezs/accounts/address/5Sm4gWXrNpDWW9Boi4xZCzZMHboRvEDm29Fa/keys/search?keyword=j&fromIndex=0&count=-1 | |||
| ``` | |||
| #### 返回实例 | |||
| ```json | |||
| { | |||
| "data": [ | |||
| { | |||
| "key": "jd" | |||
| }, | |||
| { | |||
| "key": "jdchain" | |||
| }], | |||
| "success": true | |||
| } | |||
| ``` | |||
| 说明 | |||
| |名称|说明| | |||
| |---|---| | |||
| |key|键| | |||
| ## 7 搜索 | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>deployment</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>deployment-peer</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>deployment</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>gateway</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>ledger</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>ledger-core</artifactId> | |||
| @@ -167,7 +167,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable { | |||
| */ | |||
| public String getKeyAtIndex(int fromIndex) { | |||
| MerkleDataNode dataNode = merkleTree.getData(fromIndex); | |||
| return new String(dataNode.getKey().toBytes()); | |||
| return new String(dataNode.getKey().toBytes()); | |||
| } | |||
| @@ -6,7 +6,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>ledger</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>ledger-model</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>ledger</artifactId> | |||
| <version>0.8.3.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>ledger-rpc</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>ledger</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>peer</artifactId> | |||
| @@ -38,7 +38,7 @@ import java.util.*; | |||
| * @since 1.0.0 | |||
| */ | |||
| @Component | |||
| @EnableScheduling | |||
| //@EnableScheduling | |||
| public class PeerTimeTasks implements ApplicationContextAware { | |||
| private ApplicationContext applicationContext; | |||
| @@ -16,7 +16,7 @@ | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| <packaging>pom</packaging> | |||
| <description>jdchain</description> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>runtime</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>runtime</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>runtime-context</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>runtime</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>runtime-modular-booter</artifactId> | |||
| </project> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>runtime</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>runtime-modular</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>sdk</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>sdk</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>sdk-base</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>sdk</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>sdk-client</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>sdk</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>sdk-samples</artifactId> | |||
| @@ -3,7 +3,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>storage</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>storage</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>storage-composite</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>storage</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>storage-redis</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>storage</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>storage-rocksdb</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>storage</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>storage-service</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>test</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>test</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>test-consensus-client</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>test</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>test-consensus-node</artifactId> | |||
| <dependencies> | |||
| @@ -26,7 +26,7 @@ | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>consensus-bftsmart</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>org.springframework.boot</groupId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>test</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>test-integration</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>test</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>test-ledger-core</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>tools</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <artifactId>tools</artifactId> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>tools</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>tools-initializer-booter</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>tools</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>tools-initializer</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>tools</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>tools-keygen-booter</artifactId> | |||
| @@ -5,7 +5,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>tools</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>tools-keygen</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>jdchain-root</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>utils</artifactId> | |||
| <packaging>pom</packaging> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>utils</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>utils-common</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>utils</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <properties> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>utils</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>utils-serialize</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>utils</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>utils-test</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>utils</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>utils-web-server</artifactId> | |||
| @@ -4,7 +4,7 @@ | |||
| <parent> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>utils</artifactId> | |||
| <version>0.8.2.RELEASE</version> | |||
| <version>0.9.0-SNAPSHOT</version> | |||
| </parent> | |||
| <artifactId>utils-web</artifactId> | |||
| <dependencies> | |||