dm

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeReceiverSihTag

func MakeReceiverSihTag(themPub ed25519.PublicKey, mePriv ed25519.PrivateKey) string

MakeReceiverSihTag creates an SIH tag for a received DM message.

func MakeSenderSihTag

func MakeSenderSihTag(themPub ed25519.PublicKey, mePriv ed25519.PrivateKey) string

MakeSenderSihTag creates an SIH tag for a sent DM message.

Types

type DMCipher

type DMCipher interface {
	// CiphertextOverhead returns the ciphertext overhead in bytes.
	CiphertextOverhead() int

	// Encrypt encrypts the given plaintext as an encrypted Direct message.
	Encrypt(plaintext []byte,
		senderStaticPrivKey nike.PrivateKey,
		partnerStaticPubKey nike.PublicKey,
		rng io.Reader,
		maxPayloadSize int) (ciphertext []byte)

	// Decrypt decrypts the given ciphertext encrypted as a Direct
	// message.
	Decrypt(ciphertext []byte, senderStaticPrivKey nike.PrivateKey) (
		partnerStaticPublicKey nike.PublicKey, plaintext []byte,
		err error)

	// IsSelfEncrypted will return whether the ciphertext provided has been
	// encrypted by the owner of the passed in private key. Returns true
	// if the ciphertext has been encrypted by the user.
	IsSelfEncrypted(data []byte, myPrivateKey nike.PrivateKey) bool

	// EncryptSelf will encrypt the passed plaintext. This will simulate the
	// encryption protocol in Encrypt, using just the user's public key.
	EncryptSelf(plaintext []byte, myPrivateKey nike.PrivateKey,
		partnerStaticPubKey nike.PublicKey,
		maxPayloadSize int) ([]byte, error)

	// DecryptSelf will decrypt the passed ciphertext. This will
	// check if the ciphertext is expected using IsSelfEncrypted.
	DecryptSelf(ciphertext []byte, myPrivateKey nike.PrivateKey) (
		partnerstaticPubKey nike.PublicKey, plaintext []byte, err error)
}

DMCipher is a minimal abstraction for building the DMCipher Protocol layer

var (
	Cipher DMCipher = &dmCipher{}
)

type NoiseCipher

type NoiseCipher interface {
	// CiphertextOverhead returns the ciphertext overhead in bytes.
	CiphertextOverhead() int

	// Encrypt encrypts the given plaintext as a Noise X message.
	// - plaintext: The message to Encrypt
	// - partnerStaticPubKey: The public key of the target of the message
	// - rng: a cryptographically secure pseudo random number generator
	Encrypt(plaintext []byte,
		partnerStaticPubKey nike.PublicKey,
		rng io.Reader) []byte

	// Decrypt decrypts the given ciphertext as a Noise X message.
	Decrypt(ciphertext []byte,
		myStatic nike.PrivateKey) ([]byte, error)
}

NoiseCipher is a minimal abstraction useful for building a noise protocol layer.

var (
	NoiseX NoiseCipher = &noiseX{}
)

Jump to

Keyboard shortcuts

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