Documentation ¶
Index ¶
- Constants
- Variables
- func BytesToUintBigEndian(b []byte) (res uint64)
- func GenerateRandomID() (id string, err error)
- func IsPubKeyEqual(a, b *ecdsa.PublicKey) bool
- func NewSentMessage(params *MessageParams) (*sentMessage, error)
- func ValidatePublicKey(k *ecdsa.PublicKey) bool
- type Config
- type Criteria
- type Envelope
- func (e *Envelope) DecodeRLP(s *rlp.Stream) error
- func (e *Envelope) Hash() common.Hash
- func (e *Envelope) IsSymmetric() bool
- 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
- func (e *Envelope) Ver() uint64
- 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) 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) 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) (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 (w *Whisper) APIs() []rpc.API
- func (w *Whisper) AddKeyPair(key *ecdsa.PrivateKey) (string, error)
- func (w *Whisper) AddSymKeyDirect(key []byte) (string, error)
- func (w *Whisper) AddSymKeyFromPassword(password string) (string, error)
- func (w *Whisper) AllowP2PMessagesFromPeer(peerID []byte) error
- func (w *Whisper) DeleteKeyPair(key string) bool
- func (w *Whisper) DeleteSymKey(id string) bool
- func (w *Whisper) Envelopes() []*Envelope
- func (w *Whisper) GenerateSymKey() (string, error)
- func (w *Whisper) GetFilter(id string) *Filter
- func (w *Whisper) GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
- func (w *Whisper) GetSymKey(id string) ([]byte, error)
- func (w *Whisper) HandlePeer(peer *p2p.Peer, rw p2p.MsgReadWriter) error
- func (w *Whisper) HasKeyPair(id string) bool
- func (w *Whisper) HasSymKey(id string) bool
- func (w *Whisper) MaxMessageSize() uint32
- func (w *Whisper) Messages(id string) []*ReceivedMessage
- func (w *Whisper) MinPow() float64
- func (w *Whisper) NewKeyPair() (string, error)
- func (w *Whisper) Overflow() bool
- func (w *Whisper) Protocols() []p2p.Protocol
- func (w *Whisper) RegisterServer(server MailServer)
- func (w *Whisper) RequestHistoricMessages(peerID []byte, envelope *Envelope) error
- func (w *Whisper) Send(envelope *Envelope) error
- func (w *Whisper) SendP2PDirect(peer *Peer, envelope *Envelope) error
- func (w *Whisper) SendP2PMessage(peerID []byte, envelope *Envelope) error
- func (w *Whisper) SetMaxMessageSize(size uint32) error
- func (w *Whisper) SetMinimumPoW(val float64) error
- func (w *Whisper) Start(*p2p.Server) error
- func (w *Whisper) Stats() Statistics
- func (w *Whisper) Stop() error
- func (w *Whisper) Subscribe(f *Filter) (string, error)
- func (w *Whisper) Unsubscribe(id string) error
- func (w *Whisper) Version() uint
Constants ¶
View Source
const ( EnvelopeVersion = uint64(0) ProtocolVersion = uint64(5) ProtocolVersionStr = "5.0" ProtocolName = "shh" NumberOfMessageCodes = 64 TopicLength = 4 AESNonceLength = 12 MaxMessageSize = uint32(10 * 1024 * 1024) // DefaultMaxMessageSize = uint32(1024 * 1024) DefaultMinimumPoW = 0.2 DefaultTTL = 50 // SynchAllowance = 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 BytesToUintBigEndian ¶
func GenerateRandomID ¶
func IsPubKeyEqual ¶
func NewSentMessage ¶
func NewSentMessage(params *MessageParams) (*sentMessage, error)
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 { Version []byte Expiry uint32 TTL uint32 Topic TopicType AESNonce []byte Data []byte EnvNonce uint64 // contains filtered or unexported fields }
func NewEnvelope ¶
func (*Envelope) IsSymmetric ¶
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) MatchTopic ¶
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) 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) 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) (bool, error)
func (*PublicWhisperAPI) SetMaxMessageSize ¶
type ReceivedMessage ¶
type ReceivedMessage struct { Raw []byte Payload []byte Padding []byte Signature []byte PoW float64 // Sent uint32 // TTL uint32 // Src *ecdsa.PublicKey // Dst *ecdsa.PublicKey // Topic TopicType SymKeyHash common.Hash // EnvelopeHash common.Hash // EnvelopeVersion uint64 }
func (*ReceivedMessage) SigToPubKey ¶
func (msg *ReceivedMessage) SigToPubKey() *ecdsa.PublicKey
func (*ReceivedMessage) Validate ¶
func (msg *ReceivedMessage) Validate() 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 (w *Whisper) AddKeyPair(key *ecdsa.PrivateKey) (string, error)
func (*Whisper) AddSymKeyFromPassword ¶
func (*Whisper) AllowP2PMessagesFromPeer ¶
func (*Whisper) DeleteKeyPair ¶
func (*Whisper) DeleteSymKey ¶
func (*Whisper) GenerateSymKey ¶
func (*Whisper) GetPrivateKey ¶
func (w *Whisper) GetPrivateKey(id string) (*ecdsa.PrivateKey, error)
func (*Whisper) HandlePeer ¶
func (*Whisper) HasKeyPair ¶
func (*Whisper) MaxMessageSize ¶
func (*Whisper) Messages ¶
func (w *Whisper) Messages(id string) []*ReceivedMessage
func (*Whisper) NewKeyPair ¶
func (*Whisper) RegisterServer ¶
func (w *Whisper) RegisterServer(server MailServer)
func (*Whisper) RequestHistoricMessages ¶
func (*Whisper) SendP2PDirect ¶
func (*Whisper) SendP2PMessage ¶
func (*Whisper) SetMaxMessageSize ¶
func (*Whisper) SetMinimumPoW ¶
func (*Whisper) Stats ¶
func (w *Whisper) Stats() Statistics
func (*Whisper) Unsubscribe ¶
Click to show internal directories.
Click to hide internal directories.