Anonymous Credentials
A zero knowledge proof signature algorithm
The anonymous credential scheme is a part of the Ontology Crypto library that provides several cryptography related utilities for the Ontology network. The main features provided by the crypto library basically revolve around digital signature. It provides general APIs for processing digital signatures and keys.
Abstract
There are three parties involved in an anonymous credential scheme, namely the issuer, the user (prover), and the verifier.
The issuer provides a certificate to the user. This certificate contains a list of the user's attributes and the issuer's signature (using BBS+signature). This protocol is formally called credential issuance protocol. The user who is in possession of the credentials can selectively disclose some parts to a verifier. This protocol is formally called credential presentation protocol.
Background
BBS + Signature
Setup: Groups G1,G2 and Gt . Pairing function e:G1∗G2→Gt , where G1 and G2 are both of order p. Common parameters:
g1 is the generator of G1
g2 is the generator of G2
Hrand ,h1,... ,hL are elements from G1
KeyGen: A sample x from uniform distribution on Zp, output sk=x , pk=g2x
Sign(sk,m1,... ,mL): Two random numbers E and sare selected from Zp. FirstB=g1∗HRands∗(h1m1∗...∗hLmL) is calculated, and then A=B1/(E+x) is computed. The signature is (A,B,E,s)
Verify (pk,m1,... ,mL,sig): Decode sig as (A,B,E,s) , and check if e(A,g2E∗pk)==e(B,g2) and whether B==g1∗HRands∗(h1m1∗...∗hLmL)
Non-Interactive Proof of Knowledge (PoK) protocol
In this subsection, we will look at an example of the non-interactive proof of knowledge protocol which proves that the public key is generated as specified in the BBS + signature scheme. That is, π=PoK{x:w=g2x && _g2=_g1x}. This means the prover proves the knowledge of x such that g2x=w and _g2=_g1x. It is assumed that w,g2,_g1,_g2 are all public.
The protocol that we provide is a standard sigma protocol. It involves three steps, which are commit, challenge, and response. Sigma protocol is an interactive protocol and can be modified to be a non-interactive zero knowledge proof by using the well-known Fiat-Shamir heuristic. The proof π={C,S}.
1. Commitment (Prover)
2. Proof (Prover)
3. Verify (Verifier)
Setup of the Issuer's key pair
Given an array of the attribute names AttributeNames, the issuer's key pair is generated in the following manner:
Select a random element x from Zp, and compute w=g2x
Select a random element _g1from G1, and compute _g2=_g1x
Generate non-interactive proof of knowledge π=PoK{x:w=g2x && _g1x}=(C,S) Here,
r: A random element r from Zpt1: Computed as t1=g2rt2: Computed as t2=_g1rC: C=H(t1∣∣t2∣∣g2∣∣_g1∣∣w∣∣_g2)s: S=(r+C∗x)modp
4. Select an array of elements from G1 from AttributeNames. Next, calculate HAttrs[i] = random(G1) for each attribute in AttributeNames
5. Select two random elements HRand And HSk from G1
6. The issuer's public key is set to ipk = (w, _g1, _g2, π, HAttrs, AttributeNames, HRand, HSk), and the private key is set to isk = x
7. Return isk and ipk
The following are the reference data structures for the issuer's key pair:
Issuance Protocol
Issuance protocol is an interactive protocol that consists of the following steps:
The issuer sends a random nonce to the user
The user creates a credential request using the public key, the secret, and the nonce. This request consists of a commitment to the user secret (can be seen as a public key), and a zero-knowledge proof of the knowledge of the user secret key. The user sends this credential request to the issuer
The issuer verifies the credential request by verifying the zero-knowledge proof If the request is valid, the issuer issues a credential to the user by signing the commitment to the secret key along with the attribute values and then sends the credential back to the user
The user verifies the issuer's signature and stores the credential that consists of the signature value, a randomness used to create the signature, the user secret, and the attribute values
The following diagram represents the interaction between the user and the issuer:

The credential request CredRequest contains a commitment Nym to user's secret key which is of the form HSksk and a
zk-PoKof the NymCredential contains the
BBS+signatureon the attributes and theNym
Generating credential request
The user generates the credential request using the attribute values and the nonce as input. The process is as follows:
Select a random element sk from Zp as the user's master secret key
Calculate Nym=HSksk , which represents the commitment to the user's master secret
Generate the zero knowledge proof π=PoK{sk:Nym=HSksk}=(C,S) in the following manner-
Select a random element sk from Zp which acts as the user's master secret
Calculate t1=HSkr
Compute the challenge C=H(t1∣∣HSk∣∣Nym∣∣nonce)
Compute the response S=(r+C∗sk)modp
The data structure of the credential request is of the following manner:
Issuing Credential
After receiving the credential request from the user, the issuer verifies π=(C,S) and generates credentials for the user. The credential is generated using the issuer's private key isk as follows:
Select two random elements e,s from Zp
Calculate
B = g1 · HRand^s · Nym · MulAll(HAttrs[i]^(Attrs[i]))Compute
A = B^(1/(e+x))Return the credential (A,B,e,s,Attrs)
The data structure of a credential looks something like:
Presentation Protocol
In the presentation protocol, the prover tries to convince the verifier that they are aware of some secret input, such that some hypothetical predicate is true. A typical example of a predicate is that the prover is in possession of an anonymous credential, and they can selectively disclose certain attributes while hiding the other attributes.
The information that is available to the user is:
User's secret key sk and its commitment Nym
Attribute values attrs=(a1,... ,aL)
BBS +signature
(A, B, e, s)Extra input
(D, I) : Attribute predicate, describes what attributes will be disclosed. If
D[j] == 1,I[j] = attrs[j] = aj, elseI[j] = null
Proving Algorithm
The selective disclosure proof can be generated in the following manner:
Randomize A : Select a random element r1 from Zp∗, and compute A′=Ar1
Calculate _A=A′(−e) ⋅Br1, r3=1/r1
Select an element r2 from Zp
Calculate B′=Br1⋅HRand−r2 , s′=s−r2⋅r3
Generate zero knowledge proof π=PoK{(sk,ai_hidden,e,r2,r3,s′)} such that-
_A/B' = A'^(-e) · HRand^r2g1 · MulAll(hi^ai_reveal) = (B')^r3 · HRand^(-s') · HSk^(-sk) ·MulAll(hi^(-ai_hidden)), wherehistands forHAttrs[i]
The proof can be generated as follows:
The output is (A′,_A,d,nym,π) where π={c,ssk,sai,se,sr2,sr3,ss′,nonce}
Here is the reference data structure for the zero knowledge proof:
Verification
The verifier has the following input information available:
(A′,_A,B′,nym,π) : from the signer
{c,ssk,sai,se,sr2,sr3,ss′,nonce} : obtained by parsing π
The verification algorithm proceeds as in the following manner:
Check if
A' != 1in G1; if false, returnfalse.Check if
e(A', w) == e(_A, g2); if false, returnfalse. This is zk−PoK for A.Parse π :
{c, s_sk, {s_ai}, s_e, s_r2, s_r3, s_s', nonce} <- π; if failed, returnfalse.~ t1 :
~t1 = A'^s_e · HRand^s_r2 · (_A/B')^(-c). This is zk−PoK for e, r2.~ t2 :
(B')^s_r3 · HRand^s_s' · HSk^(-s_sk) · MulAll(hi^(-s_ai)) · (g1·MulAll(hi^ai))^(-c)the
iabove, firstMulAll( )belongs to_D, whereD[i]==0(false)the
iabove, secondMulAll( )belongs toD, whereD[i]==1(true)
This is Zk−PoK for r3, s', gsk, ai of _D.
c′ :
c' = H(nonce, H(A', _A, B', nym, ~t1, ~t2, g1, HRand, h1, ... , hL, w), (D, I))Check if
c == c': if false, returnfalse. Otherwise returntrue.
Last updated