postrs

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClassCPU = DeviceClass((C.DeviceClass)(C.CPU))
	ClassGPU = DeviceClass((C.DeviceClass)(C.GPU))
)
View Source
const (
	// LabelLength is the length of the label in bytes.
	LabelLength = 16
)

Variables

View Source
var (
	ErrInvalidProviderID = errors.New("invalid provider ID")

	ErrInvalidLabelsRange = errors.New("invalid labels range")
	ErrOpenCL             = errors.New("OpenCL error")
	ErrInvalidArgument    = errors.New("invalid argument")
	ErrFetchProviders     = errors.New("failed to fetch providers")
	ErrUnknown            = errors.New("unknown error")
)

Functions

func CPUProviderID

func CPUProviderID() uint

func GenerateProof

func GenerateProof(dataDir string, challenge []byte, cfg config.Config, nonces uint, threads uint, powScrypt config.ScryptParams) (*shared.Proof, error)

func InitResultToError

func InitResultToError(retVal uint32) error

InitResultToError converts the return value of the C.initialize() function to a Go error.

func VerifyProof

func VerifyProof(proof *shared.Proof, metadata *shared.ProofMetadata, cfg config.Config, powScrypt, labelScrypt config.ScryptParams) error

Types

type DeviceClass

type DeviceClass int

DeviceClass is an enum for the type of device (CPU or GPU).

func (DeviceClass) String

func (c DeviceClass) String() string

type OptionFunc

type OptionFunc func(*option) error

func WithCommitment

func WithCommitment(commitment []byte) OptionFunc

func WithProviderID

func WithProviderID(id uint) OptionFunc

WithProviderID sets the ID of the openCL provider to use.

func WithScryptN

func WithScryptN(n uint32) OptionFunc

func WithStartAndEndPosition

func WithStartAndEndPosition(start, end uint64) OptionFunc

func WithVRFDifficulty

func WithVRFDifficulty(difficulty []byte) OptionFunc

type Provider

type Provider struct {
	ID         uint
	Model      string
	DeviceType DeviceClass
}

Provider is a struct that contains information about an OpenCL provider. libpostrs returns a list of these structs when calling cGetProviders(). Each Provider is an OpenCL platform + Device combination.

func OpenCLProviders

func OpenCLProviders() ([]Provider, error)

type ScryptPositionsResult

type ScryptPositionsResult struct {
	Output      []byte  // The output of the scrypt computation.
	IdxSolution *uint64 // The index of a solution to the proof of work (if checked for).
}

ScryptPositionsResult is the result of a ScryptPositions call.

func ScryptPositions

func ScryptPositions(opts ...OptionFunc) (ScryptPositionsResult, error)

ScryptPositions computes the scrypt output for the given options.

Jump to

Keyboard shortcuts

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