Documentation ¶
Index ¶
- Constants
- Variables
- func ToIdentity(pubkey PubKeyObject) (identity.Public, error)
- type Bitmessage
- type Broadcast
- func CreateTaggedBroadcast(expires time.Time, bm *Bitmessage, tag *hash.Sha, private *identity.PrivateID) (*Broadcast, error)
- func CreateTaglessBroadcast(expiration time.Time, bm *Bitmessage, private *identity.PrivateID) (*Broadcast, error)
- func NewTaggedBroadcast(msg *obj.TaggedBroadcast, address bmutil.Address) (*Broadcast, error)
- func NewTaglessBroadcast(msg *obj.TaglessBroadcast, address bmutil.Address) (*Broadcast, error)
- func SignAndEncryptBroadcast(expiration time.Time, msg *Bitmessage, tag *hash.Sha, ...) (*Broadcast, error)
- func TryDecryptAndVerifyBroadcast(msg obj.Broadcast, address bmutil.Address) (*Broadcast, error)
- type Data
- type Message
- type PubKeyObject
Constants ¶
const (
// AckLength is the length of an ack message.
AckLength = 26
)
Variables ¶
var ( // ErrUnsupportedOp is returned when the attempted operation is unsupported. ErrUnsupportedOp = errors.New("operation unsupported") // ErrInvalidSignature is returned when the signature embedded in the // message is malformed or fails to verify (because of invalid checksum). ErrInvalidSignature = errors.New("invalid signature/verification failed") // ErrInvalidIdentity is returned when the provided address/identity is // unable to decrypt the given message. ErrInvalidIdentity = errors.New("invalid supplied identity/decryption failed") // ErrInvalidObjectType is returned when the given object is not of // the expected type. ErrInvalidObjectType = errors.New("invalid object type") )
Functions ¶
func ToIdentity ¶
func ToIdentity(pubkey PubKeyObject) (identity.Public, error)
ToIdentity transforms a PubKeyObject to an identity.Public
Types ¶
type Bitmessage ¶
Bitmessage is a representation of the data included in a bitmessage. It could be part of a message object or a broadcast object.
func (*Bitmessage) String ¶
func (b *Bitmessage) String() string
type Broadcast ¶
type Broadcast struct {
// contains filtered or unexported fields
}
Broadcast represents a broadcast that has either been decrypted from the network or which we have created.
func CreateTaggedBroadcast ¶
func CreateTaggedBroadcast(expires time.Time, bm *Bitmessage, tag *hash.Sha, private *identity.PrivateID) (*Broadcast, error)
CreateTaggedBroadcast creates a Broadcast that we send over the network, as opposed to one that we receive and decrypt.
func CreateTaglessBroadcast ¶
func CreateTaglessBroadcast(expiration time.Time, bm *Bitmessage, private *identity.PrivateID) (*Broadcast, error)
CreateTaglessBroadcast creates a Broadcast that we send over the network, as opposed to one that we receive and decrypt.
func NewTaggedBroadcast ¶
NewTaggedBroadcast takes a broadcast we have received over the network and attempts to decrypt it.
func NewTaglessBroadcast ¶
NewTaglessBroadcast takes a broadcast we have received over the network and attempts to decrypt it.
func SignAndEncryptBroadcast ¶
func SignAndEncryptBroadcast(expiration time.Time, msg *Bitmessage, tag *hash.Sha, privID *identity.PrivateID) (*Broadcast, error)
SignAndEncryptBroadcast signs and encrypts a Broadcast, populating the Signature and Encrypted fields using the provided private identity.
The private identity supplied should be of the sender. There are no checks against supplying invalid private identity.
func TryDecryptAndVerifyBroadcast ¶
TryDecryptAndVerifyBroadcast tries to decrypt a wire.BroadcastObject of the public identity. If it fails, it returns ErrInvalidIdentity. If decryption succeeds, it verifies the embedded signature. If signature verification fails, it returns ErrInvalidSignature. Else, it returns nil.
All necessary fields of the provided wire.BroadcastObject are populated.
func (*Broadcast) Bitmessage ¶
func (broadcast *Broadcast) Bitmessage() *Bitmessage
Bitmessage returns the message data.
type Data ¶
type Data struct { Key identity.PublicKey Version uint64 Stream uint64 Behavior uint32 Pow *pow.Data }
func (*Data) PubKeyData ¶
func (d *Data) PubKeyData() *obj.PubKeyData
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is a representation of a message object that includes data which would normally be encrypted.
func NewMessage ¶
NewMessage attempts to decrypt the data in a message object and turn it into a Message.
func SignAndEncryptMessage ¶
func SignAndEncryptMessage(expiration time.Time, streamNumber uint64, bm *Bitmessage, ack []byte, privID *identity.PrivateKey, pubID *identity.PublicKey) (*Message, error)
SignAndEncryptMessage signs and encrypts a Message, populating the Signature and Encrypted fields using the provided private identity.
The private identity supplied should be of the sender. The public identity should be that of the recipient. There are no checks against supplying invalid private or public identities.
func TryDecryptAndVerifyMessage ¶
TryDecryptAndVerifyMessage tries to decrypt an obj.Message using the private identity. If it fails, it returns ErrInvalidIdentity. If decryption succeeds, it verifies the embedded signature. If signature verification fails, it returns ErrInvalidSignature. Else, it returns nil.
All necessary fields of the provided obj.Message are populated.
func (*Message) Bitmessage ¶
func (msg *Message) Bitmessage() *Bitmessage
Bitmessage returns the message data.
type PubKeyObject ¶
type PubKeyObject interface { Object() obj.Object Data() *obj.PubKeyData Behavior() uint32 Pow() *pow.Data Tag() *hash.Sha String() string }
PubKeyObject is an interface representing a PubKeyMessage. It represents a pubkey object that we either created or were able to decrypt. It encapsulates the cryptographic operations required to work with pubkey objects.
func GeneratePubKey ¶
GeneratePubKey generates a PubKey from the specified private identity. It also signs and encrypts it (if necessary) yielding an object that only needs proof-of-work to be done on it.
func TryDecryptAndVerifyPubKey ¶
TryDecryptAndVerifyPubKey tries to decrypt a wire.PubKeyObject of the address. If it fails, it returns ErrInvalidIdentity. If decryption succeeds, it verifies the embedded signature. If signature verification fails, it returns ErrInvalidSignature. Else, it returns nil.
All necessary fields of the provided wire.PubKeyObject are populated.