Skip to content
This repository was archived by the owner on Apr 22, 2025. It is now read-only.

Commit f15f58e

Browse files
Revert "[FABJ-394] Signature-based whitelisting"
This reverts commit 5f3a0c4. Reason for revert: breaks merge build Change-Id: Ida7dd1a35c41d1c5aac3060c79fdb06b8decf165 Signed-off-by: Andrew Coleman <andrew_coleman@uk.ibm.com>
1 parent 5f3a0c4 commit f15f58e

File tree

12 files changed

+95
-356
lines changed

12 files changed

+95
-356
lines changed

src/main/java/org/hyperledger/fabric/sdk/idemix/IdemixCredRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.io.PrintWriter;
2020
import java.io.StringWriter;
21+
import java.util.ArrayList;
2122
import java.util.Arrays;
2223
import java.util.Base64;
2324

src/main/java/org/hyperledger/fabric/sdk/idemix/IdemixSignature.java

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,18 @@ public IdemixSignature(IdemixCredential c, BIG sk, IdemixPseudonym pseudonym, Id
120120
rAttrs[i] = IdemixUtils.randModOrder(rng);
121121
}
122122

123-
// Compute revocation contribution
124-
RevocationProver prover = RevocationProver.getProver(revocationAlgorithm);
123+
// Compute non-revoked proof
124+
NonRevocationProver prover = NonRevocationProver.getNonRevocationProver(revocationAlgorithm);
125125
int hiddenRHIndex = Ints.indexOf(hiddenIndices, rhIndex);
126126
if (hiddenRHIndex < 0) {
127127
// rhIndex is not present, set to last index position
128128
hiddenRHIndex = hiddenIndices.length;
129129
}
130-
byte[] revocationFSContribution = prover.getFSContribution(
131-
BIG.fromBytes(c.getAttrs()[rhIndex]),
132-
rAttrs[hiddenRHIndex],
133-
cri
134-
);
135-
if (revocationFSContribution == null) {
130+
byte[] nonRevokedProofHashData = prover.getFSContribution(BIG.fromBytes(c.getAttrs()[rhIndex]), rAttrs[hiddenRHIndex], cri);
131+
if (nonRevokedProofHashData == null) {
136132
throw new RuntimeException("Failed to compute non-revoked proof");
137133
}
138134

139-
// System.out.println(Arrays.toString(revocationFSContribution));
140-
141135
ECP t1 = aPrime.mul2(re, ipk.getHRand(), rR2);
142136
ECP t2 = PAIR.G1mul(ipk.getHRand(), rSPrime);
143137
t2.add(bPrime.mul2(rR3, ipk.getHsk(), rsk));
@@ -162,7 +156,6 @@ public IdemixSignature(IdemixCredential c, BIG sk, IdemixPseudonym pseudonym, Id
162156
proofData = IdemixUtils.append(proofData, IdemixUtils.ecpToBytes(aBar));
163157
proofData = IdemixUtils.append(proofData, IdemixUtils.ecpToBytes(bPrime));
164158
proofData = IdemixUtils.append(proofData, IdemixUtils.ecpToBytes(pseudonym.getNym()));
165-
proofData = IdemixUtils.append(proofData, revocationFSContribution);
166159
proofData = IdemixUtils.append(proofData, ipk.getHash());
167160
proofData = IdemixUtils.append(proofData, disclosure);
168161
proofData = IdemixUtils.append(proofData, msg);
@@ -270,6 +263,12 @@ public boolean verify(boolean[] disclosure, IdemixIssuerPublicKey ipk, byte[] ms
270263
throw new IllegalArgumentException("Attribute " + rhIndex + " is disclosed but also used a revocation handle attribute, which should remain hidden");
271264
}
272265

266+
// Verify EpochPK
267+
if (!RevocationAuthority.verifyEpochPK(revPk, this.revocationPk, this.revocationPKSig, epoch, revocationAlgorithm)) {
268+
// Signature is based on an invalid revocation epoch public key
269+
return false;
270+
}
271+
273272
FP12 temp1 = PAIR.ate(ipk.getW(), aPrime);
274273
FP12 temp2 = PAIR.ate(IdemixUtils.genG2, aBar);
275274
temp2.inverse();
@@ -307,19 +306,18 @@ public boolean verify(boolean[] disclosure, IdemixIssuerPublicKey ipk, byte[] ms
307306
ECP t3 = ipk.getHsk().mul2(proofSSk, ipk.getHRand(), proofSRNym);
308307
t3.sub(nym.mul(proofC));
309308

310-
// Involve the revocation verifier
311-
RevocationVerifier revocationVerifier = RevocationVerifier.getVerifier(revocationAlgorithm);
309+
// Check with non-revoked-verifier
310+
NonRevocationVerifier nonRevokedVerifier = NonRevocationVerifier.getNonRevocationVerifier(revocationAlgorithm);
312311
int hiddenRHIndex = Ints.indexOf(hiddenIndices, rhIndex);
313312
if (hiddenRHIndex < 0) {
314313
// rhIndex is not present, set to last index position
315314
hiddenRHIndex = hiddenIndices.length;
316315
}
317316
BIG proofSRh = proofSAttrs[hiddenRHIndex];
318-
byte[] revocationFSContribution = revocationVerifier.recomputeFSContribution(this.nonRevocationProof, proofC, IdemixUtils.transformFromProto(this.revocationPk), proofSRh);
319-
if (revocationFSContribution == null) {
317+
byte[] nonRevokedProofBytes = nonRevokedVerifier.recomputeFSContribution(this.nonRevocationProof, proofC, IdemixUtils.transformFromProto(this.revocationPk), proofSRh);
318+
if (nonRevokedProofBytes == null) {
320319
return false;
321320
}
322-
// System.out.println(Arrays.toString(revocationFSContribution));
323321

324322
// create proofData such that it can contain the sign label, 7 elements in G1 (each of size 2*FIELD_BYTES+1),
325323
// the ipk hash, the disclosure array, and the message
@@ -332,7 +330,6 @@ public boolean verify(boolean[] disclosure, IdemixIssuerPublicKey ipk, byte[] ms
332330
proofData = IdemixUtils.append(proofData, IdemixUtils.ecpToBytes(aBar));
333331
proofData = IdemixUtils.append(proofData, IdemixUtils.ecpToBytes(bPrime));
334332
proofData = IdemixUtils.append(proofData, IdemixUtils.ecpToBytes(nym));
335-
proofData = IdemixUtils.append(proofData, revocationFSContribution);
336333
proofData = IdemixUtils.append(proofData, ipk.getHash());
337334
proofData = IdemixUtils.append(proofData, disclosure);
338335
proofData = IdemixUtils.append(proofData, msg);
@@ -344,21 +341,7 @@ public boolean verify(boolean[] disclosure, IdemixIssuerPublicKey ipk, byte[] ms
344341
finalProofData = IdemixUtils.append(finalProofData, IdemixUtils.bigToBytes(nonce));
345342

346343
byte[] hashedProofData = IdemixUtils.bigToBytes(IdemixUtils.hashModOrder(finalProofData));
347-
if (!Arrays.equals(IdemixUtils.bigToBytes(proofC), hashedProofData)) {
348-
// System.out.println("invalid proof");
349-
return false;
350-
}
351-
352-
// Check revocation
353-
// - Epoch
354-
if (this.epoch != epoch) {
355-
// System.out.println("different epoch");
356-
return false;
357-
}
358-
359-
// - EpochPk
360-
RevocationAuthority ra = new RevocationAuthority(revPk);
361-
return ra.verifyEpochPK(this.revocationPk, this.revocationPKSig, epoch, revocationAlgorithm);
344+
return Arrays.equals(IdemixUtils.bigToBytes(proofC), hashedProofData);
362345
}
363346

364347
/**

src/main/java/org/hyperledger/fabric/sdk/idemix/IdemixUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.io.ByteArrayOutputStream;
2020
import java.io.IOException;
2121
import java.security.SecureRandom;
22+
import java.util.ArrayList;
23+
import java.util.List;
2224

2325
import com.google.protobuf.ByteString;
2426
import org.apache.milagro.amcl.FP256BN.BIG;
@@ -150,9 +152,6 @@ static byte[] ecpToBytes(ECP2 e) {
150152
* @return a new byte[] of data + toAppend
151153
*/
152154
static byte[] append(byte[] data, byte[] toAppend) {
153-
if (toAppend.length == 0) {
154-
return data;
155-
}
156155

157156
ByteArrayOutputStream stream = new ByteArrayOutputStream();
158157
try {

src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationProver.java renamed to src/main/java/org/hyperledger/fabric/sdk/idemix/NonRevocationProver.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,24 @@
1919
import org.hyperledger.fabric.protos.idemix.Idemix;
2020

2121
/**
22-
* A RevocationProver is a prover that can prove that an identity mixer credential is not revoked.
23-
* For every RevocationAlgorithm, there will be an instantiation of RevocationProver.
22+
* A NonRevocationProver is a prover that can prove that an identity mixer credential is not revoked.
23+
* For every RevocationAlgorithm, there will be an instantiation of NonRevocationProver.
2424
*/
25-
interface RevocationProver {
25+
interface NonRevocationProver {
2626

2727
/**
2828
* This method provides a concrete non-revocation for a given Revocation algorithm
2929
*
3030
* @param algorithm Revocation mechanism to use
31-
* @return A concrete RevocationProver for the given revocation mechanism
31+
* @return A concrete NonRevocationProver for the given revocation mechanism
3232
*/
33-
static RevocationProver getProver(RevocationAlgorithm algorithm) {
33+
static NonRevocationProver getNonRevocationProver(RevocationAlgorithm algorithm) {
3434
if (algorithm == null) {
3535
throw new IllegalArgumentException("Revocation algorithm cannot be null");
3636
}
3737
switch (algorithm) {
3838
case ALG_NO_REVOCATION:
39-
return new NopRevocationProver();
40-
case ALG_PLAIN_SIGNATURE:
41-
return new PlainSigRevocationProver();
39+
return new NopNonRevocationProver();
4240
default:
4341
// Revocation algorithm not supported
4442
throw new IllegalArgumentException("Revocation algorithm " + algorithm.name() + " not supported");

src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationVerifier.java renamed to src/main/java/org/hyperledger/fabric/sdk/idemix/NonRevocationVerifier.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,23 @@
2121
import org.hyperledger.fabric.protos.idemix.Idemix;
2222

2323
/**
24-
* A RevocationProver is a prover that can prove that an identity mixer credential is not revoked.
25-
* For every RevocationAlgorithm, there will be an instantiation of RevocationProver.
24+
* A NonRevocationProver is a prover that can prove that an identity mixer credential is not revoked.
25+
* For every RevocationAlgorithm, there will be an instantiation of NonRevocationProver.
2626
*/
27-
interface RevocationVerifier {
27+
interface NonRevocationVerifier {
2828
/**
2929
* This method provides a non-revocation verifier depending on the Revocation algorithm
3030
*
3131
* @param algorithm Revocation mechanism to use
32-
* @return RevocationVerifier or null if not allowed
32+
* @return NonRevocationVerifier or null if not allowed
3333
*/
34-
static RevocationVerifier getVerifier(RevocationAlgorithm algorithm) {
34+
static NonRevocationVerifier getNonRevocationVerifier(RevocationAlgorithm algorithm) {
3535
if (algorithm == null) {
3636
throw new IllegalArgumentException("Revocation algorithm cannot be null");
3737
}
3838
switch (algorithm) {
3939
case ALG_NO_REVOCATION:
40-
return new NopRevocationVerifier();
41-
case ALG_PLAIN_SIGNATURE:
42-
return new PlainSignRevocationVerifier();
40+
return new NopNonRevocationVerifier();
4341
default:
4442
// Revocation algorithm not supported
4543
throw new Error("Revocation algorithm " + algorithm.name() + " not supported");

src/main/java/org/hyperledger/fabric/sdk/idemix/NopRevocationProver.java renamed to src/main/java/org/hyperledger/fabric/sdk/idemix/NopNonRevocationProver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import org.hyperledger.fabric.protos.idemix.Idemix;
2020

2121
/**
22-
* NopRevocationProver is a concrete RevocationProver for RevocationAlgorithm "ALG_NO_REVOCATION"
22+
* NopNonRevocationProver is a concrete NonRevocationProver for RevocationAlgorithm "ALG_NO_REVOCATION"
2323
*/
24-
class NopRevocationProver implements RevocationProver {
24+
class NopNonRevocationProver implements NonRevocationProver {
2525
private final byte[] empty = new byte[0];
2626

2727
public byte[] getFSContribution(BIG rh, BIG rRh, Idemix.CredentialRevocationInformation cri) {

src/main/java/org/hyperledger/fabric/sdk/idemix/NopRevocationVerifier.java renamed to src/main/java/org/hyperledger/fabric/sdk/idemix/NopNonRevocationVerifier.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
import org.hyperledger.fabric.protos.idemix.Idemix;
2121

2222
/**
23-
* NopRevocationVerifier is a concrete RevocationVerifier for RevocationAlgorithm "ALG_NO_REVOCATION"
23+
* NopNonRevocationVerifier is a concrete NonRevocationVerifier for RevocationAlgorithm "ALG_NO_REVOCATION"
2424
*/
25-
class NopRevocationVerifier implements RevocationVerifier {
25+
class NopNonRevocationVerifier implements NonRevocationVerifier {
2626
private final byte[] empty = new byte[0];
27-
2827
public byte[] recomputeFSContribution(Idemix.NonRevocationProof proof, BIG challenge, ECP2 epochPK, BIG proofSRh) {
2928
return empty;
3029
}

src/main/java/org/hyperledger/fabric/sdk/idemix/PlainSigRevocationProver.java

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)