From 3e60b1c26b5c763f08e654fd9850e69c57f0bb14 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Tue, 20 Jun 2023 15:07:04 -0600 Subject: [PATCH] lint --- signer/cosigner_security.go | 13 +++++++++++-- signer/cosigner_security_ecies.go | 22 ++++++++++++++++++---- signer/cosigner_security_rsa.go | 10 ++++++++-- signer/local_cosigner.go | 5 +++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/signer/cosigner_security.go b/signer/cosigner_security.go index 4371e728..9d5f0cc7 100644 --- a/signer/cosigner_security.go +++ b/signer/cosigner_security.go @@ -6,8 +6,17 @@ type CosignerSecurity interface { GetID() int // EncryptAndSign encrypts the nonce and signs it for authentication. - EncryptAndSign(id int, noncePub []byte, nonceShare []byte) (CosignerNonce, error) + EncryptAndSign( + id int, + noncePub []byte, + nonceShare []byte, + ) (CosignerNonce, error) // DecryptAndVerify decrypts the nonce and verifies the signature to authenticate the source cosigner. - DecryptAndVerify(id int, encryptedNoncePub []byte, encryptedNonceShare []byte, signature []byte) ([]byte, []byte, error) + DecryptAndVerify( + id int, + encryptedNoncePub []byte, + encryptedNonceShare []byte, + signature []byte, + ) ([]byte, []byte, error) } diff --git a/signer/cosigner_security_ecies.go b/signer/cosigner_security_ecies.go index 2b1ee6fe..1ea90174 100644 --- a/signer/cosigner_security_ecies.go +++ b/signer/cosigner_security_ecies.go @@ -13,7 +13,8 @@ import ( var _ CosignerSecurity = &CosignerSecurityECIES{} -// CosignerSecurityECIES is an implementation of CosignerSecurity using ECIES for encryption and ECDSA for digital signature. +// CosignerSecurityECIES is an implementation of CosignerSecurity +// using ECIES for encryption and ECDSA for digital signature. type CosignerSecurityECIES struct { key CosignerECIESKey eciesPubKeys map[int]CosignerECIESPubKey @@ -81,7 +82,14 @@ func (c *CosignerSecurityECIES) EncryptAndSign(id int, noncePub []byte, nonceSha } hash := sha256.Sum256(jsonBytes) - signature, err := ecdsa.SignASN1(rand.Reader, &ecdsa.PrivateKey{PublicKey: ecdsa.PublicKey(*c.key.ECIESKey.PublicKey), D: c.key.ECIESKey.D}, hash[:]) + signature, err := ecdsa.SignASN1( + rand.Reader, + &ecdsa.PrivateKey{ + PublicKey: ecdsa.PublicKey(*c.key.ECIESKey.PublicKey), + D: c.key.ECIESKey.D, + }, + hash[:], + ) if err != nil { return nonce, err } @@ -92,8 +100,14 @@ func (c *CosignerSecurityECIES) EncryptAndSign(id int, noncePub []byte, nonceSha return nonce, nil } -// DecryptAndVerify decrypts the nonce and verifies the signature to authenticate the source cosigner. -func (c *CosignerSecurityECIES) DecryptAndVerify(id int, encryptedNoncePub []byte, encryptedNonceShare []byte, signature []byte) ([]byte, []byte, error) { +// DecryptAndVerify decrypts the nonce and verifies +// the signature to authenticate the source cosigner. +func (c *CosignerSecurityECIES) DecryptAndVerify( + id int, + encryptedNoncePub []byte, + encryptedNonceShare []byte, + signature []byte, +) ([]byte, []byte, error) { digestMsg := CosignerNonce{ SourceID: id, SourcePubKey: encryptedNoncePub, diff --git a/signer/cosigner_security_rsa.go b/signer/cosigner_security_rsa.go index 9e11f9ec..64d44f90 100644 --- a/signer/cosigner_security_rsa.go +++ b/signer/cosigner_security_rsa.go @@ -92,8 +92,14 @@ func (c *CosignerSecurityRSA) EncryptAndSign(id int, noncePub []byte, nonceShare return nonce, nil } -// DecryptAndVerify decrypts the nonce and verifies the signature to authenticate the source cosigner. -func (c *CosignerSecurityRSA) DecryptAndVerify(id int, encryptedNoncePub []byte, encryptedNonceShare []byte, signature []byte) ([]byte, []byte, error) { +// DecryptAndVerify decrypts the nonce and verifies +// the signature to authenticate the source cosigner. +func (c *CosignerSecurityRSA) DecryptAndVerify( + id int, + encryptedNoncePub []byte, + encryptedNonceShare []byte, + signature []byte, +) ([]byte, []byte, error) { digestMsg := CosignerNonce{ SourceID: id, SourcePubKey: encryptedNoncePub, diff --git a/signer/local_cosigner.go b/signer/local_cosigner.go index 85aed1b3..643c3558 100644 --- a/signer/local_cosigner.go +++ b/signer/local_cosigner.go @@ -364,7 +364,7 @@ func (cosigner *LocalCosigner) GetNonces( var eg errgroup.Group - for i := 1; i <= int(total); i++ { + for i := 1; i <= total; i++ { if i == id { continue } @@ -479,7 +479,8 @@ func (cosigner *LocalCosigner) setNonce(req CosignerSetNonceRequest) error { return errors.New("SourceSig field is required") } - noncePub, nonceShare, err := cosigner.security.DecryptAndVerify(req.SourceID, req.SourcePubKey, req.EncryptedSharePart, req.SourceSig) + noncePub, nonceShare, err := cosigner.security.DecryptAndVerify( + req.SourceID, req.SourcePubKey, req.EncryptedSharePart, req.SourceSig) if err != nil { return err }