Documentation ¶
Overview ¶
Package types defines types shared between server and client.
Index ¶
- Variables
- func GetTimeFrame(keys []MatchKey) (validFrom, validTo uint64)
- type MatchKey
- type PregenerateEntry
- type RPCTypeDecrypt
- type RPCTypeDecryptResponse
- type RPCTypeGetKeysResponse
- type RPCTypeNone
- type RatchetList
- func (rl *RatchetList) Append(e PregenerateEntry)
- func (rl *RatchetList) Bytes() []byte
- func (rl *RatchetList) FindRatchetKeys(validFrom, validTo uint64) []MatchKey
- func (rl *RatchetList) Parse(d []byte) (*RatchetList, error)
- func (rl *RatchetList) Sign(privateKey *[ed25519.PrivateKeySize]byte)
- func (rl *RatchetList) Verify(expectPubkey *[ed25519.PublicKeySize]byte) bool
Constants ¶
This section is empty.
Variables ¶
var ErrParse = errors.New("types: parsing error")
ErrParse is returned in case of a parsing error.
Functions ¶
func GetTimeFrame ¶
GetTimeFrame returns the timeframe covered by the MatchKeys, holes are ignored!
Types ¶
type PregenerateEntry ¶
type PregenerateEntry struct { LineHash [32]byte // Hash of this line, incorporates previous one. Counter uint64 // Output counter of ratchet. ValidFrom uint64 // Time this entry becomes valid. ValidTo uint64 // Time this entry becomes invalid. PublicKey [32]byte // Public key of this entry. }
PregenerateEntry is a pregenerated Ratchet Key.
func NewPregenerateEntry ¶
func NewPregenerateEntry(previousHash *[32]byte, counter, validFrom, validTo uint64, publicKey [32]byte) *PregenerateEntry
NewPregenerateEntry creates a new PreGenerateEntry with the valid hash calculated. Setting previousHash nil means first entry in list for fountain.
func Unmarshall ¶
func Unmarshall(entry *[pageEntryMarshallSize]byte) *PregenerateEntry
Unmarshall a pregenerate entry.
func (*PregenerateEntry) Copy ¶
func (pge *PregenerateEntry) Copy() *PregenerateEntry
Copy PregenerateEntry.
func (*PregenerateEntry) Hash ¶
func (pge *PregenerateEntry) Hash(previous *[32]byte)
Hash an entry.
func (*PregenerateEntry) Marshall ¶
func (pge *PregenerateEntry) Marshall() *[pageEntryMarshallSize]byte
Marshall a PregenerateEntry.
func (*PregenerateEntry) Validate ¶
func (pge *PregenerateEntry) Validate(previous *[32]byte) bool
Validate PregenerateEntry.
type RPCTypeDecrypt ¶
type RPCTypeDecrypt struct {
OracleMessage []byte
}
RPCTypeDecrypt is the request for a Cypherlock server to decrypt the contained binary OracleMessage.
type RPCTypeDecryptResponse ¶
type RPCTypeDecryptResponse struct {
ResponseMessage []byte
}
RPCTypeDecryptResponse is the response from a Cypherlock server that contains the binary ResponseMessage.
type RPCTypeGetKeysResponse ¶
type RPCTypeGetKeysResponse struct {
Keys []byte
}
RPCTypeGetKeysResponse is the response by a Cypherlock server containing a binary keylist.
type RPCTypeNone ¶
type RPCTypeNone struct{}
RPCTypeNone is an empty RPC type to fullfil API requirements.
type RatchetList ¶
type RatchetList struct { PreviousLineHash [32]byte // Last LineHash of previous list. Ignored for now. PublicKeys []PregenerateEntry // Pregenerated items. ListHash [32]byte // Hash of list. EnvelopeKey [32]byte // Curve25519 envelope key, long term. SignatureKey [ed25519.PublicKeySize]byte // Long term signature key of server. Signature [ed25519.SignatureSize]byte // Signature over the above. // contains filtered or unexported fields }
RatchetList is a list of ratchet keys.
func NewRatchetList ¶
func NewRatchetList(previousLineHash [32]byte, expectedLength int) *RatchetList
NewRatchetList returns a new ratchet list. New, Append, set SignatureKey and EnvelopeKey, Sign.
func (*RatchetList) Append ¶
func (rl *RatchetList) Append(e PregenerateEntry)
Append an entry to the list.
func (*RatchetList) Bytes ¶
func (rl *RatchetList) Bytes() []byte
Bytes returns the marshalled bytes, only valid after signing.
func (*RatchetList) FindRatchetKeys ¶
func (rl *RatchetList) FindRatchetKeys(validFrom, validTo uint64) []MatchKey
FindRatchetKeys finds keys that fit the validFrom/validTo policy. Returns nil if non found.
func (*RatchetList) Parse ¶
func (rl *RatchetList) Parse(d []byte) (*RatchetList, error)
Parse a binary RatchetList into struct.
func (*RatchetList) Sign ¶
func (rl *RatchetList) Sign(privateKey *[ed25519.PrivateKeySize]byte)
Sign RatchetList. Make sure EnvelopeKey and SignatureKey are set.
func (*RatchetList) Verify ¶
func (rl *RatchetList) Verify(expectPubkey *[ed25519.PublicKeySize]byte) bool
Verify if a signature in a RatchetList matches the list. Import, list must be parsed or created by API. expectPubkey is only verified if not nil.