whisperv6

package
v0.0.0-...-99821d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

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)")
)

List of errors

Functions

This section is empty.

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"`
}

Criteria holds various filter options for inbound messages.

type Info

type Info struct {
	Memory         int     `json:"memory"`         // Memory size of the floating messages in bytes.
	Messages       int     `json:"messages"`       // Number of floating messages.
	MinPow         float64 `json:"minPow"`         // Minimal accepted PoW
	MaxMessageSize uint32  `json:"maxMessageSize"` // Maximum accepted message size
}

Info contains diagnostic information.

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"`
}

Message is the RPC representation of a whisper message.

func ToWhisperMessage

func ToWhisperMessage(message *ReceivedMessage) *Message

ToWhisperMessage converts an internal message into an API version.

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"`
}

NewMessage represents a new whisper message that is posted through the RPC.

type PublicWhisperAPI

type PublicWhisperAPI struct {
	// contains filtered or unexported fields
}

PublicWhisperAPI provides the whisper RPC service that can be use publicly without security implications.

func NewPublicWhisperAPI

func NewPublicWhisperAPI(w *Whisper) *PublicWhisperAPI

NewPublicWhisperAPI create a new RPC whisper service.

func (*PublicWhisperAPI) AddPrivateKey

func (api *PublicWhisperAPI) AddPrivateKey(ctx context.Context, privateKey hexutil.Bytes) (string, error)

AddPrivateKey imports the given private key.

func (*PublicWhisperAPI) AddSymKey

func (api *PublicWhisperAPI) AddSymKey(ctx context.Context, key hexutil.Bytes) (string, error)

AddSymKey import a symmetric key. It returns an ID that can be used to refer to the key. Can be used encrypting and decrypting messages where the key is known to both parties.

func (*PublicWhisperAPI) CancelLightClient

func (api *PublicWhisperAPI) CancelLightClient(ctx context.Context) bool

CancelLightClient cancels light client mode.

func (*PublicWhisperAPI) DeleteKeyPair

func (api *PublicWhisperAPI) DeleteKeyPair(ctx context.Context, key string) (bool, error)

DeleteKeyPair removes the key with the given key if it exists.

func (*PublicWhisperAPI) DeleteMessageFilter

func (api *PublicWhisperAPI) DeleteMessageFilter(id string) (bool, error)

DeleteMessageFilter deletes a filter.

func (*PublicWhisperAPI) DeleteSymKey

func (api *PublicWhisperAPI) DeleteSymKey(ctx context.Context, id string) bool

DeleteSymKey deletes the symmetric key that is associated with the given id.

func (*PublicWhisperAPI) GenerateSymKeyFromPassword

func (api *PublicWhisperAPI) GenerateSymKeyFromPassword(ctx context.Context, passwd string) (string, error)

GenerateSymKeyFromPassword derive a key from the given password, stores it, and returns its ID.

func (*PublicWhisperAPI) GetFilterMessages

func (api *PublicWhisperAPI) GetFilterMessages(id string) ([]*Message, error)

GetFilterMessages returns the messages that match the filter criteria and are received between the last poll and now.

func (*PublicWhisperAPI) GetPrivateKey

func (api *PublicWhisperAPI) GetPrivateKey(ctx context.Context, id string) (hexutil.Bytes, error)

GetPrivateKey returns the private key associated with the given key. The key is the hex encoded representation of a key in the form specified in section 4.3.6 of ANSI X9.62.

func (*PublicWhisperAPI) GetPublicKey

func (api *PublicWhisperAPI) GetPublicKey(ctx context.Context, id string) (hexutil.Bytes, error)

GetPublicKey returns the public key associated with the given key. The key is the hex encoded representation of a key in the form specified in section 4.3.6 of ANSI X9.62.

func (*PublicWhisperAPI) GetSymKey

func (api *PublicWhisperAPI) GetSymKey(ctx context.Context, id string) (hexutil.Bytes, error)

GetSymKey returns the symmetric key associated with the given id.

func (*PublicWhisperAPI) HasKeyPair

func (api *PublicWhisperAPI) HasKeyPair(ctx context.Context, id string) bool

HasKeyPair returns an indication if the node has a key pair that is associated with the given id.

func (*PublicWhisperAPI) HasSymKey

func (api *PublicWhisperAPI) HasSymKey(ctx context.Context, id string) bool

HasSymKey returns an indication if the node has a symmetric key associated with the given key.

func (*PublicWhisperAPI) Info

func (api *PublicWhisperAPI) Info(ctx context.Context) Info

Info returns diagnostic information about the whisper node.

func (*PublicWhisperAPI) MakeLightClient

func (api *PublicWhisperAPI) MakeLightClient(ctx context.Context) bool

MakeLightClient turns the node into light client, which does not forward any incoming messages, and sends only messages originated in this node.

func (*PublicWhisperAPI) MarkTrustedPeer

func (api *PublicWhisperAPI) MarkTrustedPeer(ctx context.Context, url string) (bool, error)

MarkTrustedPeer marks a peer trusted, which will allow it to send historic (expired) messages. Note: This function is not adding new nodes, the node needs to exists as a peer.

func (*PublicWhisperAPI) Messages

func (api *PublicWhisperAPI) Messages(ctx context.Context, crit Criteria) (*rpc.Subscription, error)

Messages set up a subscription that fires events when messages arrive that match the given set of criteria.

func (*PublicWhisperAPI) NewKeyPair

func (api *PublicWhisperAPI) NewKeyPair(ctx context.Context) (string, error)

NewKeyPair generates a new public and private key pair for message decryption and encryption. It returns an ID that can be used to refer to the keypair.

func (*PublicWhisperAPI) NewMessageFilter

func (api *PublicWhisperAPI) NewMessageFilter(req Criteria) (string, error)

NewMessageFilter creates a new filter that can be used to poll for (new) messages that satisfy the given criteria.

func (*PublicWhisperAPI) NewSymKey

func (api *PublicWhisperAPI) NewSymKey(ctx context.Context) (string, error)

NewSymKey generate a random symmetric key. It returns an ID that can be used to refer to the key. Can be used encrypting and decrypting messages where the key is known to both parties.

func (*PublicWhisperAPI) Post

func (api *PublicWhisperAPI) Post(ctx context.Context, req NewMessage) (hexutil.Bytes, error)

Post posts a message on the Whisper network. returns the hash of the message in case of success.

func (*PublicWhisperAPI) SetBloomFilter

func (api *PublicWhisperAPI) SetBloomFilter(ctx context.Context, bloom hexutil.Bytes) (bool, error)

SetBloomFilter sets the new value of bloom filter, and notifies the peers.

func (*PublicWhisperAPI) SetMaxMessageSize

func (api *PublicWhisperAPI) SetMaxMessageSize(ctx context.Context, size uint32) (bool, error)

SetMaxMessageSize sets the maximum message size that is accepted. Upper limit is defined by MaxMessageSize.

func (*PublicWhisperAPI) SetMinPoW

func (api *PublicWhisperAPI) SetMinPoW(ctx context.Context, pow float64) (bool, error)

SetMinPoW sets the minimum PoW, and notifies the peers.

func (*PublicWhisperAPI) Version

func (api *PublicWhisperAPI) Version(ctx context.Context) string

Version returns the Whisper sub-protocol version.

Directories

Path Synopsis
Package whisperv5 implements the Whisper protocol (version 5).
Package whisperv5 implements the Whisper protocol (version 5).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL