Documentation ¶
Index ¶
- Constants
- Variables
- func DecodePubKeySignature(r io.Reader) (signature []byte, err error)
- func EncodePubKeySignature(w io.Writer, signature []byte) (err error)
- func InventoryHash(obj Object) *hash.Sha
- type Broadcast
- type EncryptedPubKey
- func (p *EncryptedPubKey) Command() string
- func (p *EncryptedPubKey) Decode(r io.Reader) error
- func (p *EncryptedPubKey) Encode(w io.Writer) error
- func (p *EncryptedPubKey) Header() *wire.ObjectHeader
- func (p *EncryptedPubKey) MaxPayloadLength() int
- func (p *EncryptedPubKey) MsgObject() *wire.MsgObject
- func (p *EncryptedPubKey) Payload() []byte
- func (p *EncryptedPubKey) String() string
- type ExtendedPubKey
- func (p *ExtendedPubKey) Behavior() uint32
- func (p *ExtendedPubKey) Command() string
- func (p *ExtendedPubKey) Data() *PubKeyData
- func (p *ExtendedPubKey) Decode(r io.Reader) error
- func (p *ExtendedPubKey) Encode(w io.Writer) error
- func (p *ExtendedPubKey) EncodeForSigning(w io.Writer) error
- func (p *ExtendedPubKey) EncryptionKey() *wire.PubKey
- func (p *ExtendedPubKey) Header() *wire.ObjectHeader
- func (p *ExtendedPubKey) MaxPayloadLength() int
- func (p *ExtendedPubKey) MsgObject() *wire.MsgObject
- func (p *ExtendedPubKey) Object() Object
- func (p *ExtendedPubKey) Payload() []byte
- func (p *ExtendedPubKey) Pow() *pow.Data
- func (p *ExtendedPubKey) String() string
- func (p *ExtendedPubKey) Tag() *hash.Sha
- func (p *ExtendedPubKey) VerificationKey() *wire.PubKey
- type GetPubKey
- func (msg *GetPubKey) Command() string
- func (msg *GetPubKey) Decode(r io.Reader) error
- func (msg *GetPubKey) Encode(w io.Writer) error
- func (msg *GetPubKey) Header() *wire.ObjectHeader
- func (msg *GetPubKey) MaxPayloadLength() int
- func (msg *GetPubKey) MsgObject() *wire.MsgObject
- func (msg *GetPubKey) Payload() []byte
- func (msg *GetPubKey) String() string
- type Message
- func (msg *Message) Command() string
- func (msg *Message) Decode(r io.Reader) error
- func (msg *Message) Encode(w io.Writer) error
- func (msg *Message) Header() *wire.ObjectHeader
- func (msg *Message) MaxPayloadLength() int
- func (msg *Message) MsgObject() *wire.MsgObject
- func (msg *Message) Payload() []byte
- func (msg *Message) String() string
- type Object
- type PubKeyData
- type SimplePubKey
- func (p *SimplePubKey) Behavior() uint32
- func (p *SimplePubKey) Command() string
- func (p *SimplePubKey) Data() *PubKeyData
- func (p *SimplePubKey) Decode(r io.Reader) error
- func (p *SimplePubKey) Encode(w io.Writer) error
- func (p *SimplePubKey) EncryptionKey() *wire.PubKey
- func (p *SimplePubKey) Header() *wire.ObjectHeader
- func (p *SimplePubKey) MaxPayloadLength() int
- func (p *SimplePubKey) MsgObject() *wire.MsgObject
- func (p *SimplePubKey) Object() Object
- func (p *SimplePubKey) Payload() []byte
- func (p *SimplePubKey) Pow() *pow.Data
- func (p *SimplePubKey) String() string
- func (p *SimplePubKey) Tag() *hash.Sha
- func (p *SimplePubKey) VerificationKey() *wire.PubKey
- type TaggedBroadcast
- func (msg *TaggedBroadcast) Command() string
- func (msg *TaggedBroadcast) Decode(r io.Reader) error
- func (msg *TaggedBroadcast) Encode(w io.Writer) error
- func (msg *TaggedBroadcast) EncodeForSigning(w io.Writer) error
- func (msg *TaggedBroadcast) Encrypted() []byte
- func (msg *TaggedBroadcast) Header() *wire.ObjectHeader
- func (msg *TaggedBroadcast) MaxPayloadLength() int
- func (msg *TaggedBroadcast) MsgObject() *wire.MsgObject
- func (msg *TaggedBroadcast) Payload() []byte
- func (msg *TaggedBroadcast) String() string
- type TaglessBroadcast
- func (msg *TaglessBroadcast) Command() string
- func (msg *TaglessBroadcast) Decode(r io.Reader) error
- func (msg *TaglessBroadcast) Encode(w io.Writer) error
- func (msg *TaglessBroadcast) EncodeForSigning(w io.Writer) error
- func (msg *TaglessBroadcast) Encrypted() []byte
- func (msg *TaglessBroadcast) Header() *wire.ObjectHeader
- func (msg *TaglessBroadcast) MaxPayloadLength() int
- func (msg *TaglessBroadcast) MsgObject() *wire.MsgObject
- func (msg *TaglessBroadcast) Payload() []byte
- func (msg *TaglessBroadcast) String() string
Constants ¶
const ( // TaglessBroadcastVersion is the broadcast version which does not contain // a tag. TaglessBroadcastVersion = 4 // TaggedBroadcastVersion is the broadcast version from which tags for light // clients started being added at the beginning of the broadcast message. TaggedBroadcastVersion = 5 )
const ( // SimplePubKeyVersion is the version in which pubkeys are sent unencrypted // without any details of PoW required by the sender. SimplePubKeyVersion = 2 // ExtendedPubKeyVersion is the version in which pubkeys are sent // unencrypted with details of PoW required by the sender. ExtendedPubKeyVersion = 3 // EncryptedPubKeyVersion is the version from which pubkeys started to be // sent as an encrypted ExtendedPubKey, decryptable by those who had the // addresses of the owners of those keys. EncryptedPubKeyVersion = 4 // SignatureMaxLength consists of 2 256-bit integers encoding using ASN.1 // 2*256/8 + 16 (safe encoding boundary). TODO find precise number. Probably // 72. SignatureMaxLength = 80 )
const MessageVersion = 1
MessageVersion is the standard version number for message objects.
const ( // TagGetPubKeyVersion specifies the version of GetPubKey from which // tags started being encoded in messages and not ripe. This was done to // thwart any public key/address harvesting attempts. TagGetPubKeyVersion = 4 )
Variables ¶
var ErrInvalidVersion = errors.New("Invalid version")
ErrInvalidVersion is returned when a message is decoded with an unrecognized or invalid version.
Functions ¶
func DecodePubKeySignature ¶
DecodePubKeySignature decodes a PubKey signature.
func EncodePubKeySignature ¶
EncodePubKeySignature encodes a PubKey signature.
func InventoryHash ¶
InventoryHash returns the hash of the object, as defined by the Bitmessage protocol.
Types ¶
type Broadcast ¶
Broadcast represents either kind of broadcast.
func DecodeBroadcast ¶
DecodeBroadcast takes a byte array and turns it into a broadcast object.
type EncryptedPubKey ¶
type EncryptedPubKey struct { Tag *hash.Sha Encrypted []byte // contains filtered or unexported fields }
EncryptedPubKey represents an encrypted pubkey.
func NewEncryptedPubKey ¶
func NewEncryptedPubKey(nonce pow.Nonce, expiration time.Time, streamNumber uint64, tag *hash.Sha, encrypted []byte) *EncryptedPubKey
NewEncryptedPubKey returns a new object message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*EncryptedPubKey) Command ¶
func (p *EncryptedPubKey) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*EncryptedPubKey) Decode ¶
func (p *EncryptedPubKey) Decode(r io.Reader) error
Decode decodes an EncryptedPubKey from a reader.
func (*EncryptedPubKey) Encode ¶
func (p *EncryptedPubKey) Encode(w io.Writer) error
Encode encodes the receiver to w using the bitmessage protocol encoding. This is part of the Message interface implementation.
func (*EncryptedPubKey) Header ¶
func (p *EncryptedPubKey) Header() *wire.ObjectHeader
Header is part of the Object interface and returns the object header.
func (*EncryptedPubKey) MaxPayloadLength ¶
func (p *EncryptedPubKey) MaxPayloadLength() int
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*EncryptedPubKey) MsgObject ¶
func (p *EncryptedPubKey) MsgObject() *wire.MsgObject
MsgObject is part of the Object interface and transforms the abstract Object to a *MsgObject.
func (*EncryptedPubKey) Payload ¶
func (p *EncryptedPubKey) Payload() []byte
Payload is part of the Object interface and returns the object payload of the message.
func (*EncryptedPubKey) String ¶
func (p *EncryptedPubKey) String() string
type ExtendedPubKey ¶
type ExtendedPubKey struct { Signature []byte // contains filtered or unexported fields }
ExtendedPubKey implements the Message and Object interfaces and represents an extended pubkey sent in response to MsgGetPubKey. The extended pub key includes information about the proof-of-work required to send a message.
func NewExtendedPubKey ¶
func NewExtendedPubKey(nonce pow.Nonce, expiration time.Time, streamNumber uint64, data *PubKeyData, signature []byte) *ExtendedPubKey
NewExtendedPubKey returns a new object message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*ExtendedPubKey) Behavior ¶
func (p *ExtendedPubKey) Behavior() uint32
Behavior returns the PubKey's behavior.
func (*ExtendedPubKey) Command ¶
func (p *ExtendedPubKey) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*ExtendedPubKey) Data ¶
func (p *ExtendedPubKey) Data() *PubKeyData
Data returns the PubKey's PubKeyData object.
func (*ExtendedPubKey) Decode ¶
func (p *ExtendedPubKey) Decode(r io.Reader) error
Decode decodes an ExtendedPubKey from a reader.
func (*ExtendedPubKey) Encode ¶
func (p *ExtendedPubKey) Encode(w io.Writer) error
Encode encodes the receiver to w using the bitmessage protocol encoding. This is part of the Message interface implementation.
func (*ExtendedPubKey) EncodeForSigning ¶
func (p *ExtendedPubKey) EncodeForSigning(w io.Writer) error
EncodeForSigning encodes the data that is signed.
func (*ExtendedPubKey) EncryptionKey ¶
func (p *ExtendedPubKey) EncryptionKey() *wire.PubKey
EncryptionKey return's the PubKey's EncryptionKey
func (*ExtendedPubKey) Header ¶
func (p *ExtendedPubKey) Header() *wire.ObjectHeader
Header is part of the Object interface and returns the object header.
func (*ExtendedPubKey) MaxPayloadLength ¶
func (p *ExtendedPubKey) MaxPayloadLength() int
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*ExtendedPubKey) MsgObject ¶
func (p *ExtendedPubKey) MsgObject() *wire.MsgObject
MsgObject is part of the Object interface and transforms the abstract Object to a *MsgObject.
func (*ExtendedPubKey) Object ¶
func (p *ExtendedPubKey) Object() Object
Object is part of the cipher.PubKey interface and returns the PubKey as an Object type.
func (*ExtendedPubKey) Payload ¶
func (p *ExtendedPubKey) Payload() []byte
Payload is part of the Object interface and returns the object payload of the message.
func (*ExtendedPubKey) Pow ¶
func (p *ExtendedPubKey) Pow() *pow.Data
Pow return's the key's pow data. For the SimplePubKey, this is nil.
func (*ExtendedPubKey) String ¶
func (p *ExtendedPubKey) String() string
func (*ExtendedPubKey) Tag ¶
func (p *ExtendedPubKey) Tag() *hash.Sha
Tag return's the key's pow data. For the SimplePubKey, this is nil.
func (*ExtendedPubKey) VerificationKey ¶
func (p *ExtendedPubKey) VerificationKey() *wire.PubKey
VerificationKey return's the PubKey's VerificationKey
type GetPubKey ¶
GetPubKey implements the Message interface and represents a request for a public key. If Version <= TagGetPubKeyVersion, tag is encoded in message and not ripe.
func NewGetPubKey ¶
NewGetPubKey returns a new object message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*GetPubKey) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*GetPubKey) Decode ¶
Decode decodes r using the bitmessage protocol encoding into the receiver. This is part of the Message interface implementation.
func (*GetPubKey) Encode ¶
Encode encodes the receiver to w using the bitmessage protocol encoding. This is part of the Message interface implementation.
func (*GetPubKey) Header ¶
func (msg *GetPubKey) Header() *wire.ObjectHeader
Header returns the object header.
func (*GetPubKey) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type Message ¶
type Message struct { Encrypted []byte // contains filtered or unexported fields }
Message implements the Object and Message interfaces and represents a message sent between two addresses. It can be decrypted only by those that have the private encryption key that corresponds to the destination address.
func DecodeMessage ¶
DecodeMessage takes a byte array and turns it into a message object.
func NewMessage ¶
func NewMessage(nonce pow.Nonce, expiration time.Time, streamNumber uint64, encrypted []byte) *Message
NewMessage returns a new object message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*Message) Command ¶
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*Message) Decode ¶
Decode decodes r using the bitmessage protocol encoding into the receiver. This is part of the Message interface implementation.
func (*Message) Encode ¶
Encode encodes the receiver to w using the bitmessage protocol encoding. This is part of the Message interface implementation.
func (*Message) Header ¶
func (msg *Message) Header() *wire.ObjectHeader
Header returns the object header.
func (*Message) MaxPayloadLength ¶
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
type Object ¶
Object is an interface an object message. Object messages can represent many different things, and therefore we might want many different internal representations for them. Therefore we use an interface.
func DecodeObject ¶
DecodeObject tries to convert a MsgObject into an an Object.
func DecodePubKey ¶
DecodePubKey takes a reader and decodes it as some kind of PubKey object.
func ReadObject ¶
ReadObject tries to convert a MsgObject into an an Object.
func ReadPubKey ¶
ReadPubKey takes a byte array and and tries to read it as some kind of pubkey.
type PubKeyData ¶
type PubKeyData struct { Behavior uint32 Verification *wire.PubKey Encryption *wire.PubKey Pow *pow.Data }
PubKeyData contains the information that is transmitted in a PubKey object.
func (*PubKeyData) Decode ¶
func (pk *PubKeyData) Decode(r io.Reader) error
Decode decodes a PubKeyData from a reader.
func (*PubKeyData) DecodeSimple ¶
func (pk *PubKeyData) DecodeSimple(r io.Reader) error
DecodeSimple decodes a PubKeyData according to the simpler, original format for PubKey objects.
func (*PubKeyData) Encode ¶
func (pk *PubKeyData) Encode(w io.Writer) error
Encode encodes the PubKeyData to a writer.
func (*PubKeyData) EncodeSimple ¶
func (pk *PubKeyData) EncodeSimple(w io.Writer) error
EncodeSimple encodes the PubKeyData to a writer according to the format for a SimplePubKey.
func (*PubKeyData) String ¶
func (pk *PubKeyData) String() string
String creates a human-readible string of a PubKeyData.
type SimplePubKey ¶
type SimplePubKey struct {
// contains filtered or unexported fields
}
SimplePubKey implements the Message and Object interfaces and represents a pubkey sent in response to MsgGetPubKey.
func NewSimplePubKey ¶
func NewSimplePubKey(nonce pow.Nonce, expiration time.Time, streamNumber uint64, behavior uint32, vk, ek *wire.PubKey) *SimplePubKey
NewSimplePubKey returns a new object message that conforms to the Message interface using the passed parameters and defaults for the remaining fields.
func (*SimplePubKey) Behavior ¶
func (p *SimplePubKey) Behavior() uint32
Behavior returns the PubKey's behavior.
func (*SimplePubKey) Command ¶
func (p *SimplePubKey) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*SimplePubKey) Data ¶
func (p *SimplePubKey) Data() *PubKeyData
Data returns the PubKey's PubKeyData object.
func (*SimplePubKey) Decode ¶
func (p *SimplePubKey) Decode(r io.Reader) error
Decode is part of the Message interface and it reads a new SimplePubKey in from r.
func (*SimplePubKey) Encode ¶
func (p *SimplePubKey) Encode(w io.Writer) error
Encode is part of the Message interface and it writes the SimplePubKey as a string of bits to the Writer.
func (*SimplePubKey) EncryptionKey ¶
func (p *SimplePubKey) EncryptionKey() *wire.PubKey
EncryptionKey return's the PubKey's EncryptionKey
func (*SimplePubKey) Header ¶
func (p *SimplePubKey) Header() *wire.ObjectHeader
Header is part of the Object interface and returns the object header.
func (*SimplePubKey) MaxPayloadLength ¶
func (p *SimplePubKey) MaxPayloadLength() int
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*SimplePubKey) MsgObject ¶
func (p *SimplePubKey) MsgObject() *wire.MsgObject
MsgObject is part of the Object interface and transforms the abstract Object to a *MsgObject.
func (*SimplePubKey) Object ¶
func (p *SimplePubKey) Object() Object
Object is part of the cipher.PubKey interface and returns the PubKey as an Object type.
func (*SimplePubKey) Payload ¶
func (p *SimplePubKey) Payload() []byte
Payload is part of the Object interface and returns the object payload of the message.
func (*SimplePubKey) Pow ¶
func (p *SimplePubKey) Pow() *pow.Data
Pow return's the key's pow data. For the SimplePubKey, this is nil.
func (*SimplePubKey) String ¶
func (p *SimplePubKey) String() string
String returns a representation of the SimplePubKey as a human-readable string.
func (*SimplePubKey) Tag ¶
func (p *SimplePubKey) Tag() *hash.Sha
Tag return's the key's pow data. For the SimplePubKey, this is nil.
func (*SimplePubKey) VerificationKey ¶
func (p *SimplePubKey) VerificationKey() *wire.PubKey
VerificationKey return's the PubKey's VerificationKey
type TaggedBroadcast ¶
TaggedBroadcast implements the Object and Message interfaces and represents a broadcast message in tagged format that can be decrypted by all the clients that know the address of the sender.
func NewTaggedBroadcast ¶
func NewTaggedBroadcast(nonce pow.Nonce, expiration time.Time, streamNumber uint64, tag *hash.Sha, encrypted []byte) *TaggedBroadcast
NewTaggedBroadcast returns a new object message that conforms to the Object interface using the passed parameters and defaults for the remaining fields.
func (*TaggedBroadcast) Command ¶
func (msg *TaggedBroadcast) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*TaggedBroadcast) Decode ¶
func (msg *TaggedBroadcast) Decode(r io.Reader) error
Decode decodes r using the bitmessage protocol encoding into the receiver. This is part of the Message interface implementation.
func (*TaggedBroadcast) Encode ¶
func (msg *TaggedBroadcast) Encode(w io.Writer) error
Encode encodes the receiver to w using the bitmessage protocol encoding. This is part of the Message interface implementation.
func (*TaggedBroadcast) EncodeForSigning ¶
func (msg *TaggedBroadcast) EncodeForSigning(w io.Writer) error
EncodeForSigning encodes the information in the TaggedBroadcast required for signing. This is just the header and tag.
func (*TaggedBroadcast) Encrypted ¶
func (msg *TaggedBroadcast) Encrypted() []byte
Encrypted returns the encrypted data in this Broadcast.
func (*TaggedBroadcast) Header ¶
func (msg *TaggedBroadcast) Header() *wire.ObjectHeader
Header returns the object header.
func (*TaggedBroadcast) MaxPayloadLength ¶
func (msg *TaggedBroadcast) MaxPayloadLength() int
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*TaggedBroadcast) MsgObject ¶
func (msg *TaggedBroadcast) MsgObject() *wire.MsgObject
MsgObject transforms the PubKeyObject to a *MsgObject.
func (*TaggedBroadcast) Payload ¶
func (msg *TaggedBroadcast) Payload() []byte
Payload return the object payload of the message.
func (*TaggedBroadcast) String ¶
func (msg *TaggedBroadcast) String() string
type TaglessBroadcast ¶
type TaglessBroadcast struct {
// contains filtered or unexported fields
}
TaglessBroadcast implements the Object and Message interfaces and represents a broadcast message in tagless format that can be decrypted by all the clients that know the address of the sender.
func NewTaglessBroadcast ¶
func NewTaglessBroadcast(nonce pow.Nonce, expiration time.Time, streamNumber uint64, encrypted []byte) *TaglessBroadcast
NewTaglessBroadcast returns a new object message that conforms to the Object interface using the passed parameters and defaults for the remaining fields.
func (*TaglessBroadcast) Command ¶
func (msg *TaglessBroadcast) Command() string
Command returns the protocol command string for the message. This is part of the Message interface implementation.
func (*TaglessBroadcast) Decode ¶
func (msg *TaglessBroadcast) Decode(r io.Reader) error
Decode decodes r using the bitmessage protocol encoding into the receiver. This is part of the Message interface implementation.
func (*TaglessBroadcast) Encode ¶
func (msg *TaglessBroadcast) Encode(w io.Writer) error
Encode encodes the receiver to w using the bitmessage protocol encoding. This is part of the Message interface implementation.
func (*TaglessBroadcast) EncodeForSigning ¶
func (msg *TaglessBroadcast) EncodeForSigning(w io.Writer) error
EncodeForSigning encodes the information in a TaglessBroadcast that is supposed to be signed. That's just the header.
func (*TaglessBroadcast) Encrypted ¶
func (msg *TaglessBroadcast) Encrypted() []byte
Encrypted returns the encrypted data in this Broadcast.
func (*TaglessBroadcast) Header ¶
func (msg *TaglessBroadcast) Header() *wire.ObjectHeader
Header returns the object header.
func (*TaglessBroadcast) MaxPayloadLength ¶
func (msg *TaglessBroadcast) MaxPayloadLength() int
MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.
func (*TaglessBroadcast) MsgObject ¶
func (msg *TaglessBroadcast) MsgObject() *wire.MsgObject
MsgObject transforms the PubKeyObject to a *MsgObject.
func (*TaglessBroadcast) Payload ¶
func (msg *TaglessBroadcast) Payload() []byte
Payload return the object payload of the message.
func (*TaglessBroadcast) String ¶
func (msg *TaglessBroadcast) String() string
String creates a human-readable string that with information about the broadcast.