status-go/common/utils.go

25 lines
433 B
Go
Raw Normal View History

2023-11-15 15:58:15 +00:00
package common
import (
"crypto/ecdsa"
2020-01-02 09:10:19 +00:00
"github.com/status-im/status-go/eth-node/crypto"
2023-11-15 15:58:15 +00:00
"github.com/status-im/status-go/protocol/protobuf"
)
2023-11-15 15:58:15 +00:00
func RecoverKey(m *protobuf.ApplicationMetadataMessage) (*ecdsa.PublicKey, error) {
if m.Signature == nil {
return nil, nil
}
recoveredKey, err := crypto.SigToPub(
crypto.Keccak256(m.Payload),
m.Signature,
)
if err != nil {
return nil, err
}
return recoveredKey, nil
}