Skip to content

Commit

Permalink
[FAB-3708] cleanup unused/unimplemented msp code
Browse files Browse the repository at this point in the history
This change set removes a few unused structs/types.

Change-Id: I65ca1cf56dc1a1348e44cec08a15fe3833e4631f
Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
  • Loading branch information
ale-linux committed Jun 1, 2017
1 parent fa63fb9 commit 5f6a232
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 152 deletions.
8 changes: 0 additions & 8 deletions common/cauthdsl/cauthdsl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 0 additions & 20 deletions common/mocks/msp/noopmsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
8 changes: 0 additions & 8 deletions core/policy/mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
25 changes: 0 additions & 25 deletions msp/identities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
}
63 changes: 0 additions & 63 deletions msp/msp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 {
Expand Down
20 changes: 0 additions & 20 deletions msp/msp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 0 additions & 8 deletions peer/gossip/mocks/mocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5f6a232

Please sign in to comment.