Documentation ¶
Overview ¶
Package mam provides functions for creating Masked Authentication Messaging messages
Package mam provides functions for creating Masked Authentication Messaging messages
Index ¶
- Variables
- func MAMCreate(payloadLength uint64, message Trytes, sideKey Trytes, merkleTree Trits, ...) (Trits, uint64, error)
- func MAMInitEncryption(sideKey Trits, merkleRoot Trits, spongeFunc sponge.SpongeFunction)
- func MAMParse(payload Trits, payloadLength uint64, sideKey Trytes, root Trits) (uint64, Trytes, Trytes, SecurityLevel, error)
- func Mask(dest Trits, message Trits, length uint64, c *curl.Curl)
- func PayloadMinLength(messageLength, merkleTreeLength, index uint64, security SecurityLevel) uint64
- func Unmask(cipher Trits, length uint64, c *curl.Curl) (dest Trits)
- type API
- type Channel
- type ChannelMode
- type Receiver
- type Transmitter
Constants ¶
This section is empty.
Variables ¶
var ( ErrPayloadTooShort = errors.New("payload too short") ErrMerkleRootDoesNotMatch = errors.New("Merkle root does not match") ErrWrongSecurityLevel = errors.New("wrong security level") )
var ( ErrUnknownChannelMode = errors.New("Channel mode must be ChannelModePublic, ChannelModePrivate or ChannelModeRestricted") ErrNoSideKey = errors.New("A 81-trytes sideKey must be provided for the restricted mode") )
Some error definitions.
var (
ErrCouldNotParseChannelMode = errors.New("could not parse Channel mode")
)
Error definitions
Functions ¶
func MAMCreate ¶
func MAMCreate(payloadLength uint64, message Trytes, sideKey Trytes, merkleTree Trits, merkleTreeLength uint64, leafCount uint64, index uint64, nextRoot Trits, start uint64, seed Trytes, security SecurityLevel) (Trits, uint64, error)
MAMCreate creates a signed, encrypted payload from a message.
payloadLength is the length of the payload message is the message to encrypt sideKey is the encryption key merkleTree is the Merkle tree merkleTreeLength is the length of the Merkle tree leafCount is the number of leaves of the Merkle tree index is the leaf index nextRoot is the Merkle root of the next MAM payload start is the offset used to generate addresses seed is the seed used to generate addresses - Not sent over the network security is the security level used to generate addresses
Returns:
payload is the payload of the encrypted message payloadMinLength is the length of the payload needed to encrypt the message err is the error message
func MAMInitEncryption ¶
func MAMInitEncryption(sideKey Trits, merkleRoot Trits, spongeFunc sponge.SpongeFunction)
MAMInitEncryption initializes the encryption/decryption state for a MAM session.
sideKey is the encryption/decryption key merkleRoot is the Merkle root spongeFunc is the spongeFunction instance used for encryption/decryption
func MAMParse ¶
func MAMParse(payload Trits, payloadLength uint64, sideKey Trytes, root Trits) (uint64, Trytes, Trytes, SecurityLevel, error)
MAMParse decrypts, parses and validates an encrypted payload.
payload is the payload payloadLength is the length of the payload sideKey is the decryption key root is the Merkle root
Returns:
parsedIndex is the parsed index of the message parsedNextRoot is the Merkle root of the next MAM payload parsedMessage is the decrypted message parsedSecurity is the parsed security level of the message err is the error message
func Mask ¶
Masks a given message with a curl instance state.
dest is the destination of the masked message message is the message to be masked length is the length of the message c is the curl instance used to mask the message
func PayloadMinLength ¶
PayloadMinLength computes the minimum length of a payload.
messageLength is the length of the message merkleTreeLength is the length of the Merkle tree index is the leaf index security is the security level used to generate addresses
Returns the minimum length of the payload
Types ¶
type API ¶
type API interface { PrepareTransfers(seed trinary.Trytes, transfers bundle.Transfers, opts api.PrepareTransfersOptions) ([]trinary.Trytes, error) SendTrytes(trytes []trinary.Trytes, depth uint64, mwm uint64, reference ...trinary.Hash) (bundle.Bundle, error) FindTransactionObjects(query api.FindTransactionsQuery) (transaction.Transactions, error) }
API defines an interface with a subset of methods of `api.API`.
type Channel ¶
type Channel struct { Mode ChannelMode `json:"mode"` SideKey trinary.Trytes `json:"side_key"` NextRoot trinary.Trits `json:"next_root"` SecurityLevel consts.SecurityLevel `json:"security_level"` Start uint64 `json:"start"` Count uint64 `json:"count"` NextCount uint64 `json:"next_count"` Index uint64 `json:"index"` }
func NewChannel ¶
func NewChannel(securityLevel consts.SecurityLevel) *Channel
type ChannelMode ¶
type ChannelMode string
ChannelMode is an enum of Channel modes.
const ( ChannelModePublic ChannelMode = "public" ChannelModePrivate ChannelMode = "private" ChannelModeRestricted ChannelMode = "restricted" )
Definition of possible Channel modes.
func ParseChannelMode ¶
func ParseChannelMode(input string) (ChannelMode, error)
ParseChannelMode parses a Channel mode from the given string.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver implements a receiver for MAM-Messages.
func (*Receiver) Receive ¶
Receive tries to receive all messages from the specified root and returns them along with the next root.
type Transmitter ¶
type Transmitter struct {
// contains filtered or unexported fields
}
Transmitter defines the MAM facade transmitter.
func NewTransmitter ¶
func NewTransmitter(api API, seed trinary.Trytes, mwm uint64, securityLevel consts.SecurityLevel) *Transmitter
NewTransmitter returns a new transmitter.
func NewTransmitterWithChannel ¶
func NewTransmitterWithChannel(api API, seed trinary.Trytes, mwm uint64, channel *Channel) *Transmitter
NewTransmitterWithChannel returns a new transmitter with an existing channel.
func (*Transmitter) Channel ¶
func (t *Transmitter) Channel() *Channel
SideKey returns the underlying Channel of this Transmitter.
func (*Transmitter) SetMode ¶
func (t *Transmitter) SetMode(m ChannelMode, sideKey trinary.Trytes) error
SetMode sets the Channel mode.
func (*Transmitter) SideKey ¶
func (t *Transmitter) SideKey() trinary.Trytes
SideKey returns the Channel's side key.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package merkle provides functions for creating and validating MAM compatible Merkle trees.
|
Package merkle provides functions for creating and validating MAM compatible Merkle trees. |
Package signing provides implements the signing scheme used in MAM.
|
Package signing provides implements the signing scheme used in MAM. |