pow

package
v4.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SipHash24

func SipHash24(v [4]uint64, nonce uint64, rotE uint8) uint64

SipHash24 is an utility function to compute a single siphash 2-4 based on a seed and a nonce.

func SipHashBlock

func SipHashBlock(v [4]uint64, nonce uint64, rotE uint8, xorAll bool) uint64

SipHashBlock builds a block of siphash values by repeatedly hashing from the nonce truncated to its closest block start, up to the end of the block. Returns the resulting hash at the nonce's position.

Types

type CuckarooContext

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

CuckarooContext is a Cuckatoo cycle context. Only includes the verifier for now.

func NewCuckarooCtx

func NewCuckarooCtx(chainType consensus.ChainType, edgeBits uint8, proofSize int) *CuckarooContext

NewCuckarooCtx instantiates a new CuckarooContext as a PowContext

func (*CuckarooContext) SetHeaderNonce

func (c *CuckarooContext) SetHeaderNonce(header []uint8, nonce *uint32)

SetHeaderNonce sets the header nonce.

func (*CuckarooContext) Verify

func (c *CuckarooContext) Verify(proof Proof) error

Verify verifies the Cuckatoo context.

type CuckaroodContext

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

CuckaroodContext is a Cuckatoo cycle context. Only includes the verifier for now.

func NewCuckaroodCtx

func NewCuckaroodCtx(chainType consensus.ChainType, edgeBits uint8, proofSize int) *CuckaroodContext

NewCuckaroodCtx instantiates a new CuckaroodContext as a PowContext. Note that this can't be moved in the PoWContext trait as this particular trait needs to be convertible to an object trait.

func (*CuckaroodContext) SetHeaderNonce

func (c *CuckaroodContext) SetHeaderNonce(header []uint8, nonce *uint32)

SetHeaderNonce sets the header nonce.

func (*CuckaroodContext) Verify

func (c *CuckaroodContext) Verify(proof Proof) error

Verify verifies the Cuckatoo context.

type CuckaroomContext

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

CuckaroomContext is a Cuckaroom cycle context. Only includes the verifier for now.

func NewCuckaroomCtx

func NewCuckaroomCtx(chainType consensus.ChainType, edgeBits uint8, proofSize int) *CuckaroomContext

NewCuckaroomCtx instantiates a new CuckaroomContext as a PowContext. Note that this can't / be moved in the PoWContext trait as this particular trait needs to be / convertible to an object trait.

func (*CuckaroomContext) SetHeaderNonce

func (c *CuckaroomContext) SetHeaderNonce(header []uint8, nonce *uint32)

SetHeaderNonce sets the header nonce.

func (*CuckaroomContext) Verify

func (c *CuckaroomContext) Verify(proof Proof) error

Verify verifies the Cuckaroom context.

type CuckaroozContext

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

CuckaroozContext is a Cuckarooz cycle context. Only includes the verifier for now.

func NewCuckaroozCtx

func NewCuckaroozCtx(chainType consensus.ChainType, edgeBits uint8, proofSize int) *CuckaroozContext

NewCuckaroozCtx instantiates a new CuckaroozContext as a PowContext. Note that this can't / be moved in the PoWContext trait as this particular trait needs to be / convertible to an object trait.

func (*CuckaroozContext) SetHeaderNonce

func (c *CuckaroozContext) SetHeaderNonce(header []uint8, nonce *uint32)

SetHeaderNonce sets the header nonce.

func (*CuckaroozContext) Verify

func (c *CuckaroozContext) Verify(proof Proof) error

Verify verifies the Cuckaroom context.

type CuckatooContext

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

CuckatooContext is a Cuckatoo solver context.

func NewCuckatooCtx

func NewCuckatooCtx(chainType consensus.ChainType, edgeBits uint8, proofSize int, maxSols uint32) *CuckatooContext

NewCuckatooCtx instantiates a new CuckatooContext as a PowContext

func (*CuckatooContext) SetHeaderNonce

func (c *CuckatooContext) SetHeaderNonce(header []uint8, nonce *uint32)

SetHeaderNonce sets the header nonce.

func (*CuckatooContext) Verify

func (c *CuckatooContext) Verify(proof Proof) error

Verify verifies the Cuckatoo context.

type CuckooParams

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

CuckooParams is a utility struct to calculate commonly used Cuckoo parameters calculated from header, nonce, edge_bits, etc.

type PowContext

type PowContext interface {
	// Sets the header along with an optional nonce at the end solve: whether to
	// set up structures for a solve (true) or just validate (false)
	SetHeaderNonce(header []uint8, nonce *uint32)
	// Verify a solution with the stored parameters
	Verify(proof Proof) error
}

PowContext is a generic interface for a solver/verifier providing common interface into Cuckoo-family PoW

type Proof

type Proof struct {
	// Power of 2 used for the size of the cuckoo graph
	EdgeBits uint8
	// The nonces
	Nonces []uint64
}

Proof is a Cuck(at)oo Cycle proof of work, consisting of the edge_bits to get the graph size (i.e. the 2-log of the number of edges) and the nonces of the graph solution. While being expressed as u64 for simplicity, nonces a.k.a. edge indices range from 0 to (1 << edge_bits) - 1

The hash of the `Proof` is the hash of its packed nonces when serializing them at their exact bit size. The resulting bit sequence is padded to be byte-aligned.

type ProofOfWork

type ProofOfWork struct {
	// Total accumulated difficulty since genesis block
	TotalDifficulty uint64
	// Variable difficulty scaling factor fo secondary proof of work
	SecondaryScaling uint32
	// Nonce increment used to mine this block.
	Nonce uint64
	// Proof of work data.
	Proof Proof
}

ProofOfWork is a block header information pertaining to the proof of work

func (*ProofOfWork) EdgeBits

func (p *ProofOfWork) EdgeBits() uint8

EdgeBits is the edge bits used for the cuckoo cycle size on this proof

func (*ProofOfWork) IsPrimary

func (p *ProofOfWork) IsPrimary() bool

IsPrimary is whether this proof of work is for the primary algorithm (as opposed / to secondary). Only depends on the edge_bits at this time.

func (*ProofOfWork) IsSecondary

func (p *ProofOfWork) IsSecondary() bool

IsSecondary is whether this proof of work is for the secondary algorithm (as opposed / to primary). Only depends on the edge_bits at this time.

Jump to

Keyboard shortcuts

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