Skip to content

Commit

Permalink
[FAB-10293] Make MSP protos conform to official style
Browse files Browse the repository at this point in the history
This change set makes the MSP protos conform to the official proto style

Change-Id: I766cc341833279fcd4149aeea124978145595fed
Signed-off-by: yacovm <[email protected]>
  • Loading branch information
yacovm committed May 22, 2018
1 parent 6528c9d commit 959811e
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 188 deletions.
2 changes: 1 addition & 1 deletion common/crypto/expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestIdemixIdentityExpiresAt(t *testing.T) {
idemixId := &msp.SerializedIdemixIdentity{
NymX: []byte{1, 2, 3},
NymY: []byte{1, 2, 3},
OU: []byte("OU1"),
Ou: []byte("OU1"),
}
idemixBytes, err := proto.Marshal(idemixId)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion core/handlers/auth/filter/expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func createIdemixIdentity(t *testing.T) []byte {
idemixId := &msp.SerializedIdemixIdentity{
NymX: []byte{1, 2, 3},
NymY: []byte{1, 2, 3},
OU: []byte("OU1"),
Ou: []byte("OU1"),
}
idemixBytes, err := proto.Marshal(idemixId)
assert.NoError(t, err)
Expand Down
12 changes: 6 additions & 6 deletions msp/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.M

nodeOUs = &msp.FabricNodeOUs{
Enable: configuration.NodeOUs.Enable,
ClientOUIdentifier: &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.ClientOUIdentifier.OrganizationalUnitIdentifier},
PeerOUIdentifier: &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.PeerOUIdentifier.OrganizationalUnitIdentifier},
ClientOuIdentifier: &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.ClientOUIdentifier.OrganizationalUnitIdentifier},
PeerOuIdentifier: &msp.FabricOUIdentifier{OrganizationalUnitIdentifier: configuration.NodeOUs.PeerOUIdentifier.OrganizationalUnitIdentifier},
}

// Read certificates, if defined
Expand All @@ -313,7 +313,7 @@ func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.M
if err != nil {
mspLogger.Infof("Failed loading ClientOU certificate at [%s]: [%s]", f, err)
} else {
nodeOUs.ClientOUIdentifier.Certificate = raw
nodeOUs.ClientOuIdentifier.Certificate = raw
}

// PeerOU
Expand All @@ -322,7 +322,7 @@ func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.M
if err != nil {
mspLogger.Debugf("Failed loading PeerOU certificate at [%s]: [%s]", f, err)
} else {
nodeOUs.PeerOUIdentifier.Certificate = raw
nodeOUs.PeerOuIdentifier.Certificate = raw
}
}
} else {
Expand All @@ -347,7 +347,7 @@ func getMspConfig(dir string, ID string, sigid *msp.SigningIdentityInfo) (*msp.M
CryptoConfig: cryptoConfig,
TlsRootCerts: tlsCACerts,
TlsIntermediateCerts: tlsIntermediateCerts,
FabricNodeOUs: nodeOUs,
FabricNodeOus: nodeOUs,
}

fmpsjs, _ := proto.Marshal(fmspconf)
Expand Down Expand Up @@ -379,7 +379,7 @@ func GetIdemixMspConfig(dir string, ID string) (*msp.MSPConfig, error) {

idemixConfig := &msp.IdemixMSPConfig{
Name: ID,
IPk: ipkBytes,
Ipk: ipkBytes,
RevocationPk: revocationPkBytes,
}

Expand Down
6 changes: 3 additions & 3 deletions msp/idemixmsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (msp *idemixmsp) Setup(conf1 *m.MSPConfig) error {
mspLogger.Debugf("Setting up Idemix MSP instance %s", msp.name)

ipk := new(idemix.IssuerPublicKey)
err = proto.Unmarshal(conf.IPk, ipk)
err = proto.Unmarshal(conf.Ipk, ipk)
if err != nil {
return errors.Wrap(err, "failed to unmarshal ipk from idemix msp config")
}
Expand Down Expand Up @@ -266,7 +266,7 @@ func (msp *idemixmsp) deserializeIdentityInternal(serializedID []byte) (Identity
Nym := FP256BN.NewECPbigs(FP256BN.FromBytes(serialized.NymX), FP256BN.FromBytes(serialized.NymY))

ou := &m.OrganizationUnit{}
err = proto.Unmarshal(serialized.OU, ou)
err = proto.Unmarshal(serialized.Ou, ou)
if err != nil {
return nil, errors.Wrap(err, "cannot deserialize the OU of the identity")
}
Expand Down Expand Up @@ -542,7 +542,7 @@ func (id *idemixidentity) Serialize() ([]byte, error) {
return nil, errors.Wrapf(err, "could not marshal role of identity %s", id.id)
}

serialized.OU = ouBytes
serialized.Ou = ouBytes
serialized.Role = roleBytes

serialized.Proof, err = proto.Marshal(id.associationProof)
Expand Down
4 changes: 2 additions & 2 deletions msp/idemixmsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestSetupBad(t *testing.T) {
assert.NoError(t, err)
ipkBytes, err := proto.Marshal(key.Ipk)
assert.NoError(t, err)
idemixconfig.IPk = ipkBytes
idemixconfig.Ipk = ipkBytes

idemixConfigBytes, err := proto.Marshal(idemixconfig)
assert.NoError(t, err)
Expand All @@ -109,7 +109,7 @@ func TestSetupBad(t *testing.T) {

// Create MSP config with bad IPK bytes
ipkBytes = []byte("barf")
idemixconfig.IPk = ipkBytes
idemixconfig.Ipk = ipkBytes

idemixConfigBytes, err = proto.Marshal(idemixconfig)
assert.NoError(t, err)
Expand Down
16 changes: 8 additions & 8 deletions msp/mspimplsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,24 @@ func (msp *bccspmsp) finalizeSetupCAs(config *m.FabricMSPConfig) error {
}

func (msp *bccspmsp) setupNodeOUs(config *m.FabricMSPConfig) error {
if config.FabricNodeOUs != nil {
if config.FabricNodeOus != nil {

msp.ouEnforcement = config.FabricNodeOUs.Enable
msp.ouEnforcement = config.FabricNodeOus.Enable

// ClientOU
msp.clientOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOUs.ClientOUIdentifier.OrganizationalUnitIdentifier}
if len(config.FabricNodeOUs.ClientOUIdentifier.Certificate) != 0 {
certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOUs.ClientOUIdentifier.Certificate)
msp.clientOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.ClientOuIdentifier.OrganizationalUnitIdentifier}
if len(config.FabricNodeOus.ClientOuIdentifier.Certificate) != 0 {
certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.ClientOuIdentifier.Certificate)
if err != nil {
return err
}
msp.clientOU.CertifiersIdentifier = certifiersIdentifier
}

// PeerOU
msp.peerOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOUs.PeerOUIdentifier.OrganizationalUnitIdentifier}
if len(config.FabricNodeOUs.PeerOUIdentifier.Certificate) != 0 {
certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOUs.PeerOUIdentifier.Certificate)
msp.peerOU = &OUIdentifier{OrganizationalUnitIdentifier: config.FabricNodeOus.PeerOuIdentifier.OrganizationalUnitIdentifier}
if len(config.FabricNodeOus.PeerOuIdentifier.Certificate) != 0 {
certifiersIdentifier, err := msp.getCertifiersIdentifier(config.FabricNodeOus.PeerOuIdentifier.Certificate)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion orderer/common/msgprocessor/expiration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func createIdemixIdentity(t *testing.T) []byte {
idemixId := &msp.SerializedIdemixIdentity{
NymX: []byte{1, 2, 3},
NymY: []byte{1, 2, 3},
OU: []byte("OU1"),
Ou: []byte("OU1"),
}
idemixBytes, err := proto.Marshal(idemixId)
assert.NoError(t, err)
Expand Down
56 changes: 28 additions & 28 deletions protos/msp/identities.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions protos/msp/identities.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,22 @@ message SerializedIdentity {
// The IdemixMSP will first serialize an idemix identity to bytes using
// this proto, and then uses these bytes as id_bytes in SerializedIdentity
message SerializedIdemixIdentity {
// NymX is the X-component of the pseudonym elliptic curve point.
// nym_x is the X-component of the pseudonym elliptic curve point.
// It is a []byte representation of an amcl.BIG
// The pseudonym can be seen as a public key of the identity, it is used to verify signatures.
bytes NymX = 1;
bytes nym_x = 1;

// NymY is the Y-component of the pseudonym elliptic curve point.
// nym_y is the Y-component of the pseudonym elliptic curve point.
// It is a []byte representation of an amcl.BIG
// The pseudonym can be seen as a public key of the identity, it is used to verify signatures.
bytes NymY = 2;
bytes nym_y = 2;

// OU contains the organizational unit of the idemix identity
bytes OU = 3;
// ou contains the organizational unit of the idemix identity
bytes ou = 3;

// Role contains the role of this identity (e.g., ADMIN or MEMBER)
bytes Role = 4;
// role contains the role of this identity (e.g., ADMIN or MEMBER)
bytes role = 4;

// Proof contains the cryptographic evidence that this identity is valid
bytes Proof = 5;
// proof contains the cryptographic evidence that this identity is valid
bytes proof = 5;
}
Loading

0 comments on commit 959811e

Please sign in to comment.