nonce

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-2-Clause Imports: 3 Imported by: 2

Documentation

Overview

Package nonce contains our implementation of a nonce, including an expiration time, generation time and TTL.

Index

Constants

View Source
const (
	// Length of Nonce in bytes
	// 256 bits
	NonceLen = 32

	// TTL of registration nonce in seconds
	RegistrationTTL = 180
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Nonce

type Nonce struct {
	Value      `json:"value"`
	GenTime    time.Time     `json:"genTime"`
	ExpiryTime time.Time     `json:"expiryTime"`
	TTL        time.Duration `json:"TTL"`
}

func NewNonce

func NewNonce(ttl uint) (Nonce, error)

NewNonce generate a fresh nonce with the given TTL in seconds

func (Nonce) Bytes

func (n Nonce) Bytes() []byte

Bytes returns the nonce's value in a byte slice

func (Nonce) IsValid

func (n Nonce) IsValid() bool

IsValid checks that the nonce has not expired

type Value

type Value [NonceLen]byte

Jump to

Keyboard shortcuts

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