formats

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const MessageHMACLength = 32

MessageHMACLength is implied to be constant due to an assumption that this key is used as an HMAC key when calling libsodium's functions.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentParser

type ContentParser interface {
	Parse(raw message.RawContent) (message.Content, error)
}

type MessageHMAC

type MessageHMAC struct {
	// contains filtered or unexported fields
}

MessageHMAC is mainly used for test networks. It is applied to messages when creating them to make them incompatible with the main Secure Scuttlebutt network. MessageHMAC is not documented in the Protocol Guide as by default it is not applied, it is more of a convention.

See https://github.com/ssb-js/ssb-validate#state--validateappendstate-hmac_key-msg.

func MustNewMessageHMAC

func MustNewMessageHMAC(b []byte) MessageHMAC

func NewDefaultMessageHMAC

func NewDefaultMessageHMAC() MessageHMAC

NewDefaultMessageHMAC returns a MessageHMAC used by the main Secure Secuttlebutt network. This value effectively means that message HMAC should not be applied to messages.

func NewMessageHMAC

func NewMessageHMAC(b []byte) (MessageHMAC, error)

NewMessageHMAC creates a message HMAC from the provided slice of bytes. The slice must have a length of MessageHMACLength or 0. Passing slice of length 0 is equivalent to calling NewDefaultMessageHMAC which should be preferred for redability.

func (MessageHMAC) Bytes

func (k MessageHMAC) Bytes() []byte

Bytes returns the slice of length MessageHMACLength or nil if this is the default message HMAC.

func (MessageHMAC) IsZero

func (k MessageHMAC) IsZero() bool

type RawMessageIdentifier

type RawMessageIdentifier struct {
	// contains filtered or unexported fields
}

func NewRawMessageIdentifier

func NewRawMessageIdentifier(formats []feeds.FeedFormat) *RawMessageIdentifier

func (RawMessageIdentifier) LoadRawMessage

func (RawMessageIdentifier) PeekRawMessage

func (RawMessageIdentifier) VerifyRawMessage

func (i RawMessageIdentifier) VerifyRawMessage(raw message.RawMessage) (message.Message, error)

type Scuttlebutt

type Scuttlebutt struct {
	// contains filtered or unexported fields
}

func NewScuttlebutt

func NewScuttlebutt(
	parser ContentParser,
	hmac MessageHMAC,
) *Scuttlebutt

func (*Scuttlebutt) Load

func (s *Scuttlebutt) Load(verifiedRawMessage message.VerifiedRawMessage) (message.MessageWithoutId, error)

func (*Scuttlebutt) Peek

func (*Scuttlebutt) Sign

func (s *Scuttlebutt) Sign(unsigned message.UnsignedMessage, private identity.Private) (message.Message, error)

func (*Scuttlebutt) Verify

func (s *Scuttlebutt) Verify(raw message.RawMessage) (message.Message, error)

Jump to

Keyboard shortcuts

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