Browse Source

Update to version 0.9.0-SNAPSHOT;

tags/1.0.0
huanghaiquan 5 years ago
parent
commit
a297d7d5d4
79 changed files with 1187 additions and 151 deletions
  1. +1
    -1
      source/base/pom.xml
  2. +1
    -1
      source/binary-proto/pom.xml
  3. +1
    -1
      source/consensus/consensus-bftsmart/pom.xml
  4. +1
    -1
      source/consensus/consensus-framework/pom.xml
  5. +1
    -1
      source/consensus/consensus-mq/pom.xml
  6. +1
    -1
      source/consensus/pom.xml
  7. +47
    -0
      source/contract/contract-compiler/pom.xml
  8. +107
    -0
      source/contract/contract-engine/pom.xml
  9. +1
    -1
      source/contract/contract-framework/pom.xml
  10. +41
    -0
      source/contract/contract-jar/pom.xml
  11. +1
    -1
      source/contract/contract-jvm/pom.xml
  12. +2
    -2
      source/contract/contract-maven-plugin/pom.xml
  13. +1
    -1
      source/contract/contract-model/pom.xml
  14. +80
    -0
      source/contract/contract-tools/pom.xml
  15. +1
    -1
      source/contract/pom.xml
  16. +1
    -1
      source/crypto/crypto-adv/pom.xml
  17. +118
    -0
      source/crypto/crypto-adv/src/main/java/com/jd/blockchain/crypto/elgamal/ElGamalUtils.java
  18. +107
    -0
      source/crypto/crypto-adv/src/main/java/com/jd/blockchain/crypto/mpc/EqualVerify.java
  19. +270
    -0
      source/crypto/crypto-adv/src/main/java/com/jd/blockchain/crypto/mpc/IntCompare.java
  20. +73
    -0
      source/crypto/crypto-adv/src/test/java/test/com/jd/blockchain/crypto/elgamal/ElGamalUtilsTest.java
  21. +73
    -0
      source/crypto/crypto-adv/src/test/java/test/com/jd/blockchain/crypto/mpc/EqualVerifyTest.java
  22. +50
    -0
      source/crypto/crypto-adv/src/test/java/test/com/jd/blockchain/crypto/mpc/IntCompareTest.java
  23. +1
    -1
      source/crypto/crypto-framework/pom.xml
  24. +10
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/asymmetric/AsymmetricCryptography.java
  25. +8
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/asymmetric/AsymmetricEncryptionFunction.java
  26. +8
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/asymmetric/SignatureFunction.java
  27. +24
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/AsymmtricCryptographyImpl.java
  28. +5
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/def/asymmetric/ECDSASignatureFunction.java
  29. +13
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/def/asymmetric/ED25519SignatureFunction.java
  30. +10
    -0
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/jni/asymmetric/JNIED25519SignatureFunction.java
  31. +15
    -7
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/sm/asymmetric/SM2CryptoFunction.java
  32. +11
    -7
      source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/smutils/asymmetric/SM2Utils.java
  33. +46
    -0
      source/crypto/crypto-framework/src/test/java/test/com/jd/blockchain/crypto/asymmetric/AsymmtricCryptographyImplTest.java
  34. +12
    -0
      source/crypto/crypto-framework/src/test/java/test/com/jd/blockchain/crypto/smutils/SM2UtilsTest.java
  35. +1
    -1
      source/crypto/pom.xml
  36. +1
    -1
      source/deployment/deployment-gateway/pom.xml
  37. +0
    -78
      source/deployment/deployment-gateway/src/main/resources/docs/api_doc_cn_1.3.MD
  38. +1
    -1
      source/deployment/deployment-peer/pom.xml
  39. +1
    -1
      source/deployment/pom.xml
  40. +1
    -1
      source/gateway/pom.xml
  41. +1
    -1
      source/ledger/ledger-core/pom.xml
  42. +1
    -1
      source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/MerkleDataSet.java
  43. +1
    -1
      source/ledger/ledger-model/pom.xml
  44. +1
    -1
      source/ledger/ledger-rpc/pom.xml
  45. +1
    -1
      source/ledger/pom.xml
  46. +1
    -1
      source/peer/pom.xml
  47. +1
    -1
      source/peer/src/main/java/com/jd/blockchain/peer/web/PeerTimeTasks.java
  48. +1
    -1
      source/pom.xml
  49. +1
    -1
      source/runtime/pom.xml
  50. +1
    -1
      source/runtime/runtime-context/pom.xml
  51. +1
    -1
      source/runtime/runtime-modular-booter/pom.xml
  52. +1
    -1
      source/runtime/runtime-modular/pom.xml
  53. +1
    -1
      source/sdk/pom.xml
  54. +1
    -1
      source/sdk/sdk-base/pom.xml
  55. +1
    -1
      source/sdk/sdk-client/pom.xml
  56. +1
    -1
      source/sdk/sdk-samples/pom.xml
  57. +1
    -1
      source/storage/pom.xml
  58. +1
    -1
      source/storage/storage-composite/pom.xml
  59. +1
    -1
      source/storage/storage-redis/pom.xml
  60. +1
    -1
      source/storage/storage-rocksdb/pom.xml
  61. +1
    -1
      source/storage/storage-service/pom.xml
  62. +1
    -1
      source/test/pom.xml
  63. +1
    -1
      source/test/test-consensus-client/pom.xml
  64. +2
    -2
      source/test/test-consensus-node/pom.xml
  65. +1
    -1
      source/test/test-integration/pom.xml
  66. +1
    -1
      source/test/test-ledger-core/pom.xml
  67. +1
    -1
      source/tools/pom.xml
  68. +1
    -1
      source/tools/tools-capability/pom.xml
  69. +1
    -1
      source/tools/tools-initializer-booter/pom.xml
  70. +1
    -1
      source/tools/tools-initializer/pom.xml
  71. +1
    -1
      source/tools/tools-keygen-booter/pom.xml
  72. +1
    -1
      source/tools/tools-keygen/pom.xml
  73. +1
    -1
      source/utils/pom.xml
  74. +1
    -1
      source/utils/utils-common/pom.xml
  75. +1
    -1
      source/utils/utils-http/pom.xml
  76. +1
    -1
      source/utils/utils-serialize/pom.xml
  77. +1
    -1
      source/utils/utils-test/pom.xml
  78. +1
    -1
      source/utils/utils-web-server/pom.xml
  79. +1
    -1
      source/utils/utils-web/pom.xml

+ 1
- 1
source/base/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>base</artifactId> <artifactId>base</artifactId>
</project> </project>

+ 1
- 1
source/binary-proto/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>binary-proto</artifactId> <artifactId>binary-proto</artifactId>




+ 1
- 1
source/consensus/consensus-bftsmart/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>consensus</artifactId> <artifactId>consensus</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>consensus-bftsmart</artifactId> <artifactId>consensus-bftsmart</artifactId>




+ 1
- 1
source/consensus/consensus-framework/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>consensus</artifactId> <artifactId>consensus</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>consensus-framework</artifactId> <artifactId>consensus-framework</artifactId>




+ 1
- 1
source/consensus/consensus-mq/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>consensus</artifactId> <artifactId>consensus</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>consensus-mq</artifactId> <artifactId>consensus-mq</artifactId>




+ 1
- 1
source/consensus/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>consensus</artifactId> <artifactId>consensus</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 47
- 0
source/contract/contract-compiler/pom.xml View File

@@ -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>

+ 107
- 0
source/contract/contract-engine/pom.xml View File

@@ -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>

+ 1
- 1
source/contract/contract-framework/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>contract</artifactId> <artifactId>contract</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>contract-framework</artifactId> <artifactId>contract-framework</artifactId>




+ 41
- 0
source/contract/contract-jar/pom.xml View File

@@ -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>

+ 1
- 1
source/contract/contract-jvm/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>contract</artifactId> <artifactId>contract</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>contract-jvm</artifactId> <artifactId>contract-jvm</artifactId>




+ 2
- 2
source/contract/contract-maven-plugin/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>contract</artifactId> <artifactId>contract</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>contract-maven-plugin</artifactId> <artifactId>contract-maven-plugin</artifactId>
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
@@ -15,7 +15,7 @@
<junit.version>4.12</junit.version> <junit.version>4.12</junit.version>
</properties> </properties>


<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>


+ 1
- 1
source/contract/contract-model/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>contract</artifactId> <artifactId>contract</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>contract-model</artifactId> <artifactId>contract-model</artifactId>




+ 80
- 0
source/contract/contract-tools/pom.xml View File

@@ -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>-->
<!--&lt;!&ndash;<arg>-verbose</arg>&ndash;&gt;-->
<!--&lt;!&ndash;<arg>-Xlint:unchecked</arg>&ndash;&gt;-->
<!--&lt;!&ndash;<arg>-Xlint:deprecation</arg>&ndash;&gt;-->
<!--&lt;!&ndash;<arg>-bootclasspath</arg>&ndash;&gt;-->
<!--&lt;!&ndash;<arg>${env.JAVA_HOME}/jre/lib/rt.jar</arg>&ndash;&gt;-->
<!--<arg>-extdirs</arg>-->
<!--<arg>${project.basedir}/../contract/contract-libs;$JAVA_HOME/jre/lib/ext</arg>-->
<!--</compilerArgs>-->
<!--</configuration>-->
<!--</plugin>-->
<!--</plugins>-->
<!--</build>-->
</project>

+ 1
- 1
source/contract/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>contract</artifactId> <artifactId>contract</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/crypto/crypto-adv/pom.xml View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>crypto</artifactId> <artifactId>crypto</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>crypto-adv</artifactId> <artifactId>crypto-adv</artifactId>




+ 118
- 0
source/crypto/crypto-adv/src/main/java/com/jd/blockchain/crypto/elgamal/ElGamalUtils.java View File

@@ -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;}

}

+ 107
- 0
source/crypto/crypto-adv/src/main/java/com/jd/blockchain/crypto/mpc/EqualVerify.java View File

@@ -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;
}
}

+ 270
- 0
source/crypto/crypto-adv/src/main/java/com/jd/blockchain/crypto/mpc/IntCompare.java View File

@@ -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);
}
}



+ 73
- 0
source/crypto/crypto-adv/src/test/java/test/com/jd/blockchain/crypto/elgamal/ElGamalUtilsTest.java View File

@@ -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])));
}
}

+ 73
- 0
source/crypto/crypto-adv/src/test/java/test/com/jd/blockchain/crypto/mpc/EqualVerifyTest.java View File

@@ -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);
}
}

}

+ 50
- 0
source/crypto/crypto-adv/src/test/java/test/com/jd/blockchain/crypto/mpc/IntCompareTest.java View File

@@ -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);
}
}
}

+ 1
- 1
source/crypto/crypto-framework/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>crypto</artifactId> <artifactId>crypto</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>crypto-framework</artifactId> <artifactId>crypto-framework</artifactId>




+ 10
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/asymmetric/AsymmetricCryptography.java View File

@@ -61,6 +61,16 @@ public interface AsymmetricCryptography {


SignatureDigest tryResolveSignatureDigest(byte[] digestBytes); SignatureDigest tryResolveSignatureDigest(byte[] digestBytes);


/**
* 由私钥恢复公钥;
*
* @param privKeyBytes 包含算法标识、密钥掩码和私钥的字节数组
* @return 包含算法标识、密钥掩码和公钥的字节数组
*/
byte[] retrievePubKeyBytes(byte[] privKeyBytes);

byte[] tryRetrievePubKeyBytes(byte[] privKeyBytes);

PubKey resolvePubKey(byte[] pubKeyBytes); PubKey resolvePubKey(byte[] pubKeyBytes);


PubKey tryResolvePubKey(byte[] pubKeyBytes); PubKey tryResolvePubKey(byte[] pubKeyBytes);


+ 8
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/asymmetric/AsymmetricEncryptionFunction.java View File

@@ -23,6 +23,14 @@ public interface AsymmetricEncryptionFunction extends CryptoKeyPairGenerator, Cr
*/ */
byte[] decrypt(PrivKey privKey, Ciphertext ciphertext); byte[] decrypt(PrivKey privKey, Ciphertext ciphertext);


/**
* 使用字节数组形式的私钥生成字节数组形式的公钥;
*
* @param privKeyBytes 包含算法标识、密钥掩码和私钥的字节数组
* @return 包含算法标识、密钥掩码和公钥的字节数组
*/
byte[] retrievePubKeyBytes(byte[] privKeyBytes);

/** /**
* 校验私钥格式是否满足要求; * 校验私钥格式是否满足要求;
* *


+ 8
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/asymmetric/SignatureFunction.java View File

@@ -22,6 +22,14 @@ public interface SignatureFunction extends CryptoKeyPairGenerator, CryptoFunctio
*/ */
boolean verify(SignatureDigest digest, PubKey pubKey, byte[] data); boolean verify(SignatureDigest digest, PubKey pubKey, byte[] data);


/**
* 使用字节数组形式的私钥生成字节数组形式的公钥;
*
* @param privKeyBytes 包含算法标识、密钥掩码和私钥的字节数组
* @return 包含算法标识、密钥掩码和公钥的字节数组
*/
byte[] retrievePubKeyBytes(byte[] privKeyBytes);

/** /**
* 校验私钥格式是否满足要求; * 校验私钥格式是否满足要求;
* *


+ 24
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/AsymmtricCryptographyImpl.java View File

@@ -135,6 +135,30 @@ public class AsymmtricCryptographyImpl implements AsymmetricCryptography {
return null; 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 @Override
public PubKey resolvePubKey(byte[] pubKeyBytes) { public PubKey resolvePubKey(byte[] pubKeyBytes) {
PubKey pubKey = tryResolvePubKey(pubKeyBytes); PubKey pubKey = tryResolvePubKey(pubKeyBytes);


+ 5
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/def/asymmetric/ECDSASignatureFunction.java View File

@@ -15,6 +15,11 @@ public class ECDSASignatureFunction implements SignatureFunction {
return false; return false;
} }


@Override
public byte[] retrievePubKeyBytes(byte[] privKeyBytes) {
return new byte[0];
}

@Override @Override
public boolean supportPrivKey(byte[] privKeyBytes) { public boolean supportPrivKey(byte[] privKeyBytes) {
return false; return false;


+ 13
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/def/asymmetric/ED25519SignatureFunction.java View File

@@ -7,6 +7,9 @@ import com.jd.blockchain.utils.security.Ed25519Utils;
import net.i2p.crypto.eddsa.EdDSAPrivateKey; import net.i2p.crypto.eddsa.EdDSAPrivateKey;
import net.i2p.crypto.eddsa.EdDSAPublicKey; import net.i2p.crypto.eddsa.EdDSAPublicKey;
import net.i2p.crypto.eddsa.KeyPairGenerator; 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; import java.security.KeyPair;


@@ -68,6 +71,16 @@ public class ED25519SignatureFunction implements SignatureFunction {
return Ed25519Utils.verify(data, rawPubKeyBytes, rawDigestBytes); 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 @Override
public boolean supportPrivKey(byte[] privKeyBytes) { public boolean supportPrivKey(byte[] privKeyBytes) {
// 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应ED25519签名算法,并且密钥类型是私钥 // 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应ED25519签名算法,并且密钥类型是私钥


+ 10
- 0
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/jni/asymmetric/JNIED25519SignatureFunction.java View File

@@ -3,6 +3,7 @@ package com.jd.blockchain.crypto.impl.jni.asymmetric;
import com.jd.blockchain.crypto.CryptoAlgorithm; import com.jd.blockchain.crypto.CryptoAlgorithm;
import com.jd.blockchain.crypto.asymmetric.*; import com.jd.blockchain.crypto.asymmetric.*;
import com.jd.blockchain.crypto.jniutils.asymmetric.JNIED25519Utils; 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.CryptoAlgorithm.JNIED25519;
import static com.jd.blockchain.crypto.CryptoBytes.ALGORYTHM_BYTES; import static com.jd.blockchain.crypto.CryptoBytes.ALGORYTHM_BYTES;
@@ -70,6 +71,15 @@ public class JNIED25519SignatureFunction implements SignatureFunction {
return ed25519.verify(data, rawPubKeyBytes, rawDigestBytes); 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 @Override
public boolean supportPrivKey(byte[] privKeyBytes) { public boolean supportPrivKey(byte[] privKeyBytes) {
// 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应JNIED25519签名算法,并且密钥类型是私钥 // 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应JNIED25519签名算法,并且密钥类型是私钥


+ 15
- 7
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/impl/sm/asymmetric/SM2CryptoFunction.java View File

@@ -7,7 +7,6 @@ import com.jd.blockchain.crypto.smutils.asymmetric.SM2Utils;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair; import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.crypto.params.ECPrivateKeyParameters; import org.bouncycastle.crypto.params.ECPrivateKeyParameters;
import org.bouncycastle.crypto.params.ECPublicKeyParameters; 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.CryptoAlgorithm.SM2;
import static com.jd.blockchain.crypto.CryptoBytes.ALGORYTHM_BYTES; import static com.jd.blockchain.crypto.CryptoBytes.ALGORYTHM_BYTES;
@@ -65,6 +64,14 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur
return SM2Utils.decrypt(rawCiphertextBytes,rawPrivKeyBytes); 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 @Override
public boolean supportPrivKey(byte[] privKeyBytes) { public boolean supportPrivKey(byte[] privKeyBytes) {
// 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应SM2算法,并且密钥类型是私钥 // 验证输入字节数组长度=算法标识长度+密钥类型长度+密钥长度,密钥数据的算法标识对应SM2算法,并且密钥类型是私钥
@@ -171,12 +178,13 @@ public class SM2CryptoFunction implements AsymmetricEncryptionFunction, Signatur
System.arraycopy(privKeyBytesD,privKeyBytesD.length-PRIVKEY_SIZE,privKeyBytes,0,PRIVKEY_SIZE); System.arraycopy(privKeyBytesD,privKeyBytesD.length-PRIVKEY_SIZE,privKeyBytes,0,PRIVKEY_SIZE);
else System.arraycopy(privKeyBytesD,0,privKeyBytes,PRIVKEY_SIZE-privKeyBytesD.length,privKeyBytesD.length); 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)); return new CryptoKeyPair(new PubKey(SM2,pubKeyBytes),new PrivKey(SM2,privKeyBytes));
} }


+ 11
- 7
source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/smutils/asymmetric/SM2Utils.java View File

@@ -13,7 +13,9 @@ import org.bouncycastle.crypto.generators.ECKeyPairGenerator;
import org.bouncycastle.crypto.params.*; import org.bouncycastle.crypto.params.*;
import org.bouncycastle.crypto.signers.SM2Signer; import org.bouncycastle.crypto.signers.SM2Signer;
import org.bouncycastle.math.ec.ECCurve; import org.bouncycastle.math.ec.ECCurve;
import org.bouncycastle.math.ec.ECMultiplier;
import org.bouncycastle.math.ec.ECPoint; import org.bouncycastle.math.ec.ECPoint;
import org.bouncycastle.math.ec.FixedPointCombMultiplier;


import java.io.IOException; import java.io.IOException;
import java.math.BigInteger; import java.math.BigInteger;
@@ -66,6 +68,13 @@ public class SM2Utils {
return keyPairGenerator.generateKeyPair(); 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----------------- //-----------------Digital Signature Algorithm-----------------


@@ -265,14 +274,9 @@ public class SM2Utils {


// To retrieve the public key point from publicKey in byte array mode // To retrieve the public key point from publicKey in byte array mode
private static ECPoint resolvePubKeyBytes(byte[] publicKey){ 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 ECCurve getCurve(){return curve;}
public static ECDomainParameters getDomainParams(){return domainParams;} public static ECDomainParameters getDomainParams(){return domainParams;}
} }


+ 46
- 0
source/crypto/crypto-framework/src/test/java/test/com/jd/blockchain/crypto/asymmetric/AsymmtricCryptographyImplTest.java View File

@@ -678,6 +678,52 @@ public class AsymmtricCryptographyImplTest {
public void testTryResolveSignatureDigest() { 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 @Test
public void testResolvePubKey() { public void testResolvePubKey() {




+ 12
- 0
source/crypto/crypto-framework/src/test/java/test/com/jd/blockchain/crypto/smutils/SM2UtilsTest.java View File

@@ -34,6 +34,18 @@ public class SM2UtilsTest {
assertArrayEquals(Hex.decode(expectedPublicKey),pubKeyBytes); 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 @Test
public void testSign() { public void testSign() {




+ 1
- 1
source/crypto/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>crypto</artifactId> <artifactId>crypto</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/deployment/deployment-gateway/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>deployment</artifactId> <artifactId>deployment</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>deployment-gateway</artifactId> <artifactId>deployment-gateway</artifactId>




+ 0
- 78
source/deployment/deployment-gateway/src/main/resources/docs/api_doc_cn_1.3.MD View File

@@ -1440,85 +1440,7 @@ http://localhost/ledgers/657TQAw6ssVoeKniWGwbovk7njvCTvikPambM9eBv6ezs/accounts/
|type|value类型| |type|value类型|
|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 搜索 ## 7 搜索




+ 1
- 1
source/deployment/deployment-peer/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>deployment</artifactId> <artifactId>deployment</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>deployment-peer</artifactId> <artifactId>deployment-peer</artifactId>




+ 1
- 1
source/deployment/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>deployment</artifactId> <artifactId>deployment</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/gateway/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>gateway</artifactId> <artifactId>gateway</artifactId>




+ 1
- 1
source/ledger/ledger-core/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>ledger</artifactId> <artifactId>ledger</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>ledger-core</artifactId> <artifactId>ledger-core</artifactId>




+ 1
- 1
source/ledger/ledger-core/src/main/java/com/jd/blockchain/ledger/core/MerkleDataSet.java View File

@@ -167,7 +167,7 @@ public class MerkleDataSet implements Transactional, MerkleProvable {
*/ */
public String getKeyAtIndex(int fromIndex) { public String getKeyAtIndex(int fromIndex) {
MerkleDataNode dataNode = merkleTree.getData(fromIndex); MerkleDataNode dataNode = merkleTree.getData(fromIndex);
return new String(dataNode.getKey().toBytes());
return new String(dataNode.getKey().toBytes());
} }


+ 1
- 1
source/ledger/ledger-model/pom.xml View File

@@ -6,7 +6,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>ledger</artifactId> <artifactId>ledger</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>ledger-model</artifactId> <artifactId>ledger-model</artifactId>


+ 1
- 1
source/ledger/ledger-rpc/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>ledger</artifactId> <artifactId>ledger</artifactId>
<version>0.8.3.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>ledger-rpc</artifactId> <artifactId>ledger-rpc</artifactId>




+ 1
- 1
source/ledger/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>ledger</artifactId> <artifactId>ledger</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/peer/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>peer</artifactId> <artifactId>peer</artifactId>


+ 1
- 1
source/peer/src/main/java/com/jd/blockchain/peer/web/PeerTimeTasks.java View File

@@ -38,7 +38,7 @@ import java.util.*;
* @since 1.0.0 * @since 1.0.0
*/ */
@Component @Component
@EnableScheduling
//@EnableScheduling
public class PeerTimeTasks implements ApplicationContextAware { public class PeerTimeTasks implements ApplicationContextAware {


private ApplicationContext applicationContext; private ApplicationContext applicationContext;


+ 1
- 1
source/pom.xml View File

@@ -16,7 +16,7 @@


<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<description>jdchain</description> <description>jdchain</description>




+ 1
- 1
source/runtime/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>runtime</artifactId> <artifactId>runtime</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/runtime/runtime-context/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>runtime</artifactId> <artifactId>runtime</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>runtime-context</artifactId> <artifactId>runtime-context</artifactId>




+ 1
- 1
source/runtime/runtime-modular-booter/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>runtime</artifactId> <artifactId>runtime</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>runtime-modular-booter</artifactId> <artifactId>runtime-modular-booter</artifactId>
</project> </project>

+ 1
- 1
source/runtime/runtime-modular/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>runtime</artifactId> <artifactId>runtime</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>runtime-modular</artifactId> <artifactId>runtime-modular</artifactId>




+ 1
- 1
source/sdk/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>sdk</artifactId> <artifactId>sdk</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/sdk/sdk-base/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>sdk</artifactId> <artifactId>sdk</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>sdk-base</artifactId> <artifactId>sdk-base</artifactId>


+ 1
- 1
source/sdk/sdk-client/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>sdk</artifactId> <artifactId>sdk</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>sdk-client</artifactId> <artifactId>sdk-client</artifactId>


+ 1
- 1
source/sdk/sdk-samples/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>sdk</artifactId> <artifactId>sdk</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>sdk-samples</artifactId> <artifactId>sdk-samples</artifactId>


+ 1
- 1
source/storage/pom.xml View File

@@ -3,7 +3,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>storage</artifactId> <artifactId>storage</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/storage/storage-composite/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>storage</artifactId> <artifactId>storage</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>storage-composite</artifactId> <artifactId>storage-composite</artifactId>




+ 1
- 1
source/storage/storage-redis/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>storage</artifactId> <artifactId>storage</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>storage-redis</artifactId> <artifactId>storage-redis</artifactId>


+ 1
- 1
source/storage/storage-rocksdb/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>storage</artifactId> <artifactId>storage</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>storage-rocksdb</artifactId> <artifactId>storage-rocksdb</artifactId>




+ 1
- 1
source/storage/storage-service/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>storage</artifactId> <artifactId>storage</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>storage-service</artifactId> <artifactId>storage-service</artifactId>


+ 1
- 1
source/test/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>test</artifactId> <artifactId>test</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/test/test-consensus-client/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>test</artifactId> <artifactId>test</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>test-consensus-client</artifactId> <artifactId>test-consensus-client</artifactId>




+ 2
- 2
source/test/test-consensus-node/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>test</artifactId> <artifactId>test</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>test-consensus-node</artifactId> <artifactId>test-consensus-node</artifactId>
<dependencies> <dependencies>
@@ -26,7 +26,7 @@
<dependency> <dependency>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>consensus-bftsmart</artifactId> <artifactId>consensus-bftsmart</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>


+ 1
- 1
source/test/test-integration/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>test</artifactId> <artifactId>test</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>test-integration</artifactId> <artifactId>test-integration</artifactId>




+ 1
- 1
source/test/test-ledger-core/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>test</artifactId> <artifactId>test</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>test-ledger-core</artifactId> <artifactId>test-ledger-core</artifactId>




+ 1
- 1
source/tools/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/tools/tools-capability/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>




+ 1
- 1
source/tools/tools-initializer-booter/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>tools-initializer-booter</artifactId> <artifactId>tools-initializer-booter</artifactId>




+ 1
- 1
source/tools/tools-initializer/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>tools-initializer</artifactId> <artifactId>tools-initializer</artifactId>




+ 1
- 1
source/tools/tools-keygen-booter/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>tools-keygen-booter</artifactId> <artifactId>tools-keygen-booter</artifactId>




+ 1
- 1
source/tools/tools-keygen/pom.xml View File

@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>tools</artifactId> <artifactId>tools</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>tools-keygen</artifactId> <artifactId>tools-keygen</artifactId>




+ 1
- 1
source/utils/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>jdchain-root</artifactId> <artifactId>jdchain-root</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>


+ 1
- 1
source/utils/utils-common/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>utils-common</artifactId> <artifactId>utils-common</artifactId>


+ 1
- 1
source/utils/utils-http/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>


+ 1
- 1
source/utils/utils-serialize/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>utils-serialize</artifactId> <artifactId>utils-serialize</artifactId>


+ 1
- 1
source/utils/utils-test/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>utils-test</artifactId> <artifactId>utils-test</artifactId>


+ 1
- 1
source/utils/utils-web-server/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>utils-web-server</artifactId> <artifactId>utils-web-server</artifactId>


+ 1
- 1
source/utils/utils-web/pom.xml View File

@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.jd.blockchain</groupId> <groupId>com.jd.blockchain</groupId>
<artifactId>utils</artifactId> <artifactId>utils</artifactId>
<version>0.8.2.RELEASE</version>
<version>0.9.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>utils-web</artifactId> <artifactId>utils-web</artifactId>
<dependencies> <dependencies>


Loading…
Cancel
Save