mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
whisper5: minor update
This commit is contained in:
parent
c2eced014d
commit
d14292e0ed
2 changed files with 8 additions and 3 deletions
|
|
@ -58,4 +58,7 @@ const (
|
||||||
DefaultPoW = 50 * time.Millisecond
|
DefaultPoW = 50 * time.Millisecond
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Topic represents a cryptographically secure, probabilistic partial
|
||||||
|
// classifications of a message, determined as the first (left) 4 bytes of the
|
||||||
|
// SHA3 hash of some arbitrary data given by the original author of the message.
|
||||||
type TopicType [4]byte
|
type TopicType [4]byte
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ package whisper5
|
||||||
import (
|
import (
|
||||||
crand "crypto/rand"
|
crand "crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
mrand "math/rand"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"crypto/aes"
|
"crypto/aes"
|
||||||
|
|
@ -126,7 +125,10 @@ func (self *Message) Padding() []byte {
|
||||||
// NewMessage creates and initializes a non-signed, non-encrypted Whisper message.
|
// NewMessage creates and initializes a non-signed, non-encrypted Whisper message.
|
||||||
func NewMessage(payload []byte) *Message {
|
func NewMessage(payload []byte) *Message {
|
||||||
// Construct an initial flag set: no signature, no padding, other bits random
|
// Construct an initial flag set: no signature, no padding, other bits random
|
||||||
flags := byte(mrand.Intn(256))
|
buf := make([]byte, 1)
|
||||||
|
crand.Read(buf)
|
||||||
|
|
||||||
|
flags := buf[0]
|
||||||
flags &= ^signatureFlag
|
flags &= ^signatureFlag
|
||||||
flags &= ^paddingFlag
|
flags &= ^paddingFlag
|
||||||
|
|
||||||
|
|
@ -158,7 +160,7 @@ func (self *Message) appendPadding(options Options) {
|
||||||
if odd > 0 {
|
if odd > 0 {
|
||||||
padSize := maxPadLength - odd
|
padSize := maxPadLength - odd
|
||||||
buf := make([]byte, padSize)
|
buf := make([]byte, padSize)
|
||||||
mrand.Read(buf)
|
crand.Read(buf)
|
||||||
if options.Pad != nil {
|
if options.Pad != nil {
|
||||||
copy(buf, options.Pad)
|
copy(buf, options.Pad)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue