github.com/kaituanwang/hyperledger@v2.0.1+incompatible/docs/source/idemix.rst (about)

     1  MSP Implementation with Identity Mixer
     2  ======================================
     3  
     4  What is Idemix?
     5  ---------------
     6  
     7  Idemix is a cryptographic protocol suite, which provides strong authentication as
     8  well as privacy-preserving features such as **anonymity**, the ability to transact
     9  without revealing the identity of the transactor, and **unlinkability**, the
    10  ability of a single identity to send multiple transactions without revealing
    11  that the transactions were sent by the same identity.
    12  
    13  There are three actors involved in an Idemix flow: **user**, **issuer**, and
    14  **verifier**.
    15  
    16  .. image:: images/idemix-overview.png
    17  
    18  * An issuer certifies a set of user's attributes are issued in the form of a
    19    digital certificate, hereafter called "credential".
    20  * The user later generates a "`zero-knowledge proof <https://en.wikipedia.org/wiki/Zero-knowledge_proof>`_"
    21    of possession of the credential and also selectively discloses only the
    22    attributes the user chooses to reveal. The proof, because it is zero-knowledge,
    23    reveals no additional information to the verifier, issuer, or anyone else.
    24  
    25  As an example, suppose "Alice" needs to prove to Bob (a store clerk) that she has
    26  a driver's license issued to her by the DMV.
    27  
    28  In this scenario, Alice is the user, the DMV is the issuer, and Bob is the
    29  verifier. In order to prove to Bob that Alice has a driver's license, she could
    30  show it to him. However, Bob would then be able to see Alice's name, address,
    31  exact age, etc. --- much more information than Bob needs to know.
    32  
    33  Instead, Alice can use Idemix to generate a "zero-knowledge proof" for Bob, which
    34  only reveals that she has a valid driver's license and nothing else.
    35  
    36  So from the proof:
    37  
    38  * Bob does not learn any additional information about Alice other than the fact
    39    that she has a valid license (anonymity).
    40  * If Alice visits the store multiple times and generates a proof each time for Bob,
    41    Bob would not be able to tell from the proof that it was the same person
    42    (unlinkability).
    43  
    44  Idemix authentication technology provides the trust model and security
    45  guarantees that are similar to what is ensured by standard X.509 certificates but
    46  with underlying cryptographic algorithms that efficiently provide advanced
    47  privacy features including the ones described above. We'll compare Idemix and
    48  X.509 technologies in detail in the technical section below.
    49  
    50  How to use Idemix
    51  -----------------
    52  
    53  To understand how to use Idemix with Hyperledger Fabric, we need to see which
    54  Fabric components correspond to the user, issuer, and verifier in Idemix.
    55  
    56  * The Fabric Java SDK is the API for the **user**. In the future, other Fabric
    57    SDKs will also support Idemix.
    58  
    59  * Fabric provides two possible Idemix **issuers**:
    60  
    61     a) Fabric CA for production environments or development, and
    62     b) the :doc:`idemixgen <idemixgen>` tool for development environments.
    63  
    64  * The **verifier** is an Idemix MSP in Fabric.
    65  
    66  In order to use Idemix in Hyperledger Fabric, the following three basic steps
    67  are required:
    68  
    69  .. image:: images/idemix-three-steps.png
    70  
    71  *Compare the roles in this image to the ones above.*
    72  
    73  1. Consider the issuer.
    74  
    75     Fabric CA (version 1.3 or later) has been enhanced to automatically function
    76     as an Idemix issuer. When ``fabric-ca-server`` is started (or initialized via
    77     the ``fabric-ca-server init`` command), the following two files are
    78     automatically created in the home directory of the ``fabric-ca-server``:
    79     ``IssuerPublicKey`` and ``IssuerRevocationPublicKey``. These files are
    80     required in step 2.
    81  
    82     For a development environment and if you are not using Fabric CA, you may use
    83     ``idemixgen`` to create these files.
    84  
    85  2. Consider the verifier.
    86  
    87     You need to create an Idemix MSP using the ``IssuerPublicKey`` and
    88     ``IssuerRevocationPublicKey`` from step 1.
    89  
    90     For example, consider the following excerpt from
    91     `configtx.yaml in the Hyperledger Java SDK sample <https://github.com/hyperledger/fabric-sdk-java/blob/master/src/test/fixture/sdkintegration/e2e-2Orgs/v1.3/configtx.yaml>`_:
    92  
    93     .. code:: bash
    94  
    95        - &Org1Idemix
    96            # defaultorg defines the organization which is used in the sampleconfig
    97            # of the fabric.git development environment
    98            name: idemixMSP1
    99  
   100            # id to load the msp definition as
   101            id: idemixMSPID1
   102  
   103            msptype: idemix
   104            mspdir: crypto-config/peerOrganizations/org3.example.com
   105  
   106     The ``msptype`` is set to ``idemix`` and the contents of the ``mspdir``
   107     directory (``crypto-config/peerOrganizations/org3.example.com/msp`` in this
   108     example) contains the ``IssuerPublicKey`` and ``IssuerRevocationPublicKey``
   109     files.
   110  
   111     Note that in this example, ``Org1Idemix`` represents the Idemix MSP for ``Org1``
   112     (not shown), which would also have an X509 MSP.
   113  
   114  3. Consider the user. Recall that the Java SDK is the API for the user.
   115  
   116     There is only a single additional API call required in order to use Idemix
   117     with the Java SDK: the ``idemixEnroll`` method of the
   118     ``org.hyperledger.fabric_ca.sdk.HFCAClient`` class. For example, assume
   119     ``hfcaClient`` is your HFCAClient object and ``x509Enrollment`` is your
   120     ``org.hyperledger.fabric.sdk.Enrollment`` associated with your X509 certificate.
   121  
   122     The following call will return an ``org.hyperledger.fabric.sdk.Enrollment``
   123     object associated with your Idemix credential.
   124  
   125     .. code:: bash
   126  
   127        IdemixEnrollment idemixEnrollment = hfcaClient.idemixEnroll(x509enrollment, "idemixMSPID1");
   128  
   129     Note also that ``IdemixEnrollment`` implements the ``org.hyperledger.fabric.sdk.Enrollment``
   130     interface and can, therefore, be used in the same way that one uses the X509
   131     enrollment object, except, of course, that this automatically provides the
   132     privacy enhancing features of Idemix.
   133  
   134  Idemix and chaincode
   135  --------------------
   136  
   137  From a verifier perspective, there is one more actor to consider: chaincode.
   138  What can chaincode learn about the transactor when an Idemix credential is used?
   139  
   140  The `cid (Client Identity) library <https://godoc.org/github.com/hyperledger/fabric-chaincode-go/pkg/cid>`_
   141  (for golang only) has been extended to support the ``GetAttributeValue`` function
   142  when an Idemix credential is used. However, as mentioned in the "Current
   143  limitations" section below, there are only two attributes which are disclosed in
   144  the Idemix case: ``ou`` and ``role``.
   145  
   146  If Fabric CA is the credential issuer:
   147  
   148  * the value of the `ou` attribute is the identity's **affiliation** (e.g.
   149    "org1.department1");
   150  * the value of the ``role`` attribute will be either 'member' or 'admin'. A
   151    value of 'admin' means that the identity is an MSP administrator. By default,
   152    identities created by Fabric CA will return the 'member' role. In order to
   153    create an 'admin' identity, register the identity with the ``role`` attribute
   154    and a value of ``2``.
   155  
   156  For an example of setting an affiliation in the Java SDK see this `sample <https://github.com/hyperledger/fabric-sdk-java/blob/master/src/test/java/org/hyperledger/fabric/sdkintegration/End2endIdemixIT.java#L121>`_.
   157  
   158  For an example of using the CID library in go chaincode to retrieve attributes,
   159  see this `go chaincode <https://github.com/hyperledger/fabric-sdk-java/blob/master/src/test/fixture/sdkintegration/gocc/sampleIdemix/src/github.com/example_cc/example_cc.go#L88>`_.
   160  
   161  Idemix organizations cannot be used to endorse a chaincode or approve a chaincode
   162  definition. This needs to be taken into account when you set the
   163  LifecycleEndorsement and Endorsement policies on your channels. For more
   164  information, see the limitations section below.
   165  
   166  Current limitations
   167  -------------------
   168  
   169  The current version of Idemix does have a few limitations.
   170  
   171  * **Idemix organizations and endorsement policies**
   172  
   173    Idemix organizations cannot be used to endorse a chaincode transaction or
   174    approve a chaincode definition. By default, the
   175    ``Channel/Application/LifecycleEndorsement`` and
   176    ``Channel/Application/Endorsement`` policies will require signatures from a
   177    majority of organizations active on the channel. This implies that a channel
   178    that contains a large number of Idemix organizations may not be able to
   179    reach the majority needed to fulfill the default policy. For example, if a
   180    channel has two MSP Organizations and two Idemix organizations, the channel
   181    policy will require that three out of four organizations approve a chaincode
   182    definition to commit that definition to the channel. Because Idemix
   183    organizations cannot approve a chaincode definition, the policy will only be
   184    able to validate two out of four signatures.
   185  
   186    If your channel contains a sufficient number of Idemix organizations to affect
   187    the endorsement policy, you can use a signature policy to explicitly specify
   188    the required MSP organizations.
   189  
   190  * **Fixed set of attributes**
   191  
   192    It not yet possible to issue or use an Idemix credential with custom attributes.
   193    Custom attributes will be supported in a future release.
   194  
   195    The following four attributes are currently supported:
   196  
   197    1. Organizational Unit attribute ("ou"):
   198  
   199     - Usage: same as X.509
   200     - Type: String
   201     - Revealed: always
   202  
   203    2. Role attribute ("role"):
   204  
   205     - Usage: same as X.509
   206     - Type: integer
   207     - Revealed: always
   208  
   209    3. Enrollment ID attribute
   210  
   211     - Usage: uniquely identify a user --- same in all enrollment credentials that
   212       belong to the same user (will be used for auditing in the future releases)
   213     - Type: BIG
   214     - Revealed: never in the signature, only when generating an authentication token for Fabric CA
   215  
   216    4. Revocation Handle attribute
   217  
   218     - Usage: uniquely identify a credential (will be used for revocation in future releases)
   219     - Type: integer
   220     - Revealed: never
   221  
   222  * **Revocation is not yet supported**
   223  
   224     Although much of the revocation framework is in place as can be seen by the
   225     presence of a revocation handle attribute mentioned above, revocation of an
   226     Idemix credential is not yet supported.
   227  
   228  * **Peers do not use Idemix for endorsement**
   229  
   230     Currently, Idemix MSP is used by the peers only for signature verification.
   231     Signing with Idemix is only done via Client SDK. More roles (including a
   232     'peer' role) will be supported by Idemix MSP.
   233  
   234  Technical summary
   235  -----------------
   236  
   237  Comparing Idemix credentials to X.509 certificates
   238  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   239  
   240  The certificate/credential concept and the issuance process are very similar in
   241  Idemix and X.509 certs: a set of attributes is digitally signed with a signature
   242  that cannot be forged and there is a secret key to which a credential is
   243  cryptographically bound.
   244  
   245  The main difference between a standard X.509 certificate and an Identity Mixer
   246  credential is the signature scheme that is used to certify the attributes. The
   247  signatures underlying the Identity Mixer system allow for efficient proofs of the
   248  possession of a signature and the corresponding attributes without revealing the
   249  signature and (selected) attribute values themselves. We use zero-knowledge proofs
   250  to ensure that such "knowledge" or "information" is not revealed while ensuring
   251  that the signature over some attributes is valid and the user is in possession
   252  of the corresponding credential secret key.
   253  
   254  Such proofs, like X.509 certificates, can be verified with the public key of
   255  the authority that originally signed the credential and cannot be successfully
   256  forged. Only the user who knows the credential secret key can generate the proofs
   257  about the credential and its attributes.
   258  
   259  With regard to unlinkability, when an X.509 certificate is presented, all attributes
   260  have to be revealed to verify the certificate signature. This implies that all
   261  certificate usages for signing transactions are linkable.
   262  
   263  To avoid such linkability, fresh X.509 certificates need to be used every time,
   264  which results in complex key management and communication and storage overhead.
   265  Furthermore, there are cases where it is important that not even the CA issuing
   266  the certificates is able to link all the transactions to the user.
   267  
   268  Idemix helps to avoid linkability with respect to both the CA and verifiers,
   269  since even the CA is not able to link proofs to the original credential. Neither
   270  the issuer nor a verifier can tell whether two proofs were derived from the same
   271  credential (or from two different ones).
   272  
   273  More details on the concepts and features of the Identity Mixer technology are
   274  described in the paper `Concepts and Languages for Privacy-Preserving Attribute-Based Authentication <https://link.springer.com/chapter/10.1007%2F978-3-642-37282-7_4>`_.
   275  
   276  Topology Information
   277  ~~~~~~~~~~~~~~~~~~~~
   278  
   279  Given the above limitations, it is recommended to have only one Idemix-based MSP
   280  per channel or, at the extreme, per network. Indeed, for example, having multiple Idemix-based MSPs
   281  per channel would allow a party, reading the ledger of that channel, to tell apart
   282  transactions signed by parties belonging to different Idemix-based MSPs. This is because,
   283  each transaction leak the MSP-ID of the signer.
   284  In other words, Idemix currently provides only anonymity of clients among the same organization (MSP).
   285  
   286  In the future, Idemix could be extended to support anonymous hierarchies of Idemix-based
   287  Certification Authorities whose certified credentials can be verified by using a unique public-key,
   288  therefore achieving anonymity across organizations (MSPs).
   289  This would allow multiple Idemix-based MSPs to coexist in the same channel.
   290  
   291  In principal, a channel can be configured to have a single Idemix-based MSP and multiple
   292  X.509-based MSPs. Of course, the interaction between these MSP can potential
   293  leak information. An assessment of the leaked information need to be done case by case.wq
   294  
   295  Underlying cryptographic protocols
   296  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   297  
   298  Idemix technology is built from a blind signature scheme that supports multiple
   299  messages and efficient zero-knowledge proofs of signature possession. All of the
   300  cryptographic building blocks for Idemix were published at the top conferences
   301  and journals and verified by the scientific community.
   302  
   303  This particular Idemix implementation for Fabric uses a pairing-based
   304  signature scheme that was briefly proposed by `Camenisch and Lysyanskaya <https://link.springer.com/chapter/10.1007/978-3-540-28628-8_4>`_
   305  and described in detail by `Au et al. <https://link.springer.com/chapter/10.1007/11832072_8>`_.
   306  The ability to prove knowledge of a signature in a zero-knowledge proof
   307  `Camenisch et al. <https://eprint.iacr.org/2016/663.pdf>`_ was used.
   308  
   309  .. Licensed under Creative Commons Attribution 4.0 International License
   310     https://creativecommons.org/licenses/by/4.0/