diff options
author | obscuren <geffobscura@gmail.com> | 2014-12-10 21:17:32 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-12-10 21:17:32 +0800 |
commit | dda778eda7ad9b94acf14c3c91c1c29e711e170f (patch) | |
tree | dfbb71a45399455fd2c2bb77ce72c8ce9d79ba45 /whisper/whisper.go | |
parent | 0f5c6c5e2daa9fbf3a0bb753debd8989a872823c (diff) | |
download | dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.tar dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.tar.gz dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.tar.bz2 dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.tar.lz dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.tar.xz dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.tar.zst dexon-dda778eda7ad9b94acf14c3c91c1c29e711e170f.zip |
Updated whisper messages to new crypto api + added tests
Diffstat (limited to 'whisper/whisper.go')
-rw-r--r-- | whisper/whisper.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/whisper/whisper.go b/whisper/whisper.go index b4e37b959..4d7a2a23e 100644 --- a/whisper/whisper.go +++ b/whisper/whisper.go @@ -2,11 +2,13 @@ package whisper import ( "bytes" + "crypto/ecdsa" "errors" "fmt" "sync" "time" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/p2p" "gopkg.in/fatih/set.v0" ) @@ -39,7 +41,7 @@ const ( const DefaultTtl = 50 * time.Second type Whisper struct { - pub, sec []byte + key *ecdsa.PrivateKey protocol p2p.Protocol mmu sync.RWMutex @@ -49,10 +51,9 @@ type Whisper struct { quit chan struct{} } -func New(pub, sec []byte) *Whisper { +func New(sec []byte) *Whisper { whisper := &Whisper{ - pub: pub, - sec: sec, + key: crypto.ToECDSA(sec), messages: make(map[Hash]*Envelope), expiry: make(map[uint32]*set.SetNonTS), quit: make(chan struct{}), |