File tree Expand file tree Collapse file tree 2 files changed +57
-2
lines changed
Expand file tree Collapse file tree 2 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,11 @@ import (
1010)
1111
1212const (
13- PubKeyName = "cometbft/PubKeyBls12_381"
13+ Bls12PubKeyName = "cometbft/PubKeyBls12_381"
1414)
1515
1616func init () {
17- cmtjson .RegisterType (Bls12PubKey {}, PubKeyName )
17+ cmtjson .RegisterType (Bls12PubKey {}, Bls12PubKeyName )
1818}
1919
2020var _ crypto.PubKey = Bls12PubKey {}
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+ Bn254PubKeyName = "cometbft/PubKeyBn254"
14+ )
15+
16+ func init () {
17+ cmtjson .RegisterType (Bn254PubKey {}, Bn254PubKeyName )
18+ }
19+
20+ var _ crypto.PubKey = Bn254PubKey {}
21+
22+ type Bn254PubKey []byte
23+
24+ // Address is the SHA256-20 of the raw pubkey bytes.
25+ func (pubKey Bn254PubKey ) 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 Bn254PubKey ) Bytes () []byte {
34+ return []byte (pubKey )
35+ }
36+
37+ func (pubKey Bn254PubKey ) VerifySignature (msg []byte , sig []byte ) bool {
38+ return false
39+ }
40+
41+ func (pubKey Bn254PubKey ) String () string {
42+ return fmt .Sprintf ("PubKeyBn254{%X}" , []byte (pubKey ))
43+ }
44+
45+ func (Bn254PubKey ) Type () string {
46+ return "Bn254"
47+ }
48+
49+ func (pubKey Bn254PubKey ) Equals (other crypto.PubKey ) bool {
50+ if otherEd , ok := other .(Bn254PubKey ); 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