Documentation
¶
Overview ¶
Contains the generic ID type, which is a byte array that represents an entity ID. The first bytes in the array contain the actual ID data while the last byte contains the ID type, which is either generic, gateway, node, or user. IDs can be hard coded or generated using a cryptographic function found in crypto.
Index ¶
- Constants
- Variables
- func CollidesWithHardCodedID(testID *ID) bool
- type ID
- func GetHardCodedIDs() (ids []*ID)
- func NewIDListFromBytes(topology [][]byte) ([]*ID, error)
- func NewIdFromBytes(data []byte, x interface{}) *ID
- func NewIdFromString(idString string, idType Type, x interface{}) *ID
- func NewIdFromUInt(idUInt uint64, idType Type, x interface{}) *ID
- func NewIdFromUInts(idUInts [4]uint64, idType Type, x interface{}) *ID
- func Unmarshal(data []byte) (*ID, error)
- type Round
- type Type
Constants ¶
const ( Generic = Type(iota) Gateway Node User NumTypes // Gives number of ID types )
List of ID types
const (
// Length of the full ID array
ArrIDLen = dataLen + 1
)
Variables ¶
var DummyUser = ID{100, 117, 109, 109, 121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(User)}
ID for a dummy user (ID data is the string "dummy")
var NotificationBot = ID{110, 111, 116, 105, 102, 105, 99, 97, 116, 105, 111, 110, 45, 98, 111, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(Generic)}
ID for notification bot (ID data is the string "notification-bot")
var Permissioning = ID{80, 101, 114, 109, 105, 115, 115, 105, 111, 110, 105, 110, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(Generic)}
ID for permissioning (ID data is the string "Permissioning")
var TempGateway = ID{116, 109, 112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(Gateway)}
ID for a temporary gateway (ID data is the string "tmp")
var UDB = ID{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(User)}
ID for UDB (ID data is in the range of dummy IDs)
var ZeroUser = ID{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, byte(User)}
ID for a user with the ID data all zeroes
Functions ¶
func CollidesWithHardCodedID ¶
CollidesWithHardCodedID searches if the given ID collides with any hard coded IDs. If it collides, then the function returns true. Otherwise, it returns false.
Types ¶
type ID ¶
ID is an array holding the generic identifier. The first 32 bytes hold the ID data and the last byte holds the ID type.
func GetHardCodedIDs ¶
func GetHardCodedIDs() (ids []*ID)
GetHardCodedIDs returns an array of all the hard coded IDs.
func NewIDListFromBytes ¶
NewIDListFromBytes creates a list of IDs from a list of byte slices. On success, it returns a new list. On failure, it returns a nil list and an error.
func NewIdFromBytes ¶
NewIdFromBytes creates a new ID from a copy of the data. It is similar to Unmarshal() but does not do any error checking. If the data is longer than ArrIDLen, then it is truncated. If it is shorter, then the remaining bytes are filled with zeroes. This function is for testing purposes only.
func NewIdFromString ¶
NewIdFromString creates a new ID from the given string and type. If the string is longer than dataLen, then it is truncated. If it is shorter, then the remaining bytes are filled with zeroes. This function is for testing purposes only.
func NewIdFromUInt ¶
NewIdFromUInt converts the specified uint64 into bytes and returns a new ID based off it with the specified ID type. The remaining space of the array is filled with zeros. This function is for testing purposes only.
func NewIdFromUInts ¶
NewIdFromUInt converts the specified uint64 array into bytes and returns a new ID based off it with the specified ID type. Unlike NewIdFromUInt(), the four uint64s provided fill the entire ID array. This function is for testing purposes only.
func (*ID) Bytes ¶
Bytes returns a copy of an ID as a byte slice. Note that Bytes() is used by Marshal() and any changes made here will affect how Marshal() functions.
func (*ID) Cmp ¶
Cmp determines whether two IDs are the same. Returns true if they are equal and false otherwise.