trie, whisper/whisperv5: use math/rand Read function
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user