Documentation
¶
Index ¶
- Constants
- Variables
- func CPUProviderID() uint
- func GenerateProof(dataDir string, challenge []byte, logger *zap.Logger, nonces uint, ...) (*shared.Proof, error)
- func InitResultToError(retVal uint32) error
- type DeviceClass
- type OptionFunc
- type PowFlags
- type Provider
- type Scrypt
- type ScryptParams
- type ScryptPositionsResult
- type Verifier
Constants ¶
const ( ClassUnspecified = 0 ClassCPU = DeviceClass((C.DeviceClass)(C.CPU)) ClassGPU = DeviceClass((C.DeviceClass)(C.GPU)) )
const ( // Use the full dataset. AKA "Fast mode". PowFastMode = C.RandomXFlag_FLAG_FULL_MEM // Allocate memory in large pages. PowLargePages = C.RandomXFlag_FLAG_LARGE_PAGES // Use JIT compilation support. PowJIT = C.RandomXFlag_FLAG_JIT // When combined with FLAG_JIT, the JIT pages are never writable and executable at the same time. PowSecure = C.RandomXFlag_FLAG_SECURE // Use hardware accelerated AES. PowHardAES = C.RandomXFlag_FLAG_HARD_AES // Optimize Argon2 for CPUs with the SSSE3 instruction set. PowArgon2SSSE3 = C.RandomXFlag_FLAG_ARGON2_SSSE3 // Optimize Argon2 for CPUs with the SSSE3 instruction set. PowArgon2AVX2 = C.RandomXFlag_FLAG_ARGON2_AVX2 // Optimize Argon2 for CPUs without the AVX2 or SSSE3 instruction sets. PowArgon2 = C.RandomXFlag_FLAG_ARGON2 )
const (
// LabelLength is the length of the label in bytes.
LabelLength = 16
)
Variables ¶
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") )
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 InitResultToError ¶
InitResultToError converts the return value of the C.initialize() function to a Go 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 WithLogger ¶ added in v0.6.3
func WithLogger(logger *zap.Logger) OptionFunc
WithLogger sets the logger to use.
func WithProviderID ¶
func WithProviderID(id uint) OptionFunc
WithProviderID sets the ID of the openCL provider to use.
func WithScryptN ¶
func WithScryptN(n uint) 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 PowFlags ¶ added in v0.7.0
type PowFlags = C.RandomXFlag
func GetRecommendedPowFlags ¶ added in v0.7.0
func GetRecommendedPowFlags() PowFlags
Get the recommended PoW flags.
Does not include: * FLAG_LARGE_PAGES * FLAG_FULL_MEM * FLAG_SECURE
The above flags need to be set manually, if required.
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 ¶
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.
type ScryptParams ¶ added in v0.7.0
type ScryptParams = C.ScryptParams
func TranslateScryptParams ¶ added in v0.7.0
func TranslateScryptParams(n, r, p uint) ScryptParams
Translate scrypt parameters expressed as N,R,P to Nfactor, Rfactor and Pfactor that are understood by scrypt-jane. Relation: N = 1 << (nfactor + 1) r = 1 << rfactor p = 1 << pfactor
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.
type Verifier ¶ added in v0.7.0
type Verifier struct {
// contains filtered or unexported fields
}
func NewVerifier ¶ added in v0.7.0
Create a new verifier. The verifier must be closed after use with Close().