File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ package crypto
2+
3+ import (
4+ "bytes"
5+ "fmt"
6+
7+ "github.com/cometbft/cometbft/crypto"
8+ "github.com/cometbft/cometbft/crypto/tmhash"
9+ cmtjson "github.com/cometbft/cometbft/libs/json"
10+ )
11+
12+ const (
13+ Secp256k1ethPubKeyName = "cometbft/PubKeySecp256k1eth"
14+ )
15+
16+ func init () {
17+ cmtjson .RegisterType (Secp256k1ethPubKey {}, Secp256k1ethPubKeyName )
18+ }
19+
20+ var _ crypto.PubKey = Secp256k1ethPubKey {}
21+
22+ type Secp256k1ethPubKey []byte
23+
24+ // Address is the SHA256-20 of the raw pubkey bytes.
25+ func (pubKey Secp256k1ethPubKey ) Address () crypto.Address {
26+ // if len(pubKey) != PubKeySize {
27+ // panic("pubkey is incorrect size")
28+ // }
29+ return crypto .Address (tmhash .SumTruncated (pubKey ))
30+ }
31+
32+ // Bytes returns the PubKey byte format.
33+ func (pubKey Secp256k1ethPubKey ) Bytes () []byte {
34+ return []byte (pubKey )
35+ }
36+
37+ func (pubKey Secp256k1ethPubKey ) VerifySignature (msg []byte , sig []byte ) bool {
38+ return false
39+ }
40+
41+ func (pubKey Secp256k1ethPubKey ) String () string {
42+ return fmt .Sprintf ("PubKeySecp256k1eth_381{%X}" , []byte (pubKey ))
43+ }
44+
45+ func (Secp256k1ethPubKey ) Type () string {
46+ return "Secp256k1eth_381"
47+ }
48+
49+ func (pubKey Secp256k1ethPubKey ) Equals (other crypto.PubKey ) bool {
50+ if otherEd , ok := other .(Secp256k1ethPubKey ); ok {
51+ return bytes .Equal (pubKey [:], otherEd [:])
52+ }
53+
54+ return false
55+ }
You can’t perform that action at this time.
0 commit comments