github.com/hechain20/hechain@v0.0.0-20220316014945-b544036ba106/core/handlers/validation/api/identities/identities.go (about)

     1  /*
     2  Copyright hechain. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package validation
     8  
     9  import (
    10  	validation "github.com/hechain20/hechain/core/handlers/validation/api"
    11  	"github.com/hyperledger/fabric-protos-go/msp"
    12  )
    13  
    14  // IdentityDeserializer converts serialized identities
    15  // to identities.
    16  type IdentityDeserializer interface {
    17  	validation.Dependency
    18  	// DeserializeIdentity deserializes an identity.
    19  	// Deserialization will fail if the identity is associated to
    20  	// an msp that is different from this one that is performing
    21  	// the deserialization.
    22  	DeserializeIdentity(serializedIdentity []byte) (Identity, error)
    23  }
    24  
    25  // Identity interface defining operations associated to a "certificate".
    26  // That is, the public part of the identity could be thought to be a certificate,
    27  // and offers solely signature verification capabilities. This is to be used
    28  // at the peer side when verifying certificates that transactions are signed
    29  // with, and verifying signatures that correspond to these certificates.///
    30  type Identity interface {
    31  	// Validate uses the rules that govern this identity to validate it.
    32  	Validate() error
    33  
    34  	// SatisfiesPrincipal checks whether this instance matches
    35  	// the description supplied in MSPPrincipal. The check may
    36  	// involve a byte-by-byte comparison (if the principal is
    37  	// a serialized identity) or may require MSP validation
    38  	SatisfiesPrincipal(principal *msp.MSPPrincipal) error
    39  
    40  	// Verify a signature over some message using this identity as reference
    41  	Verify(msg []byte, sig []byte) error
    42  
    43  	// GetIdentityIdentifier returns the identifier of that identity
    44  	GetIdentityIdentifier() *IdentityIdentifier
    45  
    46  	// GetMSPIdentifier returns the MSP Id for this instance
    47  	GetMSPIdentifier() string
    48  }
    49  
    50  // IdentityIdentifier is a holder for the identifier of a specific
    51  // identity, naturally namespaced, by its provider identifier.
    52  type IdentityIdentifier struct {
    53  
    54  	// The identifier of the associated membership service provider
    55  	Mspid string
    56  
    57  	// The identifier for an identity within a provider
    58  	Id string
    59  }