Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New keyshare protocol #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.test
.idea/
vendor/
.DS_Store
32 changes: 25 additions & 7 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import (
// IssueCommitmentMessage encapsulates the messages sent by the receiver to the
// issuer in the second step of the issuance protocol.
type IssueCommitmentMessage struct {
U *big.Int `json:"U,omitempty"`
Nonce2 *big.Int `json:"n_2"`
Proofs ProofList `json:"combinedProofs"`
ProofPjwt string `json:"proofPJwt,omitempty"`
ProofPjwts map[string]string `json:"proofPJwts,omitempty"`
U *big.Int `json:"U,omitempty"`
Nonce2 *big.Int `json:"n_2"`
Proofs ProofList `json:"combinedProofs"`
ProofPjwt string `json:"proofPJwt,omitempty"`
ProofPjwts map[string]string `json:"proofPJwts,omitempty"`
KeyshareWs map[string]*big.Int `json:"keyshareWs,omitempty"`
KeyshareContribution string `json:"keyshareContribution,omitempty"`
}

// UnmarshalJSON implements json.Unmarshaler (json's default unmarshaler
Expand Down Expand Up @@ -188,7 +190,7 @@ func (b *CredentialBuilder) ConstructCredential(msg *IssueSignatureMessage, attr
func (b *CredentialBuilder) proveCommitment(nonce1 *big.Int) Proof {
sCommit, _ := common.RandomBigInt(b.pk.Params.LsCommit)
contrib := b.Commit(map[string]*big.Int{"secretkey": sCommit})
c := createChallenge(b.context, nonce1, contrib, false)
c := createChallenge(b.context, nonce1, contrib, nil, false)
return b.CreateProof(c)
}

Expand All @@ -210,6 +212,8 @@ type CredentialBuilder struct {

mUser map[int]*big.Int // Map of users shares of random blind attributes
mUserCommit map[int]*big.Int

newStyleKeyshareSession bool
}

func (b *CredentialBuilder) MergeProofPCommitment(commitment *ProofPCommitment) {
Expand All @@ -220,6 +224,11 @@ func (b *CredentialBuilder) MergeProofPCommitment(commitment *ProofPCommitment)
)
}

func (b *CredentialBuilder) MergeKeyshareP(keyshareP *big.Int) {
b.proofPcomm = &ProofPCommitment{P: new(big.Int).Set(keyshareP)}
b.newStyleKeyshareSession = true
}

// PublicKey returns the Idemix public key against which the credential will verify.
func (b *CredentialBuilder) PublicKey() *PublicKey {
return b.pk
Expand Down Expand Up @@ -265,8 +274,17 @@ func (b *CredentialBuilder) CreateProof(challenge *big.Int) Proof {
mUserResponses[i] = new(big.Int).Add(b.mUserCommit[i], new(big.Int).Mul(challenge, miUser))
}

var U *big.Int
if b.newStyleKeyshareSession {
U = new(big.Int).Mul(b.u, b.proofPcomm.P)
U.Mod(U, b.pk.N)
} else {
// U can be modified in the proof, so make sure this is a copy
U = new(big.Int).Set(b.u)
}

return &ProofU{
U: b.u,
U: U,
C: challenge,
VPrimeResponse: vPrimeResponse,
SResponse: sResponse,
Expand Down
6 changes: 5 additions & 1 deletion credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (ic *Credential) CreateDisclosureProof(disclosedAttributes []int, nonrev bo
if err != nil {
return nil, err
}
challenge := ProofBuilderList{builder}.Challenge(context, nonce1, false)
challenge := ProofBuilderList{builder}.Challenge(context, nonce1, nil, false)
return builder.CreateProof(challenge).(*ProofD), nil
}

Expand Down Expand Up @@ -224,6 +224,10 @@ func (d *DisclosureProofBuilder) MergeProofPCommitment(commitment *ProofPCommitm
)
}

func (d *DisclosureProofBuilder) MergeKeyshareP(keyshareP *big.Int) {
//nop
}

// PublicKey returns the Idemix public key against which this disclosure proof will verify.
func (d *DisclosureProofBuilder) PublicKey() *PublicKey {
return d.pk
Expand Down
Loading