Commit f2c8b1ee authored by Binh Nguyen's avatar Binh Nguyen Committed by Gerrit Code Review
Browse files

Merge "FAB-10303 Clean up some assorted struct init"

parents b031d69c e6ba576a
......@@ -92,12 +92,12 @@ func GenerateSignerConfig(isAdmin bool, ouString string, enrollmentId string, re
}
signer := &m.IdemixMSPSignerConfig{
credBytes,
idemix.BigToBytes(sk),
ouString,
isAdmin,
enrollmentId,
criBytes,
Cred: credBytes,
Sk: idemix.BigToBytes(sk),
OrganizationalUnitIdentifier: ouString,
IsAdmin: isAdmin,
EnrollmentId: enrollmentId,
CredentialRevocationInformation: criBytes,
}
return proto.Marshal(signer)
......
......@@ -39,7 +39,7 @@ func TestIdemixCa(t *testing.T) {
writeVerifierToFile(ipkBytes, elliptic.Marshal(elliptic.P384(), revocationkey.X, revocationkey.Y))
key := &idemix.IssuerKey{isk, ipk}
key := &idemix.IssuerKey{Isk: isk, Ipk: ipk}
conf, err := GenerateSignerConfig(false, "OU1", "enrollmentid1", 1, key, revocationkey)
assert.NoError(t, err)
......
......@@ -123,7 +123,7 @@ func readIssuerKey() *idemix.IssuerKey {
}
ipk := &idemix.IssuerPublicKey{}
handleError(proto.Unmarshal(ipkBytes, ipk))
key := &idemix.IssuerKey{isk, ipk}
key := &idemix.IssuerKey{Isk: isk, Ipk: ipk}
return key
}
......
......@@ -56,7 +56,7 @@ func TestCollectionStore(t *testing.T) {
assert.Error(t, err)
cc := &common.CollectionConfig{Payload: &common.CollectionConfig_StaticCollectionConfig{&common.StaticCollectionConfig{Name: "mycollection"}}}
ccp := &common.CollectionConfigPackage{[]*common.CollectionConfig{cc}}
ccp := &common.CollectionConfigPackage{Config: []*common.CollectionConfig{cc}}
ccpBytes, err := proto.Marshal(ccp)
assert.NoError(t, err)
assert.NotNil(t, ccpBytes)
......
......@@ -31,9 +31,9 @@ func (colls *Collections) getOrCreateKeysAndHashes(coll string) *KeysAndHashes {
}
func newPvtdataKeys() *PvtdataKeys {
return &PvtdataKeys{make(map[string]*Collections)}
return &PvtdataKeys{Map: make(map[string]*Collections)}
}
func newCollections() *Collections {
return &Collections{make(map[string]*KeysAndHashes)}
return &Collections{Map: make(map[string]*KeysAndHashes)}
}
......@@ -7,11 +7,11 @@ SPDX-License-Identifier: Apache-2.0
package pvtdatastorage
func newExpiryData() *ExpiryData {
return &ExpiryData{make(map[string]*Collections)}
return &ExpiryData{Map: make(map[string]*Collections)}
}
func newCollections() *Collections {
return &Collections{make(map[string]*TxNums)}
return &Collections{Map: make(map[string]*TxNums)}
}
func (e *ExpiryData) add(ns, coll string, txNum uint64) {
......
......@@ -74,11 +74,11 @@ func NewCredential(key *IssuerKey, m *CredRequest, attrs []*FP256BN.BIG, rng *am
}
return &Credential{
EcpToProto(A),
EcpToProto(B),
BigToBytes(E),
BigToBytes(S),
CredAttrs}, nil
A: EcpToProto(A),
B: EcpToProto(B),
E: BigToBytes(E),
S: BigToBytes(S),
Attrs: CredAttrs}, nil
}
// Ver cryptographically verifies the credential by verifying the signature
......
......@@ -56,7 +56,11 @@ func NewCredRequest(sk *FP256BN.BIG, IssuerNonce *FP256BN.BIG, ipk *IssuerPublic
proofC := HashModOrder(proofData)
proofS := Modadd(FP256BN.Modmul(proofC, sk, GroupOrder), rSk, GroupOrder)
return &CredRequest{EcpToProto(Nym), BigToBytes(IssuerNonce), BigToBytes(proofC), BigToBytes(proofS)}
return &CredRequest{
Nym: EcpToProto(Nym),
IssuerNonce: BigToBytes(IssuerNonce),
ProofC: BigToBytes(proofC),
ProofS: BigToBytes(proofS)}
}
// Check cryptographically verifies the credential request
......
......@@ -63,10 +63,10 @@ func NewNymSignature(sk *FP256BN.BIG, Nym *FP256BN.ECP, RNym *FP256BN.BIG, ipk *
// The signature consists of the Fiat-Shamir hash (ProofC), the s-values (ProofSSk, ProofSRNym), and the nonce.
return &NymSignature{
BigToBytes(ProofC),
BigToBytes(ProofSSk),
BigToBytes(ProofSRNym),
BigToBytes(Nonce)}, nil
ProofC: BigToBytes(ProofC),
ProofSSk: BigToBytes(ProofSSk),
ProofSRNym: BigToBytes(ProofSRNym),
Nonce: BigToBytes(Nonce)}, nil
}
// Ver verifies an idemix NymSignature
......
......@@ -172,23 +172,23 @@ func NewSignature(cred *Credential, sk *FP256BN.BIG, Nym *FP256BN.ECP, RNym *FP2
}
return &Signature{
EcpToProto(APrime),
EcpToProto(ABar),
EcpToProto(BPrime),
BigToBytes(ProofC),
BigToBytes(ProofSSk),
BigToBytes(ProofSE),
BigToBytes(ProofSR2),
BigToBytes(ProofSR3),
BigToBytes(ProofSSPrime),
ProofSAttrs,
BigToBytes(Nonce),
EcpToProto(Nym),
BigToBytes(ProofSRNym),
cri.EpochPk,
cri.EpochPkSig,
cri.Epoch,
nonRevokedProof},
APrime: EcpToProto(APrime),
ABar: EcpToProto(ABar),
BPrime: EcpToProto(BPrime),
ProofC: BigToBytes(ProofC),
ProofSSk: BigToBytes(ProofSSk),
ProofSE: BigToBytes(ProofSE),
ProofSR2: BigToBytes(ProofSR2),
ProofSR3: BigToBytes(ProofSR3),
ProofSSPrime: BigToBytes(ProofSSPrime),
ProofSAttrs: ProofSAttrs,
Nonce: BigToBytes(Nonce),
Nym: EcpToProto(Nym),
ProofSRNym: BigToBytes(ProofSRNym),
RevocationEpochPk: cri.EpochPk,
RevocationPkSig: cri.EpochPkSig,
Epoch: cri.Epoch,
NonRevocationProof: nonRevokedProof},
nil
}
......
......@@ -93,8 +93,8 @@ func BigToBytes(big *FP256BN.BIG) []byte {
// EcpToProto converts a *amcl.ECP into the proto struct *ECP
func EcpToProto(p *FP256BN.ECP) *ECP {
return &ECP{
BigToBytes(p.GetX()),
BigToBytes(p.GetY())}
X: BigToBytes(p.GetX()),
Y: BigToBytes(p.GetY())}
}
// EcpFromProto converts a proto struct *ECP into an *amcl.ECP
......@@ -105,10 +105,10 @@ func EcpFromProto(p *ECP) *FP256BN.ECP {
// Ecp2ToProto converts a *amcl.ECP2 into the proto struct *ECP2
func Ecp2ToProto(p *FP256BN.ECP2) *ECP2 {
return &ECP2{
BigToBytes(p.GetX().GetA()),
BigToBytes(p.GetX().GetB()),
BigToBytes(p.GetY().GetA()),
BigToBytes(p.GetY().GetB())}
Xa: BigToBytes(p.GetX().GetA()),
Xb: BigToBytes(p.GetX().GetB()),
Ya: BigToBytes(p.GetY().GetA()),
Yb: BigToBytes(p.GetY().GetB())}
}
// Ecp2FromProto converts a proto struct *ECP2 into an *amcl.ECP2
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment