obj

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: ISC Imports: 11 Imported by: 23

Documentation

Index

Constants

View Source
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
)
View Source
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
)
View Source
const MessageVersion = 1

MessageVersion is the standard version number for message objects.

View Source
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

View Source
var ErrInvalidVersion = errors.New("Invalid version")

ErrInvalidVersion is returned when a message is decoded with an unrecognized or invalid version.

Functions

func DecodePubKeySignature

func DecodePubKeySignature(r io.Reader) (signature []byte, err error)

DecodePubKeySignature decodes a PubKey signature.

func EncodePubKeySignature

func EncodePubKeySignature(w io.Writer, signature []byte) (err error)

EncodePubKeySignature encodes a PubKey signature.

func InventoryHash

func InventoryHash(obj Object) *hash.Sha

InventoryHash returns the hash of the object, as defined by the Bitmessage protocol.

Types

type Broadcast

type Broadcast interface {
	Object
	Encrypted() []byte
	EncodeForSigning(io.Writer) error
}

Broadcast represents either kind of broadcast.

func DecodeBroadcast

func DecodeBroadcast(obj []byte) (Broadcast, error)

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

type GetPubKey struct {
	Ripe *hash.Ripe
	Tag  *hash.Sha
	// contains filtered or unexported fields
}

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

func NewGetPubKey(nonce pow.Nonce, expiration time.Time, address Address) *GetPubKey

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

func (msg *GetPubKey) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*GetPubKey) Decode

func (msg *GetPubKey) 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 (*GetPubKey) Encode

func (msg *GetPubKey) 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 (*GetPubKey) Header

func (msg *GetPubKey) Header() *wire.ObjectHeader

Header returns the object header.

func (*GetPubKey) MaxPayloadLength

func (msg *GetPubKey) MaxPayloadLength() int

MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.

func (*GetPubKey) MsgObject

func (msg *GetPubKey) MsgObject() *wire.MsgObject

MsgObject transforms the PubKeyObject to a *MsgObject.

func (*GetPubKey) Payload

func (msg *GetPubKey) Payload() []byte

Payload return the object payload of the message.

func (*GetPubKey) String

func (msg *GetPubKey) String() string

String returns a human-readible string representation of the GetPubKey.

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

func DecodeMessage(obj []byte) (*Message, error)

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

func (msg *Message) Command() string

Command returns the protocol command string for the message. This is part of the Message interface implementation.

func (*Message) Decode

func (msg *Message) 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 (*Message) Encode

func (msg *Message) 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 (*Message) Header

func (msg *Message) Header() *wire.ObjectHeader

Header returns the object header.

func (*Message) MaxPayloadLength

func (msg *Message) MaxPayloadLength() int

MaxPayloadLength returns the maximum length the payload can be for the receiver. This is part of the Message interface implementation.

func (*Message) MsgObject

func (msg *Message) MsgObject() *wire.MsgObject

MsgObject transforms the PubKeyObject to a *MsgObject.

func (*Message) Payload

func (msg *Message) Payload() []byte

Payload return the object payload of the message.

func (*Message) String

func (msg *Message) String() string

type Object

type Object interface {
	wire.Message
	Header() *wire.ObjectHeader
	Payload() []byte
	String() string
}

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

func DecodeObject(r io.Reader) (Object, error)

DecodeObject tries to convert a MsgObject into an an Object.

func DecodePubKey

func DecodePubKey(r io.Reader) (Object, error)

DecodePubKey takes a reader and decodes it as some kind of PubKey object.

func ReadObject

func ReadObject(obj []byte) (Object, error)

ReadObject tries to convert a MsgObject into an an Object.

func ReadPubKey

func ReadPubKey(obj []byte) (Object, error)

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

type TaggedBroadcast struct {
	Tag *hash.Sha
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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