Documentation ¶
Index ¶
- Constants
- Variables
- func BloomFilterMatch(filter, sample []byte) bool
- func BytesToUintBigEndian(b []byte) (res uint64)
- func GenerateRandomID() (id string, err error)
- func IsPubKeyEqual(a, b *ecdsa.PublicKey) bool
- func MakeFullNodeBloom() []byte
- func NewSentMessage(params *MessageParams) (*sentMessage, error)
- func TopicToBloom(topic TopicType) []byte
- func ValidatePublicKey(k *ecdsa.PublicKey) bool
- type Config
- type Criteria
- type Envelope
- func (e *Envelope) Bloom() []byte
- func (e *Envelope) DecodeRLP(s *rlp.Stream) error
- func (e *Envelope) Hash() common.Hash
- func (e *Envelope) Open(watcher *Filter) (msg *ReceivedMessage)
- func (e *Envelope) OpenAsymmetric(key *ecdsa.PrivateKey) (*ReceivedMessage, error)
- func (e *Envelope) OpenSymmetric(key []byte) (msg *ReceivedMessage, err error)
- func (e *Envelope) PoW() float64
- func (e *Envelope) Seal(options *MessageParams) error
- type Filter
- type Filters
- type Info
- type MailServer
- type Message
- type MessageParams
- type NewMessage
- type Peer
- type PublicWhisperAPI
- func (api *PublicWhisperAPI) AddPrivateKey(ctx context.Context, privateKey hexutil.Bytes) (string, error)
- func (api *PublicWhisperAPI) AddSymKey(ctx context.Context, key hexutil.Bytes) (string, error)
- func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool
- func (api *PublicWhisperAPI) DeleteKeyPair(ctx context.Context, key string) (bool, error)
- func (api *PublicWhisperAPI) DeleteMessageFilter(id string) (bool, error)
- func (api *PublicWhisperAPI) DeleteSymKey(ctx context.Context, id string) bool
- func (api *PublicWhisperAPI) GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)
- func (api *PublicWhisperAPI) GetFilterMessages(id string) ([]*Message, error)
- func (api *PublicWhisperAPI) GetPrivateKey(ctx context.Context, id string) (hexutil.Bytes, error)
- func (api *PublicWhisperAPI) GetPublicKey(ctx context.Context, id string) (hexutil.Bytes, error)
- func (api *PublicWhisperAPI) GetSymKey(ctx context.Context, id string) (hexutil.Bytes, error)
- func (api *PublicWhisperAPI) HasKeyPair(ctx context.Context, id string) bool
- func (api *PublicWhisperAPI) HasSymKey(ctx context.Context, id string) bool
- func (api *PublicWhisperAPI) Info(ctx context.Context) Info
- func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool
- func (api *PublicWhisperAPI) MarkTrustedPeer(ctx context.Context, enode string) (bool, error)
- func (api *PublicWhisperAPI) Messages(ctx context.Context, crit Criteria) (*rpc.Subscription, error)
- func (api *PublicWhisperAPI) NewKeyPair(ctx context.Context) (string, error)
- func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error)
- func (api *PublicWhisperAPI) NewSymKey(ctx context.Context) (string, error)
- func (api *PublicWhisperAPI) Post(ctx context.Context, req NewMessage) (hexutil.Bytes, error)
- func (api *PublicWhisperAPI) SetBloomFilter(ctx context.Context, bloom hexutil.Bytes) (bool, error)
- func (api *PublicWhisperAPI) SetMaxMessageSize(ctx context.Context, size uint32) (bool, error)
- func (api *PublicWhisperAPI) SetMinPoW(ctx context.Context, pow float64) (bool, error)
- func (api *PublicWhisperAPI) Version(ctx context.Context) string
- type ReceivedMessage
- type Statistics
- type TopicType
- type Whisper
- func (whisper *Whisper) APIs() []rpc.API
- func (whisper *Whisper) AddKeyPair(key *ecdsa.PrivateKey) (string, error)
- func (whisper *Whisper) AddSymKeyDirect(key []byte) (string, error)
- func (whisper *Whisper) AddSymKeyFromPassword(password string) (string, error)
- func (whisper *Whisper) AllowP2PMessagesFromPeer(peerID []byte) error
- func (whisper *Whisper) BloomFilter() []byte
- func (whisper *Whisper) BloomFilterTolerance() []byte
- func (whisper *Whisper) DeleteKeyPair(key string) bool
- func (whisper *Whisper) DeleteSymKey(id string) bool
- func (whisper *Whisper) Envelopes() []*Envelope
- func (whisper *Whisper) GenerateSymKey() (string, error)
- func (w *Whisper) GetEnvelope(hash common.Hash) *Envelope
- func (whisper *Whisper) GetFilter(id string) *Filter
- func (whisper *Whisper) GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
- func (whisper *Whisper) GetSymKey(id string) ([]byte, error)
- func (whisper *Whisper) HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error
- func (whisper *Whisper) HasKeyPair(id string) bool
- func (whisper *Whisper) HasSymKey(id string) bool
- func (whisper *Whisper) MaxMessageSize() uint32
- func (whisper *Whisper) MinPow() float64
- func (whisper *Whisper) MinPowTolerance() float64
- func (whisper *Whisper) NewKeyPair() (string, error)
- func (whisper *Whisper) Overflow() bool
- func (whisper *Whisper) Protocols() []p2p.Protocol
- func (whisper *Whisper) RegisterServer(server MailServer)
- func (whisper *Whisper) RequestHistoricMessages(peerID []byte, envelope *Envelope) error
- func (whisper *Whisper) Send(envelope *Envelope) error
- func (whisper *Whisper) SendP2PDirect(peer *Peer, envelope *Envelope) error
- func (whisper *Whisper) SendP2PMessage(peerID []byte, envelope *Envelope) error
- func (whisper *Whisper) SetBloomFilter(bloom []byte) error
- func (whisper *Whisper) SetMaxMessageSize(size uint32) error
- func (whisper *Whisper) SetMinimumPoW(val float64) error
- func (whisper *Whisper) SetMinimumPowTest(val float64)
- func (whisper *Whisper) Start(*p2p.Server) error
- func (whisper *Whisper) Stats() Statistics
- func (whisper *Whisper) Stop() error
- func (whisper *Whisper) Subscribe(f *Filter) (string, error)
- func (whisper *Whisper) Unsubscribe(id string) error
- func (whisper *Whisper) Version() uint
Constants ¶
View Source
const ( ProtocolVersion = uint64(6) // ProtocolVersionStr = "6.0" // ProtocolName = "shh" // NumberOfMessageCodes = 128 SizeMask = byte(3) // TopicLength = 4 // BloomFilterSize = 64 // EnvelopeHeaderLength = 20 MaxMessageSize = uint32(10 * 1024 * 1024) // DefaultMaxMessageSize = uint32(1024 * 1024) DefaultMinimumPoW = 0.2 DefaultTTL = 50 // DefaultSyncAllowance = 10 // )
Variables ¶
View Source
var ( ErrSymAsym = errors.New("specify either a symmetric or an asymmetric key") ErrInvalidSymmetricKey = errors.New("invalid symmetric key") ErrInvalidPublicKey = errors.New("invalid public key") ErrInvalidSigningPubKey = errors.New("invalid signing public key") ErrTooLowPoW = errors.New("message rejected, PoW too low") ErrNoTopics = errors.New("missing topic(s)") )
View Source
var DefaultConfig = Config{ MaxMessageSize: DefaultMaxMessageSize, MinimumAcceptedPOW: DefaultMinimumPoW, }
Functions ¶
func BloomFilterMatch ¶
func BytesToUintBigEndian ¶
func GenerateRandomID ¶
func IsPubKeyEqual ¶
func MakeFullNodeBloom ¶
func MakeFullNodeBloom() []byte
func NewSentMessage ¶
func NewSentMessage(params *MessageParams) (*sentMessage, error)
func TopicToBloom ¶
func ValidatePublicKey ¶
Types ¶
type Criteria ¶
type Criteria struct { SymKeyID string `json:"symKeyID"` PrivateKeyID string `json:"privateKeyID"` Sig []byte `json:"sig"` MinPow float64 `json:"minPow"` Topics []TopicType `json:"topics"` AllowP2P bool `json:"allowP2P"` }
func (Criteria) MarshalJSON ¶
func (*Criteria) UnmarshalJSON ¶
type Envelope ¶
type Envelope struct { Expiry uint32 TTL uint32 Topic TopicType Data []byte Nonce uint64 // contains filtered or unexported fields }
func NewEnvelope ¶
func (*Envelope) Open ¶
func (e *Envelope) Open(watcher *Filter) (msg *ReceivedMessage)
func (*Envelope) OpenAsymmetric ¶
func (e *Envelope) OpenAsymmetric(key *ecdsa.PrivateKey) (*ReceivedMessage, error)
func (*Envelope) OpenSymmetric ¶
func (e *Envelope) OpenSymmetric(key []byte) (msg *ReceivedMessage, err error)
func (*Envelope) Seal ¶
func (e *Envelope) Seal(options *MessageParams) error
type Filter ¶
type Filter struct { Src *ecdsa.PublicKey // KeyAsym *ecdsa.PrivateKey // KeySym []byte // Topics [][]byte // PoW float64 // AllowP2P bool // SymKeyHash common.Hash // Messages map[common.Hash]*ReceivedMessage // contains filtered or unexported fields }
func (*Filter) MatchEnvelope ¶
func (*Filter) MatchMessage ¶
func (f *Filter) MatchMessage(msg *ReceivedMessage) bool
func (*Filter) Retrieve ¶
func (f *Filter) Retrieve() (all []*ReceivedMessage)
func (*Filter) Trigger ¶
func (f *Filter) Trigger(msg *ReceivedMessage)
type Filters ¶
type Filters struct {
// contains filtered or unexported fields
}
func NewFilters ¶
func (*Filters) NotifyWatchers ¶
type MailServer ¶
type Message ¶
type Message struct { Sig []byte `json:"sig,omitempty"` TTL uint32 `json:"ttl"` Timestamp uint32 `json:"timestamp"` Topic TopicType `json:"topic"` Payload []byte `json:"payload"` Padding []byte `json:"padding"` PoW float64 `json:"pow"` Hash []byte `json:"hash"` Dst []byte `json:"recipientPublicKey,omitempty"` }
func ToWhisperMessage ¶
func ToWhisperMessage(message *ReceivedMessage) *Message
func (Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type MessageParams ¶
type NewMessage ¶
type NewMessage struct { SymKeyID string `json:"symKeyID"` PublicKey []byte `json:"pubKey"` Sig string `json:"sig"` TTL uint32 `json:"ttl"` Topic TopicType `json:"topic"` Payload []byte `json:"payload"` Padding []byte `json:"padding"` PowTime uint32 `json:"powTime"` PowTarget float64 `json:"powTarget"` TargetPeer string `json:"targetPeer"` }
func (NewMessage) MarshalJSON ¶
func (n NewMessage) MarshalJSON() ([]byte, error)
func (*NewMessage) UnmarshalJSON ¶
func (n *NewMessage) UnmarshalJSON(input []byte) error
type PublicWhisperAPI ¶
type PublicWhisperAPI struct {
// contains filtered or unexported fields
}
func NewPublicWhisperAPI ¶
func NewPublicWhisperAPI(w *Whisper) *PublicWhisperAPI
func (*PublicWhisperAPI) AddPrivateKey ¶
func (*PublicWhisperAPI) CancelLightClient ¶
func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool
func (*PublicWhisperAPI) DeleteKeyPair ¶
func (*PublicWhisperAPI) DeleteMessageFilter ¶
func (api *PublicWhisperAPI) DeleteMessageFilter(id string) (bool, error)
func (*PublicWhisperAPI) DeleteSymKey ¶
func (api *PublicWhisperAPI) DeleteSymKey(ctx context.Context, id string) bool
func (*PublicWhisperAPI) GenerateSymKeyFromPassword ¶
func (*PublicWhisperAPI) GetFilterMessages ¶
func (api *PublicWhisperAPI) GetFilterMessages(id string) ([]*Message, error)
func (*PublicWhisperAPI) GetPrivateKey ¶
func (*PublicWhisperAPI) GetPublicKey ¶
func (*PublicWhisperAPI) HasKeyPair ¶
func (api *PublicWhisperAPI) HasKeyPair(ctx context.Context, id string) bool
func (*PublicWhisperAPI) HasSymKey ¶
func (api *PublicWhisperAPI) HasSymKey(ctx context.Context, id string) bool
func (*PublicWhisperAPI) MakeLightClient ¶
func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool
func (*PublicWhisperAPI) MarkTrustedPeer ¶
func (*PublicWhisperAPI) Messages ¶
func (api *PublicWhisperAPI) Messages(ctx context.Context, crit Criteria) (*rpc.Subscription, error)
func (*PublicWhisperAPI) NewKeyPair ¶
func (api *PublicWhisperAPI) NewKeyPair(ctx context.Context) (string, error)
func (*PublicWhisperAPI) NewMessageFilter ¶
func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error)
func (*PublicWhisperAPI) NewSymKey ¶
func (api *PublicWhisperAPI) NewSymKey(ctx context.Context) (string, error)
func (*PublicWhisperAPI) Post ¶
func (api *PublicWhisperAPI) Post(ctx context.Context, req NewMessage) (hexutil.Bytes, error)
func (*PublicWhisperAPI) SetBloomFilter ¶
func (*PublicWhisperAPI) SetMaxMessageSize ¶
type ReceivedMessage ¶
type ReceivedMessage struct { Raw []byte Payload []byte Padding []byte Signature []byte Salt []byte PoW float64 // Sent uint32 // TTL uint32 // Src *ecdsa.PublicKey // Dst *ecdsa.PublicKey // Topic TopicType SymKeyHash common.Hash // EnvelopeHash common.Hash // }
func (*ReceivedMessage) SigToPubKey ¶
func (msg *ReceivedMessage) SigToPubKey() *ecdsa.PublicKey
func (*ReceivedMessage) ValidateAndParse ¶
func (msg *ReceivedMessage) ValidateAndParse() bool
type Statistics ¶
type Statistics struct {
// contains filtered or unexported fields
}
type TopicType ¶
type TopicType [TopicLength]byte
func BytesToTopic ¶
func (TopicType) MarshalText ¶
func (*TopicType) UnmarshalText ¶
type Whisper ¶
type Whisper struct {
// contains filtered or unexported fields
}
func (*Whisper) AddKeyPair ¶
func (whisper *Whisper) AddKeyPair(key *ecdsa.PrivateKey) (string, error)
func (*Whisper) AddSymKeyDirect ¶
func (*Whisper) AddSymKeyFromPassword ¶
func (*Whisper) AllowP2PMessagesFromPeer ¶
func (*Whisper) BloomFilter ¶
func (*Whisper) BloomFilterTolerance ¶
func (*Whisper) DeleteKeyPair ¶
func (*Whisper) DeleteSymKey ¶
func (*Whisper) GenerateSymKey ¶
func (*Whisper) GetPrivateKey ¶
func (whisper *Whisper) GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
func (*Whisper) HandlePeer ¶
func (*Whisper) HasKeyPair ¶
func (*Whisper) MaxMessageSize ¶
func (*Whisper) MinPowTolerance ¶
func (*Whisper) NewKeyPair ¶
func (*Whisper) RegisterServer ¶
func (whisper *Whisper) RegisterServer(server MailServer)
func (*Whisper) RequestHistoricMessages ¶
func (*Whisper) SendP2PDirect ¶
func (*Whisper) SendP2PMessage ¶
func (*Whisper) SetBloomFilter ¶
func (*Whisper) SetMaxMessageSize ¶
func (*Whisper) SetMinimumPoW ¶
func (*Whisper) SetMinimumPowTest ¶
func (*Whisper) Stats ¶
func (whisper *Whisper) Stats() Statistics
func (*Whisper) Unsubscribe ¶
Click to show internal directories.
Click to hide internal directories.