postrs

package
v0.6.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ClassUnspecified = 0
	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")
)
View Source
var ErrScryptClosed = errors.New("scrypt has been closed")

ErrScryptClosed is returned when calling a method on an already closed Scrypt instance.

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

OptionFunc is a function that sets an option for a Scrypt instance.

func WithCommitment

func WithCommitment(commitment []byte) OptionFunc

WithCommitment sets the commitment to use for the scrypt computation.

func WithProviderID

func WithProviderID(id uint) OptionFunc

WithProviderID sets the ID of the openCL provider to use.

func WithScryptN

func WithScryptN(n uint32) OptionFunc

WithScryptN sets the N parameter for the scrypt computation.

func WithVRFDifficulty

func WithVRFDifficulty(difficulty []byte) OptionFunc

WithVRFDifficulty sets the difficulty for the VRF nonce computation.

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 Scrypt added in v0.6.2

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

Scrypt is a scrypt computation instance. It communicates with post-rs to perform the scrypt computation on the GPU or CPU.

func NewScrypt added in v0.6.2

func NewScrypt(opts ...OptionFunc) (*Scrypt, error)

NewScrypt creates a new Scrypt instance.

func (*Scrypt) Close added in v0.6.2

func (s *Scrypt) Close() error

Close closes the Scrypt instance.

func (*Scrypt) Positions added in v0.6.2

func (s *Scrypt) Positions(start, end uint64) (ScryptPositionsResult, error)

Positions computes the scrypt output for the given options.

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.

Jump to

Keyboard shortcuts

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