Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

pss: Modularize crypto and remove Whisper. Step 1 - isolate whisper code #1698

Merged
merged 8 commits into from
Sep 2, 2019

Conversation

kortatu
Copy link
Contributor

@kortatu kortatu commented Aug 28, 2019

We want to modularize crypto and stop depending on whisper. Issue #1655 describe several steps to achive this. The goal of this PR is just a small fraction of that first step.
This PR isolates all usages of whisper into two new files:

  • crypto.go: contains all the whisper usages related to keys management

  • message.go: contains the data model related to envelopes and messages that we were using from whisper.

This PR is only a refactor of code, we are not changing anything so all the new methods and types are delegating into the old whisper methods and types.

The only minor thing done was removing unused fields from whisper.ReceivedMessage and whisper.Envelope.

In crypto.go we have created and interface of the methods needed by keystore and also created a default implementation delegating to whisper.

We also isolated code calling github.com/ethereum/go-ethereum/crypto into crypto.go.

There are some crypto utilities used only by tests. Instead of adding those methods to the crypto interface, we created CryptoUtils.go and add them there. CryptoUtils is intended to be used only in tests.

Copy link
Contributor

@nolash nolash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it that the API defined here is entirely temporary, just tailored to fit the whisper that's been extracted?

We will need to go through a SWIP process to define the actual new API.

pss/crypto.go Outdated Show resolved Hide resolved
pss/message.go Show resolved Hide resolved
Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

pss/keystore.go Outdated Show resolved Hide resolved
pss/notify/notify_test.go Outdated Show resolved Hide resolved
pss/notify/notify_test.go Outdated Show resolved Hide resolved
pss/pss_test.go Outdated Show resolved Hide resolved
@kortatu
Copy link
Contributor Author

kortatu commented Aug 29, 2019

I think I'm going to encapsulate all uses of github.com/ethereum/go-ethereum/crypto in pss/crypto.go so pss will have a unqie entry point for cryptography.

@kortatu
Copy link
Contributor Author

kortatu commented Aug 29, 2019

I take it that the API defined here is entirely temporary, just tailored to fit the whisper that's been extracted?

We will need to go through a SWIP process to define the actual new API.

Yes, I also think that defining the crypto API should not be part of this stage. Anyway, in order to have a good view of the necessary methods I'm going to include all the uses of github.com/ethereum/go-ethereum/crypto aslo.

@kortatu kortatu removed their assignment Aug 29, 2019
@kortatu kortatu requested a review from nolash August 29, 2019 13:08
pss/crypto.go Show resolved Hide resolved
pss/notify/notify_test.go Outdated Show resolved Hide resolved
Created Message and Envelope Types similar to whisper ones.
Create a new CryptoBackend interface and default implementation using Whisper
Separated crypto utilities for tests in CryptoUtils
@nolash nolash merged commit 403e54e into ethersphere:master Sep 2, 2019
@kortatu kortatu deleted the issue-1655 branch September 11, 2019 07:37
@skylenet skylenet added this to the 0.5.0 milestone Sep 17, 2019
chadsr added a commit to chadsr/swarm that referenced this pull request Sep 23, 2019
* 'master' of github.com:ethersphere/swarm:
  pss: Modularize crypto and remove Whisper. Step 1 - isolate whisper code (ethersphere#1698)
  pss: Improve pressure backstop queue handling - no mutex (ethersphere#1695)
  cmd/swarm-snapshot: if 2 nodes to create snapshot use connectChain (ethersphere#1709)
  network: Add API for Capabilities (ethersphere#1675)
  pss: fixed flaky test that was using a global variable instead of a local one (ethersphere#1702)
  pss: Port tests to `network/simulation` (ethersphere#1682)
  storage: fix hasherstore seen check to happen when error is nil (ethersphere#1700)
  vendor: upgrade go-ethereum to 1.9.2 (ethersphere#1689)
  bzzeth: initial support for bzz-eth protocol (ethersphere#1571)
  network/stream: terminate runUpdateSyncing on peer quit (ethersphere#1696)
  all: first working SWAP version (ethersphere#1554)
  version: update to v0.5.0 unstable (ethersphere#1694)
  chunk, storage: storage with multi chunk Set method (ethersphere#1684)
  chunk, storage: add HasMulti to chunk.Store (ethersphere#1686)
  chunk, shed, storage: chunk.Store GetMulti method (ethersphere#1691)
  api, chunk: progress bar support (ethersphere#1649)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants