Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Config struct {

*network.HiveParams
Swap *swap.LocalProfile
Pss *pss.PssParams
Pss *pss.Params
Contract common.Address
EnsRoot common.Address
EnsAPIs []string
Expand Down Expand Up @@ -87,7 +87,7 @@ func NewConfig() (c *Config) {
FileStoreParams: storage.NewFileStoreParams(),
HiveParams: network.NewHiveParams(),
Swap: swap.NewDefaultSwapParams(),
Pss: pss.NewPssParams(),
Pss: pss.NewParams(),
ListenAddr: DefaultHTTPListenAddr,
Port: DefaultHTTPPort,
Path: node.DefaultDataDir(),
Expand Down
2 changes: 1 addition & 1 deletion pss/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func newServices() adapters.Services {
if err != nil {
return nil, err
}
psparams := pss.NewPssParams().WithPrivateKey(privkey)
psparams := pss.NewParams().WithPrivateKey(privkey)
pskad := kademlia(ctx.Config.ID)
ps, err := pss.NewPss(pskad, psparams)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pss/forwarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func addPeers(kad *network.Kademlia, addresses []pot.Address) {

func createPss(t *testing.T, kad *network.Kademlia) *Pss {
privKey, err := crypto.GenerateKey()
pssp := NewPssParams().WithPrivateKey(privKey)
pssp := NewParams().WithPrivateKey(privKey)
ps, err := NewPss(kad, pssp)
if err != nil {
t.Fatal(err.Error())
Expand Down
24 changes: 12 additions & 12 deletions pss/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ type KeyStore struct {
w *whisper.Whisper // key and encryption backend

mx sync.RWMutex
pubKeyPool map[string]map[Topic]*pssPeer // mapping of hex public keys to peer address by topic.
symKeyPool map[string]map[Topic]*pssPeer // mapping of symkeyids to peer address by topic.
symKeyDecryptCache []*string // fast lookup of symkeys recently used for decryption; last used is on top of stack
symKeyDecryptCacheCursor int // modular cursor pointing to last used, wraps on symKeyDecryptCache array
pubKeyPool map[string]map[Topic]*peer // mapping of hex public keys to peer address by topic.
symKeyPool map[string]map[Topic]*peer // mapping of symkeyids to peer address by topic.
symKeyDecryptCache []*string // fast lookup of symkeys recently used for decryption; last used is on top of stack
symKeyDecryptCacheCursor int // modular cursor pointing to last used, wraps on symKeyDecryptCache array
}

func loadKeyStore() *KeyStore {
return &KeyStore{
w: whisper.New(&whisper.DefaultConfig),

pubKeyPool: make(map[string]map[Topic]*pssPeer),
symKeyPool: make(map[string]map[Topic]*pssPeer),
pubKeyPool: make(map[string]map[Topic]*peer),
symKeyPool: make(map[string]map[Topic]*peer),
symKeyDecryptCache: make([]*string, defaultSymKeyCacheCapacity),
}
}
Expand All @@ -65,14 +65,14 @@ func (ks *KeyStore) isPubKeyStored(key string) bool {
return ok
}

func (ks *KeyStore) getPeerSym(symkeyid string, topic Topic) (*pssPeer, bool) {
func (ks *KeyStore) getPeerSym(symkeyid string, topic Topic) (*peer, bool) {
ks.mx.RLock()
defer ks.mx.RUnlock()
psp, ok := ks.symKeyPool[symkeyid][topic]
return psp, ok
}

func (ks *KeyStore) getPeerPub(pubkeyid string, topic Topic) (*pssPeer, bool) {
func (ks *KeyStore) getPeerPub(pubkeyid string, topic Topic) (*peer, bool) {
ks.mx.RLock()
defer ks.mx.RUnlock()
psp, ok := ks.pubKeyPool[pubkeyid][topic]
Expand All @@ -91,12 +91,12 @@ func (ks *KeyStore) SetPeerPublicKey(pubkey *ecdsa.PublicKey, topic Topic, addre
return fmt.Errorf("invalid public key: %v", pubkey)
}
pubkeyid := common.ToHex(pubkeybytes)
psp := &pssPeer{
psp := &peer{
address: address,
}
ks.mx.Lock()
if _, ok := ks.pubKeyPool[pubkeyid]; !ok {
ks.pubKeyPool[pubkeyid] = make(map[Topic]*pssPeer)
ks.pubKeyPool[pubkeyid] = make(map[Topic]*peer)
}
ks.pubKeyPool[pubkeyid][topic] = psp
ks.mx.Unlock()
Expand All @@ -107,13 +107,13 @@ func (ks *KeyStore) SetPeerPublicKey(pubkey *ecdsa.PublicKey, topic Topic, addre
// adds a symmetric key to the pss key pool, and optionally adds the key to the
// collection of keys used to attempt symmetric decryption of incoming messages
func (ks *KeyStore) addSymmetricKeyToPool(keyid string, topic Topic, address PssAddress, addtocache bool, protected bool) {
psp := &pssPeer{
psp := &peer{
address: address,
protected: protected,
}
ks.mx.Lock()
if _, ok := ks.symKeyPool[keyid]; !ok {
ks.symKeyPool[keyid] = make(map[Topic]*pssPeer)
ks.symKeyPool[keyid] = make(map[Topic]*peer)
}
ks.symKeyPool[keyid][topic] = psp
ks.mx.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion pss/notify/notify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func newServices(allowRaw bool) adapters.Services {
if err != nil {
return nil, err
}
pssp := pss.NewPssParams().WithPrivateKey(privkey)
pssp := pss.NewParams().WithPrivateKey(privkey)
pssp.MsgTTL = time.Second * 30
pssp.AllowRaw = allowRaw
pskad := kademlia(ctx.Config.ID)
Expand Down
2 changes: 1 addition & 1 deletion pss/prox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func newProxServices(td *testData, allowRaw bool, handlerContextFuncs map[Topic]
defer cancel()
keys, err := wapi.NewKeyPair(ctxlocal)
privkey, err := w.GetPrivateKey(keys)
pssp := NewPssParams().WithPrivateKey(privkey)
pssp := NewParams().WithPrivateKey(privkey)
pssp.AllowRaw = allowRaw
bzzPrivateKey, err := simulation.BzzPrivateKeyFromConfig(ctx.Config)
if err != nil {
Expand Down
Loading