github.com/pvitto98/fabric@v2.1.1+incompatible/idemix/nonrevocation-prover.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package idemix
     8  
     9  import (
    10  	"github.com/hyperledger/fabric-amcl/amcl"
    11  	"github.com/hyperledger/fabric-amcl/amcl/FP256BN"
    12  	"github.com/pkg/errors"
    13  )
    14  
    15  // nonRevokedProver is the Prover of the ZK proof system that handles revocation.
    16  type nonRevokedProver interface {
    17  	// getFSContribution returns the non-revocation contribution to the Fiat-Shamir hash, forming the challenge of the ZKP,
    18  	getFSContribution(rh *FP256BN.BIG, rRh *FP256BN.BIG, cri *CredentialRevocationInformation, rng *amcl.RAND) ([]byte, error)
    19  
    20  	// getNonRevokedProof returns a proof of non-revocation with the respect to passed challenge
    21  	getNonRevokedProof(chal *FP256BN.BIG) (*NonRevocationProof, error)
    22  }
    23  
    24  // nopNonRevokedProver is an empty nonRevokedProver
    25  type nopNonRevokedProver struct{}
    26  
    27  func (prover *nopNonRevokedProver) getFSContribution(rh *FP256BN.BIG, rRh *FP256BN.BIG, cri *CredentialRevocationInformation, rng *amcl.RAND) ([]byte, error) {
    28  	return nil, nil
    29  }
    30  
    31  func (prover *nopNonRevokedProver) getNonRevokedProof(chal *FP256BN.BIG) (*NonRevocationProof, error) {
    32  	ret := &NonRevocationProof{}
    33  	ret.RevocationAlg = int32(ALG_NO_REVOCATION)
    34  	return ret, nil
    35  }
    36  
    37  // getNonRevocationProver returns the nonRevokedProver bound to the passed revocation algorithm
    38  func getNonRevocationProver(algorithm RevocationAlgorithm) (nonRevokedProver, error) {
    39  	switch algorithm {
    40  	case ALG_NO_REVOCATION:
    41  		return &nopNonRevokedProver{}, nil
    42  	default:
    43  		// unknown revocation algorithm
    44  		return nil, errors.Errorf("unknown revocation algorithm %d", algorithm)
    45  	}
    46  }