cipher

package
v0.0.0-...-7e76903 Latest Latest
Warning

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

Go to latest
Published: May 14, 2016 License: ISC Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func GeneratePubKey

func GeneratePubKey(privID *identity.Private, expiry time.Duration) (*wire.MsgPubKey, error)

GeneratePubKey generates a wire.MsgPubKey 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 SignAndEncryptBroadcast

func SignAndEncryptBroadcast(msg *wire.MsgBroadcast, privID *identity.Private) error

SignAndEncryptBroadcast signs and encrypts a MsgBroadcast message, 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 SignAndEncryptMsg

func SignAndEncryptMsg(msg *wire.MsgMsg, privID *identity.Private,
	pubID *identity.Public) error

SignAndEncryptMsg signs and encrypts a MsgMsg 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 SignAndEncryptPubKey

func SignAndEncryptPubKey(msg *wire.MsgPubKey, privID *identity.Private) error

SignAndEncryptPubKey signs and encrypts a MsgPubKey message, 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

func TryDecryptAndVerifyBroadcast(msg *wire.MsgBroadcast, address *bmutil.Address) error

TryDecryptAndVerifyBroadcast tries to decrypt a wire.MsgBroadcast 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.MsgBroadcast are populated.

func TryDecryptAndVerifyMsg

func TryDecryptAndVerifyMsg(msg *wire.MsgMsg, privID *identity.Private) error

TryDecryptAndVerifyMsg tries to decrypt a wire.MsgMsg 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 wire.MsgMsg are populated.

func TryDecryptAndVerifyPubKey

func TryDecryptAndVerifyPubKey(msg *wire.MsgPubKey, address *bmutil.Address) error

TryDecryptAndVerifyPubKey tries to decrypt a wire.MsgPubKey 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.MsgPubKey are populated.

Types

This section is empty.

Jump to

Keyboard shortcuts

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