From 5f6a232d61a8df730e49fa8b1f6cc58cb7ee739e Mon Sep 17 00:00:00 2001 From: Alessandro Sorniotti Date: Thu, 1 Jun 2017 19:32:54 +0200 Subject: [PATCH] [FAB-3708] cleanup unused/unimplemented msp code This change set removes a few unused structs/types. Change-Id: I65ca1cf56dc1a1348e44cec08a15fe3833e4631f Signed-off-by: Alessandro Sorniotti --- common/cauthdsl/cauthdsl_test.go | 8 ---- common/mocks/msp/noopmsp.go | 20 ---------- core/policy/mocks/mocks.go | 8 ---- msp/identities.go | 25 ------------- msp/msp.go | 63 -------------------------------- msp/msp_test.go | 20 ---------- peer/gossip/mocks/mocks.go | 8 ---- 7 files changed, 152 deletions(-) diff --git a/common/cauthdsl/cauthdsl_test.go b/common/cauthdsl/cauthdsl_test.go index 7c500f497ad..ad7ecf3cfed 100644 --- a/common/cauthdsl/cauthdsl_test.go +++ b/common/cauthdsl/cauthdsl_test.go @@ -66,14 +66,6 @@ func (id *mockIdentity) Verify(msg []byte, sig []byte) error { } } -func (id *mockIdentity) VerifyOpts(msg []byte, sig []byte, opts msp.SignatureOpts) error { - return nil -} - -func (id *mockIdentity) VerifyAttributes(proof []byte, spec *msp.AttributeProofSpec) error { - return nil -} - func (id *mockIdentity) Serialize() ([]byte, error) { return id.idBytes, nil } diff --git a/common/mocks/msp/noopmsp.go b/common/mocks/msp/noopmsp.go index 673f61181f2..0c024a56a89 100644 --- a/common/mocks/msp/noopmsp.go +++ b/common/mocks/msp/noopmsp.go @@ -105,14 +105,6 @@ func (id *noopidentity) Verify(msg []byte, sig []byte) error { return nil } -func (id *noopidentity) VerifyOpts(msg []byte, sig []byte, opts m.SignatureOpts) error { - return nil -} - -func (id *noopidentity) VerifyAttributes(proof []byte, spec *m.AttributeProofSpec) error { - return nil -} - func (id *noopidentity) Serialize() ([]byte, error) { return []byte("cert"), nil } @@ -129,18 +121,6 @@ func (id *noopsigningidentity) Sign(msg []byte) ([]byte, error) { return []byte("signature"), nil } -func (id *noopsigningidentity) SignOpts(msg []byte, opts m.SignatureOpts) ([]byte, error) { - return nil, nil -} - -func (id *noopsigningidentity) GetAttributeProof(spec *m.AttributeProofSpec) (proof []byte, err error) { - return nil, nil -} - func (id *noopsigningidentity) GetPublicVersion() m.Identity { return id } - -func (id *noopsigningidentity) Renew() error { - return nil -} diff --git a/core/policy/mocks/mocks.go b/core/policy/mocks/mocks.go index 9b9383f2f67..6841cc04ed3 100644 --- a/core/policy/mocks/mocks.go +++ b/core/policy/mocks/mocks.go @@ -127,14 +127,6 @@ func (id *MockIdentity) Verify(msg []byte, sig []byte) error { return errors.New("Invalid Signature") } -func (id *MockIdentity) VerifyOpts(msg []byte, sig []byte, opts msp.SignatureOpts) error { - return nil -} - -func (id *MockIdentity) VerifyAttributes(proof []byte, spec *msp.AttributeProofSpec) error { - return nil -} - func (id *MockIdentity) Serialize() ([]byte, error) { return []byte("cert"), nil } diff --git a/msp/identities.go b/msp/identities.go index 1552e6ad080..dd11f49baa6 100644 --- a/msp/identities.go +++ b/msp/identities.go @@ -150,16 +150,6 @@ func (id *identity) Verify(msg []byte, sig []byte) error { return nil } -func (id *identity) VerifyOpts(msg []byte, sig []byte, opts SignatureOpts) error { - // TODO - return errors.New("This method is unimplemented") -} - -func (id *identity) VerifyAttributes(proof []byte, spec *AttributeProofSpec) error { - // TODO - return errors.New("This method is unimplemented") -} - // Serialize returns a byte array representation of this identity func (id *identity) Serialize() ([]byte, error) { // mspIdentityLogger.Infof("Serializing identity %s", id.id) @@ -233,21 +223,6 @@ func (id *signingidentity) Sign(msg []byte) ([]byte, error) { return id.signer.Sign(rand.Reader, digest, nil) } -func (id *signingidentity) SignOpts(msg []byte, opts SignatureOpts) ([]byte, error) { - // TODO - return nil, errors.New("This method is unimplemented") -} - -func (id *signingidentity) GetAttributeProof(spec *AttributeProofSpec) (proof []byte, err error) { - // TODO - return nil, errors.New("This method is unimplemented") -} - func (id *signingidentity) GetPublicVersion() Identity { return &id.identity } - -func (id *signingidentity) Renew() error { - // TODO - return errors.New("This method is unimplemented") -} diff --git a/msp/msp.go b/msp/msp.go index 5a16456e9a6..9d7d24b3d65 100644 --- a/msp/msp.go +++ b/msp/msp.go @@ -153,12 +153,6 @@ type Identity interface { // Verify a signature over some message using this identity as reference Verify(msg []byte, sig []byte) error - // VerifyOpts a signature over some message using this identity as reference - VerifyOpts(msg []byte, sig []byte, opts SignatureOpts) error - - // VerifyAttributes verifies attributes given a proof - VerifyAttributes(proof []byte, spec *AttributeProofSpec) error - // Serialize converts an identity to bytes Serialize() ([]byte, error) @@ -181,67 +175,10 @@ type SigningIdentity interface { // Sign the message Sign(msg []byte) ([]byte, error) - // SignOpts the message with options - SignOpts(msg []byte, opts SignatureOpts) ([]byte, error) - - // GetAttributeProof creates a proof for a set of attributes - GetAttributeProof(spec *AttributeProofSpec) (proof []byte, err error) - // GetPublicVersion returns the public parts of this identity GetPublicVersion() Identity - - // Renew this identity - Renew() error -} - -// ImportRequest is data required when importing a member or -// enrollment identity that was created off-band -type ImportRequest struct { - - // IdentityProvider to enroll with - Idp string - - // The certificate to import - IdentityDesc []byte - - // Key reference associated to the key of the imported member - KeyReference []string } -// SignatureOpts are signature options -type SignatureOpts struct { - Policy []string - Label string -} - -// Attribute is an arbitrary name/value pair -type Attribute interface { - Key() AttributeName - Value() []byte - Serialise() []byte -} - -// AttributeName defines the name of an attribute assuming a -// namespace defined by the entity that certifies this attributes' -// ownership. -type AttributeName struct { - // provider/guarantor of a certain attribute; this can be - // expressed by the enrollment identifier of the entity that - // issues/certifies possession of such attributes. - provider string - // the actual name of the attribute; should be unique for a given - // provider - name string -} - -type AttributeProofSpec struct { - Attributes []Attribute - Message []byte -} - -// Structures defining the identifiers for identity providers and members -// and members that belong to them. - // IdentityIdentifier is a holder for the identifier of a specific // identity, naturally namespaced, by its provider identifier. type IdentityIdentifier struct { diff --git a/msp/msp_test.go b/msp/msp_test.go index 90d62405f75..84498110d9c 100644 --- a/msp/msp_test.go +++ b/msp/msp_test.go @@ -344,26 +344,6 @@ func TestIdentitiesGetters(t *testing.T) { assert.NotNil(t, mspid) } -func TestUnimplementedMethods(t *testing.T) { - id, err := localMsp.GetDefaultSigningIdentity() - if err != nil { - t.Fatalf("GetSigningIdentity should have succeeded, got err %s", err) - return - } - - // these methods are currently unimplemented - we assert that they return an error - err = id.VerifyOpts(nil, nil, SignatureOpts{}) - assert.Error(t, err) - err = id.VerifyAttributes(nil, nil) - assert.Error(t, err) - _, err = id.SignOpts(nil, SignatureOpts{}) - assert.Error(t, err) - _, err = id.GetAttributeProof(nil) - assert.Error(t, err) - err = id.Renew() - assert.Error(t, err) -} - func TestSignAndVerify(t *testing.T) { id, err := localMsp.GetDefaultSigningIdentity() if err != nil { diff --git a/peer/gossip/mocks/mocks.go b/peer/gossip/mocks/mocks.go index 969c3d06705..c4c6d1fb9a5 100644 --- a/peer/gossip/mocks/mocks.go +++ b/peer/gossip/mocks/mocks.go @@ -150,14 +150,6 @@ func (id *Identity) Verify(msg []byte, sig []byte) error { return errors.New("Invalid Signature") } -func (id *Identity) VerifyOpts(msg []byte, sig []byte, opts msp.SignatureOpts) error { - return nil -} - -func (id *Identity) VerifyAttributes(proof []byte, spec *msp.AttributeProofSpec) error { - return nil -} - func (id *Identity) Serialize() ([]byte, error) { return []byte("cert"), nil }