forked from hyperledger/fabric-gateway
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Support for Identity Mixer Signing
- Loading branch information
1 parent
ab935e8
commit 75cd65c
Showing
40 changed files
with
3,700 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<fileset-config file-format-version="1.2.0" simple-config="false" sync-formatter="false"> | ||
<local-check-config name="maven-checkstyle-plugin validate" location="file:/home/kavin/work/my/opensource/2022/new_repos/fabric-gateway/java/checkstyle.xml" type="remote" description="maven-checkstyle-plugin configuration validate"> | ||
<property name="checkstyle.header.file" value="/home/kavin/Documents/workspace-spring-tool-suite-4-4.16.1.RELEASE/.metadata/.plugins/org.eclipse.core.resources/.projects/fabric-gateway/com.basistech.m2e.code.quality.checkstyleConfigurator/checkstyle-header-validate.txt"/> | ||
<property name="checkstyle.cache.file" value="${project_loc}/target/checkstyle-cachefile"/> | ||
</local-check-config> | ||
<fileset name="java-sources-validate" enabled="true" check-config-name="maven-checkstyle-plugin validate" local="true"> | ||
<file-match-pattern match-pattern="^src/main/java/.*\/.*\.java" include-pattern="true"/> | ||
<file-match-pattern match-pattern="^src/main/resources.*\.properties" include-pattern="true"/> | ||
<file-match-pattern match-pattern="^src/test/resources/.*\.properties" include-pattern="true"/> | ||
</fileset> | ||
</fileset-config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
java/src/main/java/org/hyperledger/fabric/client/identity/IdemixPrivateKeySigner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2020 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.client.identity; | ||
|
||
import java.security.GeneralSecurityException; | ||
import org.apache.milagro.amcl.FP256BN.BIG; | ||
import org.hyperledger.fabric.client.identity.idemix.IdemixIssuerPublicKey; | ||
import org.hyperledger.fabric.client.identity.idemix.IdemixPseudonym; | ||
import org.hyperledger.fabric.client.identity.idemix.IdemixPseudonymSignature; | ||
|
||
final class IdemixPrivateKeySigner implements Signer { | ||
private final BIG sk; | ||
private final IdemixPseudonym pseudonym; | ||
private final IdemixIssuerPublicKey ipk; | ||
|
||
IdemixPrivateKeySigner(final BIG sk, final IdemixPseudonym pseudonym, final IdemixIssuerPublicKey ipk) { | ||
this.sk = sk; | ||
this.pseudonym = pseudonym; | ||
this.ipk = ipk; | ||
} | ||
|
||
@Override | ||
public byte[] sign(final byte[] msg) throws GeneralSecurityException { | ||
if (msg == null) { | ||
throw new GeneralSecurityException("Message must not be null"); | ||
} | ||
return new IdemixPseudonymSignature(this.sk, this.pseudonym, this.ipk, msg).toProto().toByteArray(); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
java/src/main/java/org/hyperledger/fabric/client/identity/IdemixerIdentity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2019 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.client.identity; | ||
|
||
import org.hyperledger.fabric.client.identity.idemix.IdemixIdentity; | ||
|
||
/** | ||
* A client identity described by an Idemix Identity. The {@link Identities} class provides static methods to create | ||
* an Idemix Identity object. | ||
*/ | ||
public final class IdemixerIdentity implements Identity { | ||
|
||
private final String mspId; | ||
private final IdemixIdentity idemixIdentity; | ||
private final byte[] credentials; | ||
|
||
/** | ||
* Constructor. | ||
* @param mspId A membership service provider identifier. | ||
* @param idemixIdentity An Idemix Identity. | ||
*/ | ||
public IdemixerIdentity(final String mspId, final IdemixIdentity idemixIdentity) { | ||
this.mspId = mspId; | ||
this.idemixIdentity = idemixIdentity; | ||
credentials = idemixIdentity.createIdentityByteArray(); | ||
} | ||
|
||
@Override | ||
public String getMspId() { | ||
return mspId; | ||
} | ||
|
||
@Override | ||
public byte[] getCredentials() { | ||
return credentials.clone(); | ||
} | ||
|
||
/** | ||
* Get a Idemix Identity for this identity. | ||
* @return An Idemix Identity. | ||
*/ | ||
public IdemixIdentity getIdemixIdentity() { | ||
return idemixIdentity; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
java/src/main/java/org/hyperledger/fabric/client/identity/exception/BaseException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2019 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.client.identity.exception; | ||
|
||
/** | ||
* BaseException Class is a Base for all exceptions. | ||
*/ | ||
public class BaseException extends Exception { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* This method accepts exception message as a string and an exception class. | ||
* @param message an exception message | ||
* @param parent a parent exception class | ||
*/ | ||
public BaseException(final String message, final Throwable parent) { | ||
super(message, parent); | ||
} | ||
|
||
/** | ||
* This method accepts exception message as a string. | ||
* @param message an exception message | ||
*/ | ||
public BaseException(final String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* This method accepts throwable class. | ||
* @param t a throwable class object | ||
*/ | ||
public BaseException(final Throwable t) { | ||
super(t); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
java/src/main/java/org/hyperledger/fabric/client/identity/exception/CryptoException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2019 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.client.identity.exception; | ||
|
||
/** | ||
* CryptoException Class is a exception class for all crypto related exceptions. | ||
*/ | ||
public class CryptoException extends BaseException { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* This method accepts exception message as a string and an exception class. | ||
* @param message an exception message | ||
* @param parent a parent exception class | ||
*/ | ||
public CryptoException(final String message, final Exception parent) { | ||
super(message, parent); | ||
} | ||
|
||
/** | ||
* This method accepts exception message as a string. | ||
* @param message an exception message | ||
*/ | ||
public CryptoException(final String message) { | ||
super(message); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
.../main/java/org/hyperledger/fabric/client/identity/exception/InvalidArgumentException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2019 IBM All Rights Reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.client.identity.exception; | ||
|
||
/** | ||
* InvalidArgumentException class is an exception class. | ||
*/ | ||
public class InvalidArgumentException extends BaseException { | ||
private static final long serialVersionUID = -6094512275378074427L; | ||
|
||
/** | ||
* This method accepts exception message as a string and an exception class. | ||
* @param message an exception message | ||
* @param parent a parent exception class | ||
*/ | ||
public InvalidArgumentException(final String message, final Exception parent) { | ||
super(message, parent); | ||
} | ||
|
||
/** | ||
* This method accepts exception message as a string. | ||
* @param message an exception message | ||
*/ | ||
public InvalidArgumentException(final String message) { | ||
super(message); | ||
} | ||
|
||
/** | ||
* This method accepts throwable class. | ||
* @param t a throwable class object | ||
*/ | ||
public InvalidArgumentException(final Throwable t) { | ||
super(t); | ||
} | ||
} | ||
|
Oops, something went wrong.