aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/crypto.go4
-rw-r--r--crypto/crypto_test.go2
-rw-r--r--crypto/ecies/asn1.go12
-rw-r--r--crypto/ecies/ecies.go7
-rw-r--r--crypto/ecies/ecies_test.go6
-rw-r--r--crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h4
-rw-r--r--crypto/secp256k1/notes.go2
-rw-r--r--crypto/secp256k1/secp256.go2
-rw-r--r--crypto/sha3/sha3_test.go2
9 files changed, 20 insertions, 21 deletions
diff --git a/crypto/crypto.go b/crypto/crypto.go
index f1a4b774c..ce45ebd38 100644
--- a/crypto/crypto.go
+++ b/crypto/crypto.go
@@ -194,9 +194,9 @@ func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error) {
// Sign calculates an ECDSA signature.
//
-// This function is susceptible to choosen plaintext attacks that can leak
+// This function is susceptible to chosen plaintext attacks that can leak
// information about the private key that is used for signing. Callers must
-// be aware that the given hash cannot be choosen by an adversery. Common
+// be aware that the given hash cannot be chosen by an adversery. Common
// solution is to hash any input before calculating the signature.
//
// The produced signature is in the [R || S || V] format where V is 0 or 1.
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go
index 86a582306..f42605d32 100644
--- a/crypto/crypto_test.go
+++ b/crypto/crypto_test.go
@@ -217,7 +217,7 @@ func TestValidateSignatureValues(t *testing.T) {
func checkhash(t *testing.T, name string, f func([]byte) []byte, msg, exp []byte) {
sum := f(msg)
- if bytes.Compare(exp, sum) != 0 {
+ if !bytes.Equal(exp, sum) {
t.Fatalf("hash %s mismatch: want: %x have: %x", name, exp, sum)
}
}
diff --git a/crypto/ecies/asn1.go b/crypto/ecies/asn1.go
index 40dabd329..508a645cd 100644
--- a/crypto/ecies/asn1.go
+++ b/crypto/ecies/asn1.go
@@ -109,7 +109,7 @@ func (curve secgNamedCurve) Equal(curve2 secgNamedCurve) bool {
if len(curve) != len(curve2) {
return false
}
- for i, _ := range curve {
+ for i := range curve {
if curve[i] != curve2[i] {
return false
}
@@ -157,7 +157,7 @@ func (a asnAlgorithmIdentifier) Cmp(b asnAlgorithmIdentifier) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -306,7 +306,7 @@ func (a asnECDHAlgorithm) Cmp(b asnECDHAlgorithm) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -325,7 +325,7 @@ func (a asnKeyDerivationFunction) Cmp(b asnKeyDerivationFunction) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -360,7 +360,7 @@ func (a asnSymmetricEncryption) Cmp(b asnSymmetricEncryption) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
@@ -380,7 +380,7 @@ func (a asnMessageAuthenticationCode) Cmp(b asnMessageAuthenticationCode) bool {
if len(a.Algorithm) != len(b.Algorithm) {
return false
}
- for i, _ := range a.Algorithm {
+ for i := range a.Algorithm {
if a.Algorithm[i] != b.Algorithm[i] {
return false
}
diff --git a/crypto/ecies/ecies.go b/crypto/ecies/ecies.go
index 86a70261d..2a16f20a2 100644
--- a/crypto/ecies/ecies.go
+++ b/crypto/ecies/ecies.go
@@ -93,7 +93,7 @@ func ImportECDSA(prv *ecdsa.PrivateKey) *PrivateKey {
}
// Generate an elliptic curve public / private keypair. If params is nil,
-// the recommended default paramters for the key will be chosen.
+// the recommended default parameters for the key will be chosen.
func GenerateKey(rand io.Reader, curve elliptic.Curve, params *ECIESParams) (prv *PrivateKey, err error) {
pb, x, y, err := elliptic.GenerateKey(curve, rand)
if err != nil {
@@ -291,9 +291,8 @@ func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err e
// Decrypt decrypts an ECIES ciphertext.
func (prv *PrivateKey) Decrypt(rand io.Reader, c, s1, s2 []byte) (m []byte, err error) {
- if c == nil || len(c) == 0 {
- err = ErrInvalidMessage
- return
+ if len(c) == 0 {
+ return nil, ErrInvalidMessage
}
params := prv.PublicKey.Params
if params == nil {
diff --git a/crypto/ecies/ecies_test.go b/crypto/ecies/ecies_test.go
index cb09061ce..3b3517baf 100644
--- a/crypto/ecies/ecies_test.go
+++ b/crypto/ecies/ecies_test.go
@@ -492,17 +492,17 @@ type testCase struct {
}
var testCases = []testCase{
- testCase{
+ {
Curve: elliptic.P256(),
Name: "P256",
Expected: true,
},
- testCase{
+ {
Curve: elliptic.P384(),
Name: "P384",
Expected: true,
},
- testCase{
+ {
Curve: elliptic.P521(),
Name: "P521",
Expected: true,
diff --git a/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h b/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h
index 49354933d..9b4f5b607 100644
--- a/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h
+++ b/crypto/secp256k1/libsecp256k1/include/secp256k1_schnorr.h
@@ -99,7 +99,7 @@ SECP256K1_API int secp256k1_schnorr_generate_nonce_pair(
/** Produce a partial Schnorr signature, which can be combined using
* secp256k1_schnorr_partial_combine, to end up with a full signature that is
* verifiable using secp256k1_schnorr_verify.
- * Returns: 1: signature created succesfully.
+ * Returns: 1: signature created successfully.
* 0: no valid signature exists with this combination of keys, nonces
* and message (chance around 1 in 2^128)
* -1: invalid private key, nonce, or public nonces.
@@ -148,7 +148,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_schnorr_partial_sign(
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6);
/** Combine multiple Schnorr partial signatures.
- * Returns: 1: the passed signatures were succesfully combined.
+ * Returns: 1: the passed signatures were successfully combined.
* 0: the resulting signature is not valid (chance of 1 in 2^256)
* -1: some inputs were invalid, or the signatures were not created
* using the same set of nonces
diff --git a/crypto/secp256k1/notes.go b/crypto/secp256k1/notes.go
index 93e6d1902..49fcf8e2d 100644
--- a/crypto/secp256k1/notes.go
+++ b/crypto/secp256k1/notes.go
@@ -163,7 +163,7 @@ int secp256k1_ecdsa_sign_compact(const unsigned char *msg, int msglen,
int *recid);
* Recover an ECDSA public key from a compact signature.
- * Returns: 1: public key succesfully recovered (which guarantees a correct signature).
+ * Returns: 1: public key successfully recovered (which guarantees a correct signature).
* 0: otherwise.
* In: msg: the message assumed to be signed
* msglen: the length of the message
diff --git a/crypto/secp256k1/secp256.go b/crypto/secp256k1/secp256.go
index 4999c5c95..2c5f61450 100644
--- a/crypto/secp256k1/secp256.go
+++ b/crypto/secp256k1/secp256.go
@@ -49,7 +49,7 @@ import (
/*
TODO:
- > store private keys in buffer and shuffle (deters persistance on swap disc)
+ > store private keys in buffer and shuffle (deters persistence on swap disc)
> byte permutation (changing)
> xor with chaning random block (to deter scanning memory for 0x63) (stream cipher?)
*/
diff --git a/crypto/sha3/sha3_test.go b/crypto/sha3/sha3_test.go
index caf72f279..c433761a8 100644
--- a/crypto/sha3/sha3_test.go
+++ b/crypto/sha3/sha3_test.go
@@ -201,7 +201,7 @@ func TestSqueezing(t *testing.T) {
d1 := newShakeHash()
d1.Write([]byte(testString))
var multiple []byte
- for _ = range ref {
+ for range ref {
one := make([]byte, 1)
d1.Read(one)
multiple = append(multiple, one...)