Skip to content

Commit 245f28f

Browse files
committed
ss: PR ethersphere#1731. Comments on public Utils methods.
Removed unused method in crypto.go
1 parent d97d35d commit 245f28f

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

pss/crypto/crypto.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,6 @@ func (msg *receivedMessage) validateAndParse() error {
194194
return nil
195195
}
196196

197-
// sigToPubKey returns the public key associated to the message's signature.
198-
// should only be called if message has been signed
199-
func (msg *receivedMessage) sigToPubKey() *ecdsa.PublicKey {
200-
defer func() { recover() }() // in case of invalid signature
201-
202-
signedBytes := msg.Raw
203-
if isMessageSigned(msg.Raw[0]) {
204-
sz := len(msg.Raw) - signatureLength
205-
signedBytes = msg.Raw[:sz]
206-
}
207-
pub, err := msg.crypto.sigToPub(signedBytes, msg.Signature)
208-
if err != nil {
209-
log.Error("failed to recover public key from signature", "err", err)
210-
return nil
211-
}
212-
return pub
213-
}
214-
215197
func newReceivedMessage(decrypted []byte, salt []byte, crypto *defaultCryptoBackend) *receivedMessage {
216198
return &receivedMessage{
217199
Raw: decrypted,

pss/crypto/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func NewUtils() Utils {
4141
}
4242
}
4343

44+
// Generates a new private key right away. It is not stored for later retrieval.
4445
func (utils *utils) GenerateKey() (*ecdsa.PrivateKey, error) {
4546
return ethCrypto.GenerateKey()
4647
}
@@ -74,6 +75,7 @@ func (utils *utils) NewKeyPair() (string, error) {
7475
return id, nil
7576
}
7677

78+
// GetPrivateKey return a PrivateKey previously generated in NewKeyPair by id
7779
func (utils *utils) GetPrivateKey(id string) (*ecdsa.PrivateKey, error) {
7880
utils.keyMu.RLock()
7981
defer utils.keyMu.RUnlock()

0 commit comments

Comments
 (0)