Skip to content

Commit a5adcc3

Browse files
kortatunolash
authored andcommitted
pss: Distill whisper elements in pss to a custom fallback crypto (ethersphere#1731)
* pss: Distilled whisper message structure and encryption to default crypto implementation. Added Topic to PssMsg Simplified PssMsg Payload to []byte Moved crypto to own package
1 parent 3fd9021 commit a5adcc3

File tree

14 files changed

+780
-508
lines changed

14 files changed

+780
-508
lines changed

pss/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ func (pssapi *API) BaseAddr() (PssAddress, error) {
117117
// Retrieves the node's public key in hex form
118118
func (pssapi *API) GetPublicKey() (keybytes hexutil.Bytes) {
119119
key := pssapi.Pss.PublicKey()
120-
keybytes = pssapi.Pss.Crypto.FromECDSAPub(key)
120+
keybytes = pssapi.Pss.Crypto.SerializePublicKey(key)
121121
return keybytes
122122
}
123123

124124
// Set Public key to associate with a particular Pss peer
125125
func (pssapi *API) SetPeerPublicKey(pubkey hexutil.Bytes, topic Topic, addr PssAddress) error {
126-
pk, err := pssapi.Pss.Crypto.UnmarshalPubkey(pubkey)
126+
pk, err := pssapi.Pss.Crypto.UnmarshalPublicKey(pubkey)
127127
if err != nil {
128128
return fmt.Errorf("Cannot unmarshal pubkey: %x", pubkey)
129129
}

pss/client/client_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/ethereum/go-ethereum/common/hexutil"
28+
ethCrypto "github.com/ethereum/go-ethereum/crypto"
2829
"github.com/ethereum/go-ethereum/log"
2930
"github.com/ethereum/go-ethereum/node"
3031
"github.com/ethereum/go-ethereum/p2p"
@@ -45,7 +46,6 @@ type protoCtrl struct {
4546
}
4647

4748
var (
48-
cryptoUtils pss.CryptoUtils
4949
// custom logging
5050
psslogmain log.Logger
5151
pssprotocols map[string]*protoCtrl
@@ -62,8 +62,6 @@ func init() {
6262

6363
psslogmain = log.New("psslog", "*")
6464

65-
cryptoUtils = pss.NewCryptoUtils()
66-
6765
pssprotocols = make(map[string]*protoCtrl)
6866
}
6967

@@ -231,13 +229,7 @@ func newServices() adapters.Services {
231229
}
232230
return adapters.Services{
233231
"pss": func(ctx *adapters.ServiceContext) (node.Service, error) {
234-
ctxlocal, cancel := context.WithTimeout(context.Background(), time.Second)
235-
defer cancel()
236-
keys, err := cryptoUtils.NewKeyPair(ctxlocal)
237-
if err != nil {
238-
return nil, err
239-
}
240-
privkey, err := cryptoUtils.GetPrivateKey(keys)
232+
privkey, err := ethCrypto.GenerateKey()
241233
if err != nil {
242234
return nil, err
243235
}

pss/crypto.go

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)