registration

package
v0.10.10 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPow       = errors.New("invalid proof of work")
	ErrInvalidPowParams = errors.New("invalid proof of work parameters")
)
View Source
var (
	ErrInvalidCertificate          = errors.New("invalid certificate")
	ErrTooLateToRegister           = errors.New("too late to register for the desired round")
	ErrCertificationIsNotSupported = errors.New("certificate is not supported")
	ErrTrustedKeyDirPathIsNotSet   = errors.New("trusted keys directory path is not set in the configuration")
	ErrNoMatchingCertPublicKeys    = errors.New("no matching cert public keys")
	ErrInvalidPublicKey            = errors.New("invalid public key")
)
View Source
var (
	ErrMaxMembersReached         = errors.New("maximum number of round members reached")
	ErrChallengeAlreadySubmitted = errors.New("challenge is already submitted")
	ErrConflictingRegistration   = errors.New("conflicting registration")
)
View Source
var ErrNotFound = leveldb.ErrNotFound

Functions

func WithConfig

func WithConfig(cfg Config) newRegistrationOptionFunc

func WithPowVerifier

func WithPowVerifier(verifier PowVerifier) newRegistrationOptionFunc

func WithPrivateKey

func WithPrivateKey(privKey ed25519.PrivateKey) newRegistrationOptionFunc

Types

type Base64Enc added in v0.10.0

type Base64Enc []byte

func (*Base64Enc) Bytes added in v0.10.0

func (k *Base64Enc) Bytes() []byte

func (*Base64Enc) UnmarshalFlag added in v0.10.0

func (k *Base64Enc) UnmarshalFlag(value string) error

type CertifierConfig added in v0.10.0

type CertifierConfig struct {
	URL                string    `long:"certifier-url"             description:"The URL of the certifier service"`
	PubKey             Base64Enc `long:"certifier-pubkey"          description:"The public key of the certifier service (base64 encoded)"`
	TrustedKeysDirPath string    `long:"trusted-pub-keys-dir-path" description:"The path to directory with trusted public keys"`
}

Configuration of registration certificates.

Support for registering with certificates is enabled by setting at least one of:

  • `PubKey`
  • `TrustedKeysDirPath`

The `PubKey` is the public key of the certifier exposed via the URL field. It is legacy and doesn't require the client to pass a key hint. A Submit() without a hint will use this key.

The `TrustedKeysDirPath` allows for configuring more than one key, but without a URL to the related certifier(s). To use certificates signed with the private part of these keys, the client must pass a key hint to Submit(). The keys are loaded on boot and on demand and together with the `PubKey` form a set of trusted keys.

func (*CertifierConfig) MarshalLogObject added in v0.10.0

func (c *CertifierConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error

implement zap.ObjectMarshaler interface.

type Config

type Config struct {
	// FIXME: remove deprecated PoW
	PowDifficulty uint `long:"pow-difficulty" description:"(DEPRECATED) PoW difficulty (in the number of leading zero bits)"`

	MaxRoundMembers     int           `long:"max-round-members"     description:"the maximum number of members in a round"`
	MaxSubmitBatchSize  int           `long:"max-submit-batch-size" description:"The maximum number of challenges to submit in a single batch"`
	SubmitFlushInterval time.Duration `long:"submit-flush-interval" description:"The interval between flushes of the submit queue"`

	Certifier *CertifierConfig
}

func DefaultConfig

func DefaultConfig() Config

type PowParams

type PowParams struct {
	Challenge []byte
	// Difficulty is the number of leading zero bits required in the hash
	Difficulty uint
}

func NewPowParams

func NewPowParams(challenge []byte, difficulty uint) PowParams

func (PowParams) Equal

func (p PowParams) Equal(other PowParams) bool

type PowVerifier

type PowVerifier interface {
	// Verify the proof of work.
	//
	// PoW hash is ripemd256(powChallenge || nodeID || poetChallenge || nonce)
	Verify(poetChallenge, nodeID []byte, nonce uint64) error
	Params() PowParams
	SetParams(params PowParams)
}

func NewPowVerifier

func NewPowVerifier(params PowParams) PowVerifier

type Registration

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

Registration orchestrates rounds functionality It is responsible for:

  • registering challenges,
  • scheduling rounds,
  • feeding workers with membership tree roots for proof generation,
  • serving proofs.

func New

func New(
	ctx context.Context,
	genesis time.Time,
	dbdir string,
	workerSvc WorkerService,
	roundCfg roundConfig,
	opts ...newRegistrationOptionFunc,
) (*Registration, error)

func (*Registration) CertifierInfo added in v0.10.0

func (r *Registration) CertifierInfo() *CertifierConfig

func (*Registration) Close

func (r *Registration) Close() error

func (*Registration) LoadTrustedPublicKeys added in v0.10.6

func (r *Registration) LoadTrustedPublicKeys(ctx context.Context) error

func (*Registration) OpenRound added in v0.9.6

func (r *Registration) OpenRound() uint

func (*Registration) PowParams

func (r *Registration) PowParams() PowParams

func (*Registration) Proof

func (r *Registration) Proof(ctx context.Context, roundId string) (*proofData, error)

func (*Registration) Pubkey

func (r *Registration) Pubkey() ed25519.PublicKey

func (*Registration) Run

func (r *Registration) Run(ctx context.Context) error

func (*Registration) Submit

func (r *Registration) Submit(
	ctx context.Context,
	challenge, nodeID []byte,

	nonce uint64,
	powParams PowParams,
	certPubkeyHint *shared.CertKeyHint,
	certificate *shared.OpaqueCert,
	deadline time.Time,
) (epoch uint, roundEnd time.Time, err error)

type WorkerService

type WorkerService interface {
	ExecuteRound(ctx context.Context, epoch uint, membershipRoot []byte) error
	RegisterForProofs(ctx context.Context) <-chan shared.NIP
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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