Skip to content

Commit

Permalink
Run gofumpt -l -s -w against the tree
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Sykes <[email protected]>
  • Loading branch information
sykesm committed Feb 1, 2021
1 parent 825a5e4 commit 8ddb55f
Show file tree
Hide file tree
Showing 538 changed files with 2,829 additions and 3,201 deletions.
1 change: 0 additions & 1 deletion bccsp/factory/swfactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ func TestSWFactoryGet(t *testing.T) {
csp, err = f.Get(opts)
require.NoError(t, err)
require.NotNil(t, csp)

}
12 changes: 4 additions & 8 deletions bccsp/hashopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,31 @@ package bccsp
import "fmt"

// SHA256Opts contains options relating to SHA-256.
type SHA256Opts struct {
}
type SHA256Opts struct{}

// Algorithm returns the hash algorithm identifier (to be used).
func (opts *SHA256Opts) Algorithm() string {
return SHA256
}

// SHA384Opts contains options relating to SHA-384.
type SHA384Opts struct {
}
type SHA384Opts struct{}

// Algorithm returns the hash algorithm identifier (to be used).
func (opts *SHA384Opts) Algorithm() string {
return SHA384
}

// SHA3_256Opts contains options relating to SHA3-256.
type SHA3_256Opts struct {
}
type SHA3_256Opts struct{}

// Algorithm returns the hash algorithm identifier (to be used).
func (opts *SHA3_256Opts) Algorithm() string {
return SHA3_256
}

// SHA3_384Opts contains options relating to SHA3-384.
type SHA3_384Opts struct {
}
type SHA3_384Opts struct{}

// Algorithm returns the hash algorithm identifier (to be used).
func (opts *SHA3_384Opts) Algorithm() string {
Expand Down
5 changes: 0 additions & 5 deletions bccsp/idemix/bccsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
)

var _ = Describe("Idemix Bridge", func() {

Describe("setting up the environment with one issuer and one user", func() {
var (
CSP bccsp.BCCSP
Expand Down Expand Up @@ -102,7 +101,6 @@ var _ = Describe("Idemix Bridge", func() {
&bccsp.IdemixCRISignerOpts{},
)
Expect(err).NotTo(HaveOccurred())

})

It("the environment is properly set", func() {
Expand Down Expand Up @@ -200,7 +198,6 @@ var _ = Describe("Idemix Bridge", func() {
Expect(err).NotTo(HaveOccurred())
Expect(valid).To(BeTrue())
})

})

Describe("producing an idemix signature with disclosed attributes", func() {
Expand Down Expand Up @@ -257,7 +254,6 @@ var _ = Describe("Idemix Bridge", func() {
Expect(err).NotTo(HaveOccurred())
Expect(valid).To(BeTrue())
})

})

Describe("producing an idemix nym signature", func() {
Expand Down Expand Up @@ -294,7 +290,6 @@ var _ = Describe("Idemix Bridge", func() {
Expect(err).NotTo(HaveOccurred())
Expect(valid).To(BeTrue())
})

})
})
})
48 changes: 8 additions & 40 deletions bccsp/idemix/bridge/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,13 @@ var _ = Describe("Idemix Bridge", func() {
})

Describe("issuer", func() {
var (
Issuer *bridge.Issuer
)
var Issuer *bridge.Issuer

BeforeEach(func() {
Issuer = &bridge.Issuer{NewRand: bridge.NewRandOrPanic}
})

Context("key generation", func() {

Context("successful generation", func() {
var (
key handlers.IssuerSecretKey
Expand Down Expand Up @@ -104,7 +101,6 @@ var _ = Describe("Idemix Bridge", func() {
})

Context("public key import", func() {

It("fails to unmarshal issuer public key", func() {
pk, err := Issuer.NewPublicKeyFromBytes([]byte{0, 1, 2, 3, 4}, nil)
Expect(err).To(MatchError("failed to unmarshal issuer public key: proto: idemix.IssuerPublicKey: illegal tag 0 (wire type 0)"))
Expand All @@ -118,9 +114,7 @@ var _ = Describe("Idemix Bridge", func() {
})

Context("and it is modified", func() {
var (
pk handlers.IssuerPublicKey
)
var pk handlers.IssuerPublicKey
BeforeEach(func() {
attributes := []string{"A", "B"}
key, err := Issuer.NewKey(attributes)
Expand Down Expand Up @@ -164,14 +158,11 @@ var _ = Describe("Idemix Bridge", func() {
Expect(pk).To(BeNil())
})
})

})
})

Describe("user", func() {
var (
User *bridge.User
)
var User *bridge.User

BeforeEach(func() {
User = &bridge.User{NewRand: bridge.NewRandOrPanic}
Expand Down Expand Up @@ -219,7 +210,6 @@ var _ = Describe("Idemix Bridge", func() {
})

Context("nym generation", func() {

It("fails on nil user secret key", func() {
r1, r2, err := User.MakeNym(nil, issuerPublicKey)
Expect(err).To(MatchError("invalid user secret key, expected *Big, got [<nil>]"))
Expand Down Expand Up @@ -286,7 +276,6 @@ var _ = Describe("Idemix Bridge", func() {
Expect(err).To(MatchError("failure [runtime error: index out of range [2] with length 2]"))
Expect(key).To(BeNil())
})

})
})

Expand Down Expand Up @@ -346,7 +335,6 @@ var _ = Describe("Idemix Bridge", func() {
Expect(err).To(MatchError("failure [new rand panic]"))
Expect(raw).To(BeNil())
})

})

Context("verify", func() {
Expand All @@ -369,20 +357,16 @@ var _ = Describe("Idemix Bridge", func() {
err := CredRequest.Verify(nil, &mock.IssuerPublicKey{}, IssuerNonce)
Expect(err).To(MatchError("invalid issuer public key, expected *IssuerPublicKey, got [*mock.IssuerPublicKey]"))
})

})
})

Describe("credential", func() {
var (
Credential handlers.Credential
)
var Credential handlers.Credential
BeforeEach(func() {
Credential = &bridge.Credential{}
})

Context("sign", func() {

It("fail on nil issuer secret key", func() {
raw, err := Credential.Sign(nil, []byte{0, 1, 2, 3, 4}, nil)
Expect(err).To(MatchError("invalid issuer secret key, expected *Big, got [<nil>]"))
Expand Down Expand Up @@ -441,15 +425,12 @@ var _ = Describe("Idemix Bridge", func() {
})

Describe("revocation", func() {
var (
Revocation handlers.Revocation
)
var Revocation handlers.Revocation
BeforeEach(func() {
Revocation = &bridge.Revocation{}
})

Context("sign", func() {

It("fail on nil inputs", func() {
raw, err := Revocation.Sign(nil, nil, 0, 0)
Expect(err).To(MatchError("failed creating CRI: CreateCRI received nil input"))
Expand Down Expand Up @@ -477,9 +458,7 @@ var _ = Describe("Idemix Bridge", func() {
})

Describe("signature", func() {
var (
SignatureScheme handlers.SignatureScheme
)
var SignatureScheme handlers.SignatureScheme
BeforeEach(func() {
SignatureScheme = &bridge.SignatureScheme{NewRand: bridge.NewRandOrPanic}
})
Expand Down Expand Up @@ -535,9 +514,7 @@ var _ = Describe("Idemix Bridge", func() {
})

Describe("nym signature", func() {
var (
NymSignatureScheme handlers.NymSignatureScheme
)
var NymSignatureScheme handlers.NymSignatureScheme
BeforeEach(func() {
NymSignatureScheme = &bridge.NymSignatureScheme{NewRand: bridge.NewRandOrPanic}
})
Expand Down Expand Up @@ -588,7 +565,6 @@ var _ = Describe("Idemix Bridge", func() {
err := NymSignatureScheme.Verify(issuerPublicKey, nymPublicKey, []byte{0, 1, 2, 3, 4}, nil)
Expect(err).To(MatchError("error unmarshalling signature: proto: idemix.NymSignature: illegal tag 0 (wire type 0)"))
})

})
})

Expand Down Expand Up @@ -747,7 +723,6 @@ var _ = Describe("Idemix Bridge", func() {
})

Context("the environment is not valid with the respect to different parameters", func() {

It("invalid credential request nonce", func() {
valid, err := CredentialRequestVerifier.Verify(
IssuerPublicKey,
Expand Down Expand Up @@ -919,7 +894,6 @@ var _ = Describe("Idemix Bridge", func() {
)
Expect(err).To(MatchError("credential does not contain the correct attribute value at position [2]"))
Expect(valid).To(BeFalse())

})

It("invalid cri", func() {
Expand All @@ -937,7 +911,6 @@ var _ = Describe("Idemix Bridge", func() {
})

Describe("the environment is not properly set", func() {

Describe("issuer", func() {
Context("duplicate attribute", func() {
It("returns an error", func() {
Expand All @@ -948,7 +921,6 @@ var _ = Describe("Idemix Bridge", func() {
})
})
})

})

Describe("producing and verifying idemix signature with different sets of attributes", func() {
Expand Down Expand Up @@ -1076,7 +1048,6 @@ var _ = Describe("Idemix Bridge", func() {
}
Expect(valid).To(BeEquivalentTo(validity))
})

})

Context("producing an idemix signature", func() {
Expand Down Expand Up @@ -1190,7 +1161,6 @@ var _ = Describe("Idemix Bridge", func() {
)
Expect(err).To(MatchError("signature invalid: APrime = 1"))
Expect(valid).To(BeFalse())

})

It("fails when the credential is nil", func() {
Expand Down Expand Up @@ -1405,9 +1375,7 @@ var _ = Describe("Idemix Bridge", func() {
})

Context("importing nym key", func() {
var (
NymPublicKeyImporter *handlers.NymPublicKeyImporter
)
var NymPublicKeyImporter *handlers.NymPublicKeyImporter

BeforeEach(func() {
NymPublicKeyImporter = &handlers.NymPublicKeyImporter{User: User}
Expand Down
9 changes: 6 additions & 3 deletions bccsp/idemix/bridge/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,26 @@ func (*Issuer) NewPublicKeyFromBytes(raw []byte, attributes []string) (res handl
return nil, errors.WithStack(&bccsp.IdemixIssuerPublicKeyImporterError{
Type: bccsp.IdemixIssuerPublicKeyImporterUnmarshallingError,
ErrorMsg: "failed to unmarshal issuer public key",
Cause: err})
Cause: err,
})
}

err = ipk.SetHash()
if err != nil {
return nil, errors.WithStack(&bccsp.IdemixIssuerPublicKeyImporterError{
Type: bccsp.IdemixIssuerPublicKeyImporterHashError,
ErrorMsg: "setting the hash of the issuer public key failed",
Cause: err})
Cause: err,
})
}

err = ipk.Check()
if err != nil {
return nil, errors.WithStack(&bccsp.IdemixIssuerPublicKeyImporterError{
Type: bccsp.IdemixIssuerPublicKeyImporterValidationError,
ErrorMsg: "invalid issuer public key",
Cause: err})
Cause: err,
})
}

if len(attributes) != 0 {
Expand Down
3 changes: 1 addition & 2 deletions bccsp/idemix/bridge/revocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

// Revocation encapsulates the idemix algorithms for revocation
type Revocation struct {
}
type Revocation struct{}

// NewKey generate a new revocation key-pair.
func (*Revocation) NewKey() (*ecdsa.PrivateKey, error) {
Expand Down
Loading

0 comments on commit 8ddb55f

Please sign in to comment.