trie, whisper/whisperv5: use math/rand Read function

This commit is contained in:
Felix Lange
2017-03-22 19:48:51 +01:00
parent 9a2720fb35
commit f1534f5797
5 changed files with 23 additions and 54 deletions

View File

@@ -128,7 +128,7 @@ func (msg *SentMessage) appendPadding(params *MessageParams) {
panic("please fix the padding algorithm before releasing new version")
}
buf := make([]byte, padSize)
randomize(buf[1:])
mrand.Read(buf[1:])
buf[0] = byte(padSize)
if params.Padding != nil {
copy(buf[1:], params.Padding)
@@ -365,19 +365,3 @@ func (msg *ReceivedMessage) hash() []byte {
}
return crypto.Keccak256(msg.Raw)
}
// rand.Rand provides a Read method in Go 1.7 and later,
// but we can't use it yet.
func randomize(b []byte) {
cnt := 0
val := mrand.Int63()
for n := 0; n < len(b); n++ {
b[n] = byte(val)
val >>= 8
cnt++
if cnt >= 7 {
cnt = 0
val = mrand.Int63()
}
}
}