Documentation ¶
Index ¶
- Constants
- Variables
- func GetIntermediaryId(id *id.ID) ([]byte, error)
- func GetOffset(intermediaryId []byte) int64
- func GetOffsetBounds(offset, timestamp int64) (time.Time, time.Time, uint64)
- func GetOffsetNum(offset int64) int64
- func HandleQuantization(start time.Time) (int64, int32)
- func IsReserved(eid Id) bool
- type Id
- type ProtoIdentity
Constants ¶
const ( // IdLen is the length of an ephemeral [Id]. IdLen = 8 Period = int64(time.Hour * 24) NumOffsets int64 = 1 << 16 NsPerOffset = Period / NumOffsets )
Variables ¶
var ReservedIDs = []Id{
{0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1},
}
ReservedIDs are ephemeral IDs reserved for specific actions:
- All zeros denote a dummy ID
- All ones denote a payment
Functions ¶
func GetIntermediaryId ¶
GetIntermediaryId returns an intermediary ID for the ephemeral ID creation (ID hash).
func GetOffsetNum ¶
func IsReserved ¶
IsReserved checks if the Id is among the reserved global reserved ID list. Returns true if reserved, false if non-reserved.
Types ¶
type Id ¶
Id is the ephemeral ID type.
func GetId ¶
GetId returns ephemeral ID based on the passed in ID. Accepts an ID, ID size in bits, and timestamp in nanoseconds. Returns an ephemeral ID and the start and end timestamps for the salt window.
func GetIdFromIntermediary ¶
func GetIdFromIntermediary(iid []byte, size uint, timestamp int64) ( Id, time.Time, time.Time, error)
GetIdFromIntermediary returns the ephemeral ID from intermediary (ID hash). Accepts an intermediary ephemeral ID, ID size in bits, and timestamp in nanoseconds. Returns an ephemeral ID and the start and end timestamps for salt window.
func (Id) Fill ¶
Fill sets the bits of an ID with random data from passed in rng. The size of the ID is in bits.
func (Id) MarshalJSON ¶
MarshalJSON marshals the ephemeral Id into valid JSON. This function adheres to the json.Marshaler interface.
func (*Id) UnmarshalJSON ¶
UnmarshalJSON unmarshalls the JSON into the ephemeral Id. This function adheres to the json.Unmarshaler interface.
type ProtoIdentity ¶
ProtoIdentity contains the ID and the start and end time for the salt window.
func GetIdsByRange ¶
func GetIdsByRange(id *id.ID, size uint, timestamp time.Time, timeRange time.Duration) ([]ProtoIdentity, error)
GetIdsByRange returns ephemeral IDs based on passed in ID and a time range. Accepts an ID, ID size in bits, timestamp, and a time range. Returns a list of ephemeral IDs.