Documentation ¶
Index ¶
- Variables
- func WithConfig(cfg Config) newRegistrationOptionFunc
- func WithPowVerifier(verifier PowVerifier) newRegistrationOptionFunc
- func WithPrivateKey(privKey ed25519.PrivateKey) newRegistrationOptionFunc
- type Base64Enc
- type CertifierConfig
- type Config
- type PowParams
- type PowVerifier
- type Registration
- func (r *Registration) CertifierInfo() *CertifierConfig
- func (r *Registration) Close() error
- func (r *Registration) LoadTrustedPublicKeys(ctx context.Context) error
- func (r *Registration) OpenRound() uint
- func (r *Registration) PowParams() PowParams
- func (r *Registration) Proof(ctx context.Context, roundId string) (*proofData, error)
- func (r *Registration) Pubkey() ed25519.PublicKey
- func (r *Registration) Run(ctx context.Context) error
- func (r *Registration) Submit(ctx context.Context, challenge, nodeID []byte, nonce uint64, ...) (epoch uint, roundEnd time.Time, err error)
- type WorkerService
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidPow = errors.New("invalid proof of work") ErrInvalidPowParams = errors.New("invalid proof of work parameters") )
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") )
var ( ErrMaxMembersReached = errors.New("maximum number of round members reached") ErrChallengeAlreadySubmitted = errors.New("challenge is already submitted") ErrConflictingRegistration = errors.New("conflicting registration") )
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) UnmarshalFlag ¶ added in v0.10.0
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 ¶
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