common

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	P25 = 33554431 /* (1 << 25) - 1 */
	P26 = 67108863 /* (1 << 26) - 1 */
)
View Source
const (
	HASH_SIZE        int = 32
	HASHES_PER_SCOOP int = 2
	SCOOP_SIZE       int = 64
	SCOOPS_PER_PLOT  int = 4096
	PLOT_SIZE        int = 262144
	BASE_LENGTH      int = 16
	PLOT_TOTAL_SIZE  int = PLOT_SIZE + BASE_LENGTH
	HASH_CAP         int = 4096
)
View Source
const BlockSize = 64

The blocksize of SHABAL256 in bytes.

View Source
const Size = 32

The size of a SHABAL256 checksum in bytes.

Variables

View Source
var (
	ZERO = []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

	/* the prime 2^255-19 */
	PRIME = []byte{237, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
		255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 127}

	/* group order (a prime near 2^252+2^124) */
	ORDER = []byte{237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 16}

	/* smallest multiple of the order that's >= 2^255 */
	ORDER_TIMES_8 = []byte{104, 159, 174, 231, 210, 24, 147, 192, 178, 230, 188, 23, 245, 206, 247, 166, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 128}

	/* constants 2Gy and 1/(2Gy) */
	BASE_2Y  = long10{39999547, 18689728, 59995525, 1648697, 57546132, 24010086, 19059592, 5425144, 63499247, 16420658}
	BASE_R2Y = long10{5744, 8160848, 4790893, 13779497, 35730846, 12541209, 49101323, 30047407, 40071253, 6226132}
)
View Source
var SCOOPS_PER_PLOT_BIGINT *big.Int = big.NewInt(int64(SCOOPS_PER_PLOT))

Functions

func CalculateDeadline

func CalculateDeadline(accountId uint64, nonce uint64, genSig []byte, scoop int, baseTarget uint64, pocVersion int) uint64

func CalculateDeadlineOfPoc2

func CalculateDeadlineOfPoc2(accountId uint64, nonce uint64, genSig [32]byte, height uint64, baseTarget uint64) uint64

func CalculateGenerationSignature

func CalculateGenerationSignature(lastGenSig []byte, lastGenId uint64) []byte

func CalculateHit

func CalculateHit(accountId uint64, nonce uint64, genSig []byte, scoop int, pocVersion int) uint64

func CalculateScoop

func CalculateScoop(genSig []byte, height uint64) int

func ClampPrivateKey

func ClampPrivateKey(privateKey []byte)

func GetPublicKey

func GetPublicKey(privateKey []byte) [32]byte

func GetSharedSecret

func GetSharedSecret(privateKey []byte, publicKey []byte) [32]byte

func SignMsg

func SignMsg(message []byte, privateKey []byte) [64]byte

func Sum256

func Sum256(data []byte) [Size]byte

Sum256 returns the SHABAL256 checksum of the data.

func VerifyMsg

func VerifyMsg(message []byte, signature []byte, publicKey []byte, enforceCanonical bool) bool

Types

type Digest

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

digest represents the partial evaluation of a checksum.

func NewDegist

func NewDegist() *Digest

NewDegist returns a new hash.Hash computing the SHABAL256 checksum.

func (*Digest) BlockSize

func (d *Digest) BlockSize() int

func (*Digest) Reset

func (d *Digest) Reset()

func (*Digest) Size

func (d *Digest) Size() int

func (*Digest) Sum

func (d0 *Digest) Sum(in []byte) []byte

func (*Digest) Write

func (d *Digest) Write(p []byte) (int, error)

func (*Digest) Write1

func (d *Digest) Write1(p []byte, off uint32, nn int) (int, error)

type MiningPlot

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

func NewMiningPlot

func NewMiningPlot(accountId uint64, nonce uint64, pocVersion int) *MiningPlot

func (*MiningPlot) HashScoop

func (mp *MiningPlot) HashScoop(digist *Digest, pos int)

Jump to

Keyboard shortcuts

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