objects

package
v0.0.0-...-fe38a42 Latest Latest
Warning

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

Go to latest
Published: May 22, 2015 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Objects package contains all the object types as defined in v3 of the protocol specifications. Specifically: message, broadcast, getpubkey, pubkey.

Index

Constants

View Source
const (
	// Any data with this number may be ignored. The sending node might simply
	// be sharing its public key with you.
	Encoding_IGNORE = EncodingType(iota)
	// UTF-8. No 'Subject' or 'Body' sections. Useful for simple strings of
	// data, like URIs or magnet links.
	Encoding_TRIVIAL
	// UTF-8. Uses 'Subject' and 'Body' sections. No MIME is used.
	// messageToTransmit = 'Subject:' + subject + '\n' + 'Body:' + message
	Encoding_SIMPLE
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastEncryptedV4

type BroadcastEncryptedV4 struct {
	// Encrypted broadcast data.
	EncryptedData []byte
}

Broadcast originating from an address version <= 3.

func (*BroadcastEncryptedV4) DeserializeReader

func (obj *BroadcastEncryptedV4) DeserializeReader(b io.Reader) error

func (*BroadcastEncryptedV4) Serialize

func (obj *BroadcastEncryptedV4) Serialize() []byte

type BroadcastEncryptedV5

type BroadcastEncryptedV5 struct {
	// The tag. This field is new and only included when the broadcast version
	// is >= 5.
	Tag [32]byte
	// Encrypted broadcast data.
	EncryptedData []byte
}

Having a broadcast version of 5 indicates that a tag is used which, in turn, is used when the sender's address version is >=4.

func (*BroadcastEncryptedV5) DeserializeReader

func (obj *BroadcastEncryptedV5) DeserializeReader(b io.Reader) error

func (*BroadcastEncryptedV5) Serialize

func (obj *BroadcastEncryptedV5) Serialize() []byte

func (*BroadcastEncryptedV5) SetTag

func (obj *BroadcastEncryptedV5) SetTag(tag []byte)

type BroadcastUnencryptedV4AddressV2

type BroadcastUnencryptedV4AddressV2 struct {
	MsgUnencryptedV2
}

Broadcast version == 4 and address version == 2.

func (*BroadcastUnencryptedV4AddressV2) Encrypt

type BroadcastUnencryptedV4AddressV3

type BroadcastUnencryptedV4AddressV3 struct {
	MsgUnencryptedV3
}

Broadcast version == 4 and address version == 3.

func (*BroadcastUnencryptedV4AddressV3) Encrypt

type BroadcastUnencryptedV5

type BroadcastUnencryptedV5 struct {
	MsgUnencryptedV3
}

Broadcast version == 5 and address version == 4.

func (*BroadcastUnencryptedV5) Encrypt

type Corrupt

type Corrupt struct{}

Corrupt represents an object that is corrupt.

func (*Corrupt) DeserializeReader

func (obj *Corrupt) DeserializeReader(b io.Reader) error

func (*Corrupt) Serialize

func (obj *Corrupt) Serialize() []byte

type EncodingType

type EncodingType types.Varint

Define how the message is to be encoded.

type GetpubkeyV3

type GetpubkeyV3 struct {
	// The ripemd hash of the public key. This field is only included when the
	// address version is <= 3.
	Ripe [20]byte
}

When a node has the hash of a public key (from a version <= 3 address) but not the public key itself, it must send out a request for the public key.

func (*GetpubkeyV3) DeserializeReader

func (obj *GetpubkeyV3) DeserializeReader(b io.Reader) error

func (*GetpubkeyV3) Serialize

func (obj *GetpubkeyV3) Serialize() []byte

type GetpubkeyV4

type GetpubkeyV4 struct {
	// The tag derived from the address version, stream number, and ripe. This
	// field is only included when the address version is >= 4.
	Tag [32]byte
}

When a node has the hash of a public key (from a version >= 4 address) but not the public key itself, it must send out a request for the public key.

func (*GetpubkeyV4) DeserializeReader

func (obj *GetpubkeyV4) DeserializeReader(b io.Reader) error

func (*GetpubkeyV4) Serialize

func (obj *GetpubkeyV4) Serialize() []byte

type MsgEncrypted

type MsgEncrypted struct {
	EncryptedData []byte
}

Used for person-to-person messages.

func (*MsgEncrypted) DeserializeReader

func (obj *MsgEncrypted) DeserializeReader(b io.Reader) error

func (*MsgEncrypted) Serialize

func (obj *MsgEncrypted) Serialize() []byte

type MsgUnencryptedV2

type MsgUnencryptedV2 struct {
	// Sender's address version number. This is needed in order to calculate the
	// sender's address to show in the UI, and also to allow for forwards
	// compatible changes to the public-key data included below.
	AddressVersion types.Varint
	// The sender's stream number
	Stream types.Varint
	// A bitfield of optional behaviors and features that can be expected from
	// the node with this pubkey included in this message (the sender's pubkey).
	Behaviour uint32
	// The ECC public key used for signing (uncompressed format; normally
	// prepended with \x04 )
	PubSigningKey [64]byte
	// The ECC public key used for encryption (uncompressed format; normally
	// prepended with \x04 )
	PubEncryptionKey [64]byte
	// The ripe hash of the public key of the receiver of the message.
	DestinationRipe [20]byte
	// Message Encoding type
	Encoding EncodingType
	// The message
	Message []byte
	// The acknowledgement data to be transmitted. This takes the form of a
	// Bitmessage protocol message, like another msg message. The POW therein
	// must already be completed.
	AckData []byte
	// The ECDSA signature which covers everything from the msg_version to the
	// ack_data.
	Signature []byte
}

Used for person-to-person messages when the sender's address version <= 2.

func (*MsgUnencryptedV2) DeserializeReader

func (obj *MsgUnencryptedV2) DeserializeReader(b io.Reader) error

func (*MsgUnencryptedV2) Encrypt

func (obj *MsgUnencryptedV2) Encrypt(key *elliptic.PublicKey) (types.Serializer,
	error)

func (*MsgUnencryptedV2) Serialize

func (obj *MsgUnencryptedV2) Serialize() []byte

func (*MsgUnencryptedV2) SetSignature

func (obj *MsgUnencryptedV2) SetSignature(sig []byte)

func (*MsgUnencryptedV2) SetSigningAndEncryptionKeys

func (obj *MsgUnencryptedV2) SetSigningAndEncryptionKeys(sk, ek []byte)

func (*MsgUnencryptedV2) SignatureSerialize

func (obj *MsgUnencryptedV2) SignatureSerialize() []byte

Code taken from line 743 onwards on class_singleWorker.py

type MsgUnencryptedV3

type MsgUnencryptedV3 struct {
	// Sender's address version number. This is needed in order to calculate the
	// sender's address to show in the UI, and also to allow for forwards
	// compatible changes to the public-key data included below.
	AddressVersion types.Varint
	// The sender's stream number
	Stream types.Varint
	// A bitfield of optional behaviors and features that can be expected from
	// the node with this pubkey included in this message (the sender's pubkey).
	Behaviour uint32
	// The ECC public key used for signing (uncompressed format; normally
	// prepended with \x04 )
	PubSigningKey [64]byte
	// The ECC public key used for encryption (uncompressed format; normally
	// prepended with \x04 )
	PubEncryptionKey [64]byte
	// Used to calculate the difficulty target of messages accepted by this
	// node. The higher this value, the more difficult the Proof of Work must be
	// before this individual will accept the message. This number is the
	// average number of nonce trials a node will have to perform to meet the
	// Proof of Work requirement. 1000 is the network minimum so any lower
	// values will be automatically raised to 1000. This field is new and is
	// only included when the address_version >= 3.
	NonceTrialsPerByte types.Varint
	// Used to calculate the difficulty target of messages accepted by this
	// node. The higher this value, the more difficult the Proof of Work must be
	// before this individual will accept the message. This number is added to
	// the data length to make sending small messages more difficult. 1000 is
	// the network minimum so any lower values will be automatically raised to
	// 1000. This field is new and is only included when the AddressVersion >= 3.
	ExtraBytes types.Varint
	// The ripe hash of the public key of the receiver of the message.
	DestinationRipe [20]byte
	// Message Encoding type
	Encoding EncodingType
	// The message
	Message []byte
	// The acknowledgement data to be transmitted. This takes the form of a
	// Bitmessage protocol message, like another msg message. The POW therein
	// must already be completed.
	AckData []byte
	// The ECDSA signature which covers everything from the msg_version to the
	// ack_data.
	Signature []byte
}

Used for person-to-person messages when the sender's address version >= 3.

func (*MsgUnencryptedV3) DeserializeReader

func (obj *MsgUnencryptedV3) DeserializeReader(b io.Reader) error

func (*MsgUnencryptedV3) Encrypt

func (obj *MsgUnencryptedV3) Encrypt(key *elliptic.PublicKey) (types.Serializer,
	error)

func (*MsgUnencryptedV3) Serialize

func (obj *MsgUnencryptedV3) Serialize() []byte

func (*MsgUnencryptedV3) SetSignature

func (obj *MsgUnencryptedV3) SetSignature(sig []byte)

func (*MsgUnencryptedV3) SetSigningAndEncryptionKeys

func (obj *MsgUnencryptedV3) SetSigningAndEncryptionKeys(sk, ek []byte)

func (*MsgUnencryptedV3) SignatureSerialize

func (obj *MsgUnencryptedV3) SignatureSerialize() []byte

type PubkeyEncryptedV4

type PubkeyEncryptedV4 struct {
	// The tag, made up of bytes 32-64 of the double hash of the address data.
	Tag [32]byte
	// Encrypted pubkey data.
	EncryptedData []byte
}

When version 4 pubkeys are created, most of the data in the pubkey is encrypted. This is done in such a way that only someone who has the Bitmessage address which corresponds to a pubkey can decrypt and use that pubkey. This prevents people from gathering pubkeys sent around the network and using the data from them to create messages to be used in spam or in flooding attacks.

func (*PubkeyEncryptedV4) Decrypt

func (obj *PubkeyEncryptedV4) Decrypt(key *elliptic.PrivateKey) (
	types.Serializer, error)

func (*PubkeyEncryptedV4) DeserializeReader

func (obj *PubkeyEncryptedV4) DeserializeReader(b io.Reader) error

func (*PubkeyEncryptedV4) Serialize

func (obj *PubkeyEncryptedV4) Serialize() []byte

func (*PubkeyEncryptedV4) SetTag

func (obj *PubkeyEncryptedV4) SetTag(tag []byte)

type PubkeyUnencryptedV4

type PubkeyUnencryptedV4 struct {
	PubkeyV3
}

When decrypted, a version 4 pubkey is the same as a verion 3 pubkey.

func (*PubkeyUnencryptedV4) Encrypt

type PubkeyV2

type PubkeyV2 struct {
	// A bitfield of optional behaviors and features that can be expected from
	// the node receiving the message.
	Behaviour uint32
	// The ECC public key used for signing (uncompressed format; normally
	// prepended with 0x04)
	PubSigningKey [64]byte
	// The ECC public key used for encryption (uncompressed format; normally
	// prepended with 0x04)
	PubEncryptionKey [64]byte
}

A version 2 pubkey. This is still in use and supported by current clients but new v2 addresses are not generated by clients.

func (*PubkeyV2) DeserializeReader

func (obj *PubkeyV2) DeserializeReader(b io.Reader) error

func (*PubkeyV2) Serialize

func (obj *PubkeyV2) Serialize() []byte

func (*PubkeyV2) SetSigningAndEncryptionKeys

func (obj *PubkeyV2) SetSigningAndEncryptionKeys(sk, ek []byte)

type PubkeyV3

type PubkeyV3 struct {
	// A bitfield of optional behaviors and features that can be expected from
	// the node receiving the message.
	Behaviour uint32
	// The ECC public key used for signing (uncompressed format; normally
	// prepended with 0x04)
	PubSigningKey [64]byte
	// The ECC public key used for encryption (uncompressed format; normally
	// prepended with 0x04)
	PubEncryptionKey [64]byte
	// Used to calculate the difficulty target of messages accepted by this
	// node. The higher this value, the more difficult the Proof of Work must be
	// before this individual will accept the message. This number is the
	// average number of nonce trials a node will have to perform to meet the
	// Proof of Work requirement. 1000 is the network minimum so any lower
	// values will be automatically raised to 1000.
	NonceTrialsPerByte types.Varint
	// Used to calculate the difficulty target of messages accepted by this
	// node. The higher this value, the more difficult the Proof of Work must be
	// before this individual will accept the message. This number is added to
	// the data length to make sending small messages more difficult. 1000 is
	// the network minimum so any lower values will be automatically raised to
	// 1000.
	ExtraBytes types.Varint
	// The ECDSA signature which, as of protocol v3, covers the object header
	// starting with the time, appended with the data described in this table
	// down to the extra_bytes.
	Signature []byte
}

A version 3 pubkey

func (*PubkeyV3) DeserializeReader

func (obj *PubkeyV3) DeserializeReader(b io.Reader) error

func (*PubkeyV3) Serialize

func (obj *PubkeyV3) Serialize() []byte

func (*PubkeyV3) SetSignature

func (obj *PubkeyV3) SetSignature(sig []byte)

func (*PubkeyV3) SetSigningAndEncryptionKeys

func (obj *PubkeyV3) SetSigningAndEncryptionKeys(sk, ek []byte)

func (*PubkeyV3) SignatureSerialize

func (obj *PubkeyV3) SignatureSerialize() []byte

type Unrecognized

type Unrecognized struct {
	Data []byte
}

Unrecognized represents an unidentified object type.

func (*Unrecognized) DeserializeReader

func (obj *Unrecognized) DeserializeReader(b io.Reader) error

func (*Unrecognized) Serialize

func (obj *Unrecognized) Serialize() []byte

Jump to

Keyboard shortcuts

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