idemix

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2022 License: Apache-2.0 Imports: 16 Imported by: 8

README

Idemix

License Go Report Card Go

This project is a Go implementation of an anonymous identity stack for blockchain systems.

Protocol

Here we describe the cryptographic protocol that is implemented.

Preliminaries

TBD (Group etc.)

Generation of issue certificate

The input for this step are the 4 attributes that are certified, namely OU, Role, EnrollmentID and RevocationHandle (call them ).

Given these attributes, the CA samples the issuer secret key at random

And then computes

For each attribute the CA picks a random element and generates a base for that attribute

The CA randomly selects and computes bases

Then the CA randomly selects and computes

It also generates

The issuer public key is

where is a hash of all fields of the public key.

and the issuer private key is is

Generation of client certificate

Given a client with attributes , the client samples the secret key

and random elements

and then computes

The credential request sent to the CA is .

The CA computes

and checks whether

If so, the CA picks random elements

and computes

The CA returns the credential to the user.

The user verifies the credential by computing

If the user aborts. Otherwise it verifies the signature by checking whether the following equality

holds. If so, the user accepts private key and the user public key is .

Generation of signature

To sign message and simultaneously disclose a subset of attributes (tracked by the bits such that if the bit is one the corresponding attribute is disclosed; notationally, ), the client chooses a new random element and generates a new pseudonym

And then generates the new signature as follows

The client then generates random elements

and then generates

and for each attribute that requires disclosure, it generates

The signature is .

Verification of a signature

Upon receipt of a signature is over message the verifier checks whether the following equality holds

If so, it recomputes

and accepts the signature if

This verification also verifies the disclosed subset of attributes.

Generation of a pseudonymous signature

Differently from a standard signature, a pseudonymous signature does not prove that the pseudonym possesses a user certificate signed by a CA. It only proves that the pseudonym signed message . The signature is generated starting from the pseudonym (as generated in the section above) together with secret key and randomness as follows: at first it picks random elements

Then it generates

The signature is .

Verification of a pseudonymous signature

Upon receipt of a pseudonymous signature over message the verifier recomputes

and accepts the signature if

Extensions

Adding a pseudonym as a function of the Enrollment ID (eid)

The enrollment id is one of the cerified attributes ( with value ). This extension introduces a pseudonym which is a function of the enrollment ID, together with a proof that it was correclty generated.

Signature generation

The pseudonym is computed by sampling

and by generating the pseudonym

Signature generation is similar to the scheme above; in particular, the term is the same used by the original sign algorithm. The extensions include:

  • the client computes an additional value ;

  • the client includes in the challenge computation: (if is included, it should always be set to 0 otherwise the value of the enrollment ID would be revealed);

  • the client computes an additional proof ;

  • The signature includes the additional proof and pseudonym .

Signature verification

Signature verification is the same as above except that

  • verifier computes ;

  • verifier checks if .

Auditing NymEid

To Audit NymEid the client reveals pair and the auditor checks if .

Documentation

Overview

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	// AttributeIndexOU contains the index of the OU attribute in the idemix credential attributes
	AttributeIndexOU = iota

	// AttributeIndexRole contains the index of the Role attribute in the idemix credential attributes
	AttributeIndexRole

	// AttributeIndexEnrollmentId contains the index of the Enrollment ID attribute in the idemix credential attributes
	AttributeIndexEnrollmentId

	// AttributeIndexRevocationHandle contains the index of the Revocation Handle attribute in the idemix credential attributes
	AttributeIndexRevocationHandle
)
View Source
const (
	// AttributeNameOU is the attribute name of the Organization Unit attribute
	AttributeNameOU = "OU"

	// AttributeNameRole is the attribute name of the Role attribute
	AttributeNameRole = "Role"

	// AttributeNameEnrollmentId is the attribute name of the Enrollment ID attribute
	AttributeNameEnrollmentId = "EnrollmentID"

	// AttributeNameRevocationHandle is the attribute name of the revocation handle attribute
	AttributeNameRevocationHandle = "RevocationHandle"
)
View Source
const (
	MSPv1_0 = iota
	MSPv1_1
	MSPv1_3
	MSPv1_4_3
)
View Source
const (
	IdemixConfigDirMsp                  = "msp"
	IdemixConfigDirUser                 = "user"
	IdemixConfigFileIssuerPublicKey     = "IssuerPublicKey"
	IdemixConfigFileRevocationPublicKey = "RevocationPublicKey"
	IdemixConfigFileSigner              = "SignerConfig"
)

Variables

This section is empty.

Functions

func GetIdemixMspConfig

func GetIdemixMspConfig(dir string, ID string) (*msp.MSPConfig, error)

GetIdemixMspConfig returns the configuration for the Idemix MSP

func GetRoleMaskFromIdemixRole

func GetRoleMaskFromIdemixRole(role Role) int

GetRoleMaskFromIdemixRole return a bitmask for one role

func ProviderTypeToString

func ProviderTypeToString(id ProviderType) string

ProviderTypeToString returns a string that represents the ProviderType integer

Types

type IdemixSigningIdentity

type IdemixSigningIdentity struct {
	*Idemixidentity
	Cred    []byte
	UserKey bccsp.Key
	NymKey  bccsp.Key
	// contains filtered or unexported fields
}

func (*IdemixSigningIdentity) GetPublicVersion

func (id *IdemixSigningIdentity) GetPublicVersion() Identity

func (*IdemixSigningIdentity) Sign

func (id *IdemixSigningIdentity) Sign(msg []byte) ([]byte, error)

type Idemixidentity

type Idemixidentity struct {
	NymPublicKey bccsp.Key

	Role *m.MSPRole
	OU   *m.OrganizationUnit
	// contains filtered or unexported fields
}

func (*Idemixidentity) Anonymous

func (id *Idemixidentity) Anonymous() bool

func (*Idemixidentity) ExpiresAt

func (id *Idemixidentity) ExpiresAt() time.Time

func (*Idemixidentity) GetIdentifier

func (id *Idemixidentity) GetIdentifier() *IdentityIdentifier

func (*Idemixidentity) GetMSPIdentifier

func (id *Idemixidentity) GetMSPIdentifier() string

func (*Idemixidentity) GetOrganizationalUnits

func (id *Idemixidentity) GetOrganizationalUnits() []*OUIdentifier

func (*Idemixidentity) SatisfiesPrincipal

func (id *Idemixidentity) SatisfiesPrincipal(principal *m.MSPPrincipal) error

func (*Idemixidentity) Serialize

func (id *Idemixidentity) Serialize() ([]byte, error)

func (*Idemixidentity) Validate

func (id *Idemixidentity) Validate() error

func (*Idemixidentity) Verify

func (id *Idemixidentity) Verify(msg []byte, sig []byte) error

type Idemixmsp

type Idemixmsp struct {
	// contains filtered or unexported fields
}

func (*Idemixmsp) DeserializeIdentity

func (msp *Idemixmsp) DeserializeIdentity(serializedID []byte) (Identity, error)

func (*Idemixmsp) DeserializeIdentityInternal

func (msp *Idemixmsp) DeserializeIdentityInternal(serializedID []byte) (Identity, error)

func (*Idemixmsp) GetDefaultSigningIdentity

func (msp *Idemixmsp) GetDefaultSigningIdentity() (SigningIdentity, error)

func (*Idemixmsp) GetIdentifier

func (msp *Idemixmsp) GetIdentifier() (string, error)

func (*Idemixmsp) GetTLSIntermediateCerts

func (msp *Idemixmsp) GetTLSIntermediateCerts() [][]byte

func (*Idemixmsp) GetTLSRootCerts

func (msp *Idemixmsp) GetTLSRootCerts() [][]byte

func (*Idemixmsp) GetType

func (msp *Idemixmsp) GetType() ProviderType

func (*Idemixmsp) GetVersion

func (msp *Idemixmsp) GetVersion() MSPVersion

GetVersion returns the version of this MSP

func (*Idemixmsp) IsWellFormed

func (id *Idemixmsp) IsWellFormed(identity *m.SerializedIdentity) error

IsWellFormed checks if the given identity can be deserialized into its provider-specific . In this MSP implementation, an identity is considered well formed if it contains a marshaled SerializedIdemixIdentity protobuf message.

func (*Idemixmsp) SatisfiesPrincipal

func (msp *Idemixmsp) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal) error

func (*Idemixmsp) Setup

func (msp *Idemixmsp) Setup(conf1 *m.MSPConfig) error

func (*Idemixmsp) Validate

func (msp *Idemixmsp) Validate(id Identity) error

type Identity

type Identity interface {

	// ExpiresAt returns the time at which the Identity expires.
	// If the returned time is the zero value, it implies
	// the Identity does not expire, or that its expiration
	// time is unknown
	ExpiresAt() time.Time

	// GetIdentifier returns the identifier of that identity
	GetIdentifier() *IdentityIdentifier

	// GetMSPIdentifier returns the MSP Id for this instance
	GetMSPIdentifier() string

	// Validate uses the rules that govern this identity to validate it.
	// E.g., if it is a fabric TCert implemented as identity, validate
	// will check the TCert signature against the assumed root certificate
	// authority.
	Validate() error

	// GetOrganizationalUnits returns zero or more organization units or
	// divisions this identity is related to as long as this is public
	// information. Certain MSP implementations may use attributes
	// that are publicly associated to this identity, or the identifier of
	// the root certificate authority that has provided signatures on this
	// certificate.
	// Examples:
	//  - if the identity is an x.509 certificate, this function returns one
	//    or more string which is encoded in the Subject's Distinguished Name
	//    of the type OU
	// TODO: For X.509 based identities, check if we need a dedicated type
	//       for OU where the Certificate OU is properly namespaced by the
	//       signer's identity
	GetOrganizationalUnits() []*OUIdentifier

	// Anonymous returns true if this is an anonymous identity, false otherwise
	Anonymous() bool

	// Verify a signature over some message using this identity as reference
	Verify(msg []byte, sig []byte) error

	// Serialize converts an identity to bytes
	Serialize() ([]byte, error)

	// SatisfiesPrincipal checks whether this instance matches
	// the description supplied in MSPPrincipal. The check may
	// involve a byte-by-byte comparison (if the principal is
	// a serialized identity) or may require MSP validation
	SatisfiesPrincipal(principal *msp.MSPPrincipal) error
}

Identity interface defining operations associated to a "certificate". That is, the public part of the identity could be thought to be a certificate, and offers solely signature verification capabilities. This is to be used at the peer side when verifying certificates that transactions are signed with, and verifying signatures that correspond to these certificates.///

type IdentityDeserializer

type IdentityDeserializer interface {
	// DeserializeIdentity deserializes an identity.
	// Deserialization will fail if the identity is associated to
	// an msp that is different from this one that is performing
	// the deserialization.
	DeserializeIdentity(serializedIdentity []byte) (Identity, error)

	// IsWellFormed checks if the given identity can be deserialized into its provider-specific form
	IsWellFormed(identity *msp.SerializedIdentity) error
}

IdentityDeserializer is implemented by both MSPManger and MSP

type IdentityIdentifier

type IdentityIdentifier struct {

	// The identifier of the associated membership service provider
	Mspid string

	// The identifier for an identity within a provider
	Id string
}

IdentityIdentifier is a holder for the identifier of a specific identity, naturally namespaced, by its provider identifier.

type MSP

type MSP interface {

	// IdentityDeserializer interface needs to be implemented by MSP
	IdentityDeserializer

	// Setup the MSP instance according to configuration information
	Setup(config *msp.MSPConfig) error

	// GetVersion returns the version of this MSP
	GetVersion() MSPVersion

	// GetType returns the provider type
	GetType() ProviderType

	// GetIdentifier returns the provider identifier
	GetIdentifier() (string, error)

	// GetDefaultSigningIdentity returns the default signing identity
	GetDefaultSigningIdentity() (SigningIdentity, error)

	// GetTLSRootCerts returns the TLS root certificates for this MSP
	GetTLSRootCerts() [][]byte

	// GetTLSIntermediateCerts returns the TLS intermediate root certificates for this MSP
	GetTLSIntermediateCerts() [][]byte

	// Validate checks whether the supplied identity is valid
	Validate(id Identity) error

	// SatisfiesPrincipal checks whether the identity matches
	// the description supplied in MSPPrincipal. The check may
	// involve a byte-by-byte comparison (if the principal is
	// a serialized identity) or may require MSP validation
	SatisfiesPrincipal(id Identity, principal *msp.MSPPrincipal) error
}

MSP is the minimal Membership Service Provider Interface to be implemented to accommodate peer functionality

func NewIdemixMsp

func NewIdemixMsp(version MSPVersion) (MSP, error)

NewIdemixMsp creates a new instance of idemixmsp

type MSPManager

type MSPManager interface {

	// IdentityDeserializer interface needs to be implemented by MSPManager
	IdentityDeserializer

	// Setup the MSP manager instance according to configuration information
	Setup(msps []MSP) error

	// GetMSPs Provides a list of Membership Service providers
	GetMSPs() (map[string]MSP, error)
}

MSPManager is an interface defining a manager of one or more MSPs. This essentially acts as a mediator to MSP calls and routes MSP related calls to the appropriate MSP. This object is immutable, it is initialized once and never changed.

type MSPVersion

type MSPVersion int

type OUIdentifier

type OUIdentifier struct {
	// CertifiersIdentifier is the hash of certificates chain of trust
	// related to this organizational unit
	CertifiersIdentifier []byte
	// OrganizationUnitIdentifier defines the organizational unit under the
	// MSP identified with MSPIdentifier
	OrganizationalUnitIdentifier string
}

OUIdentifier represents an organizational unit and its related chain of trust identifier.

type ProviderType

type ProviderType int

ProviderType indicates the type of an identity provider

const (
	FABRIC ProviderType = iota // MSP is of FABRIC type
	IDEMIX                     // MSP is of IDEMIX type
	OTHER                      // MSP is of OTHER TYPE

)

The ProviderType of a member relative to the member API

type Role

type Role int32

Role : Represents a IdemixRole

const (
	MEMBER Role = 1
	ADMIN  Role = 2
	CLIENT Role = 4
	PEER   Role = 8
)

The expected roles are 4; We can combine them using a bitmask

type SigningIdentity

type SigningIdentity interface {

	// Extends Identity
	Identity

	// Sign the message
	Sign(msg []byte) ([]byte, error)

	// GetPublicVersion returns the public parts of this identity
	GetPublicVersion() Identity
}

SigningIdentity is an extension of Identity to cover signing capabilities. E.g., signing identity should be requested in the case of a client who wishes to sign transactions, or fabric endorser who wishes to sign proposal processing outcomes.

Directories

Path Synopsis
schemes/dlog/handlers/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
schemes/aries Module
types Module
common
flogging/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
tools

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL