chiapos

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPlotSize = 32
	MaxPlotSize = 50
)
View Source
const (
	// PrivateKeyBytes is the length of a BLS private key
	PrivateKeyBytes = 32

	// PublicKeyBytes is the length of a BLS public key
	PublicKeyBytes = 48

	// SignatureBytes is the length of a BLS signature
	SignatureBytes = 96
)

Variables

View Source
var ZeroID = [32]byte{}

Functions

func AggregateVerify

func AggregateVerify(schemeType SchemeMPLType, pks []*G1Element, datas [][]byte, signature *G2Element) (bool, error)

func CalculatePlotFilterInput

func CalculatePlotFilterInput(plotID, challenge [32]byte) [32]byte

func CalculatePosChallenge

func CalculatePosChallenge(plotID, challenge [32]byte) [32]byte

func Hash256

func Hash256(data []byte) (hash [32]byte)

Hash256 return zero if no data

func PassPlotFilter

func PassPlotFilter(plotID, challenge [32]byte) bool

func Verify

func Verify(schemeType SchemeMPLType, pk *G1Element, data []byte, signature *G2Element) (bool, error)

Types

type AugSchemeMPL

type AugSchemeMPL struct{}

func NewAugSchemeMPL

func NewAugSchemeMPL() *AugSchemeMPL

func (*AugSchemeMPL) Aggregate

func (s *AugSchemeMPL) Aggregate(signatures ...*G2Element) (*G2Element, error)

func (*AugSchemeMPL) AggregateVerify

func (s *AugSchemeMPL) AggregateVerify(pks []*G1Element, datas [][]byte, signature *G2Element) (bool, error)

func (*AugSchemeMPL) DeriveChildPkUnhardened

func (s *AugSchemeMPL) DeriveChildPkUnhardened(pk *G1Element, index int) (*G1Element, error)

func (*AugSchemeMPL) DeriveChildSk

func (s *AugSchemeMPL) DeriveChildSk(sk *PrivateKey, index int) (*PrivateKey, error)

func (*AugSchemeMPL) DeriveChildSkUnhardened

func (s *AugSchemeMPL) DeriveChildSkUnhardened(sk *PrivateKey, index int) (*PrivateKey, error)

func (*AugSchemeMPL) KeyGen

func (s *AugSchemeMPL) KeyGen(seed []byte) (*PrivateKey, error)

func (*AugSchemeMPL) Sign

func (s *AugSchemeMPL) Sign(sk *PrivateKey, data []byte) (*G2Element, error)

func (*AugSchemeMPL) SignPrepend

func (s *AugSchemeMPL) SignPrepend(sk *PrivateKey, data []byte, pk *G1Element) (*G2Element, error)

func (*AugSchemeMPL) SkToG1

func (s *AugSchemeMPL) SkToG1(sk *PrivateKey) (*G1Element, error)

func (*AugSchemeMPL) Verify

func (s *AugSchemeMPL) Verify(pk *G1Element, data []byte, signature *G2Element) (bool, error)

type BasicSchemeMPL

type BasicSchemeMPL struct{}

func NewBasicSchemeMPL

func NewBasicSchemeMPL() *BasicSchemeMPL

func (*BasicSchemeMPL) Aggregate

func (s *BasicSchemeMPL) Aggregate(signatures ...*G2Element) (*G2Element, error)

func (*BasicSchemeMPL) AggregateVerify

func (s *BasicSchemeMPL) AggregateVerify(pks []*G1Element, datas [][]byte, signature *G2Element) (bool, error)

func (*BasicSchemeMPL) DeriveChildPkUnhardened

func (s *BasicSchemeMPL) DeriveChildPkUnhardened(pk *G1Element, index int) (*G1Element, error)

func (*BasicSchemeMPL) DeriveChildSk

func (s *BasicSchemeMPL) DeriveChildSk(sk *PrivateKey, index int) (*PrivateKey, error)

func (*BasicSchemeMPL) DeriveChildSkUnhardened

func (s *BasicSchemeMPL) DeriveChildSkUnhardened(sk *PrivateKey, index int) (*PrivateKey, error)

func (*BasicSchemeMPL) KeyGen

func (s *BasicSchemeMPL) KeyGen(seed []byte) (*PrivateKey, error)

func (*BasicSchemeMPL) Sign

func (s *BasicSchemeMPL) Sign(sk *PrivateKey, data []byte) (*G2Element, error)

func (*BasicSchemeMPL) SkToG1

func (s *BasicSchemeMPL) SkToG1(sk *PrivateKey) (*G1Element, error)

SkToG1 return PublicKey

func (*BasicSchemeMPL) Verify

func (s *BasicSchemeMPL) Verify(pk *G1Element, data []byte, signature *G2Element) (bool, error)

type DiskPlotter

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

func NewDiskPlotter

func NewDiskPlotter() (*DiskPlotter, error)

func (*DiskPlotter) Close

func (p *DiskPlotter) Close() error

func (*DiskPlotter) CreatePlotDisk

func (p *DiskPlotter) CreatePlotDisk(
	tmpDir, tmp2Dir, finalDir, filename string,
	k uint8, memo, plotSeed []byte,
	buffMegabytes, numBuckets, stripeSize uint32, numThreads uint8,
	noBitfield bool,
) error

type DiskProver

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

func NewDiskProver

func NewDiskProver(filename string, loadPlotInfo bool) (*DiskProver, error)

func (*DiskProver) Close

func (dp *DiskProver) Close() error

func (*DiskProver) Filename

func (dp *DiskProver) Filename() string

func (*DiskProver) GetFullProof

func (dp *DiskProver) GetFullProof(challenge [32]byte, index uint32) ([]byte, error)

func (*DiskProver) GetQualitiesForChallenge

func (dp *DiskProver) GetQualitiesForChallenge(challenge [32]byte) ([][]byte, error)

func (*DiskProver) ID

func (dp *DiskProver) ID() [32]byte

func (*DiskProver) Memo

func (dp *DiskProver) Memo() []byte

func (*DiskProver) PlotInfo

func (dp *DiskProver) PlotInfo() *PlotInfo

func (*DiskProver) Size

func (dp *DiskProver) Size() uint8

type G1Element

type G1Element [PublicKeyBytes]byte

func DeriveChildPkUnhardened

func DeriveChildPkUnhardened(schemeType SchemeMPLType, pk *G1Element, index int) (*G1Element, error)

func NewG1Element

func NewG1Element() *G1Element

Initialization to point at infinity

func NewG1ElementFromBytes

func NewG1ElementFromBytes(bytes []byte) (*G1Element, error)

func NewG1ElementGenerator

func NewG1ElementGenerator() *G1Element

func SkToG1

func SkToG1(schemeType SchemeMPLType, sk *PrivateKey) (*G1Element, error)

func (*G1Element) Add

func (e *G1Element) Add(target *G1Element) (*G1Element, error)

func (*G1Element) Bytes

func (e *G1Element) Bytes() []byte

func (*G1Element) Copy

func (e *G1Element) Copy() *G1Element

func (*G1Element) Equals

func (e *G1Element) Equals(target *G1Element) bool

func (*G1Element) SerializeCompressed

func (e *G1Element) SerializeCompressed() []byte

func (*G1Element) SerializeUncompressed

func (e *G1Element) SerializeUncompressed() []byte

no difference with SerializeCompressed

type G2Element

type G2Element [SignatureBytes]byte

func AggregateSignatures

func AggregateSignatures(schemeType SchemeMPLType, signatures ...*G2Element) (*G2Element, error)

func NewG2Element

func NewG2Element() *G2Element

Initialization to point at infinity

func NewG2ElementFromBytes

func NewG2ElementFromBytes(bytes []byte) (*G2Element, error)

func NewG2ElementGenerator

func NewG2ElementGenerator() *G2Element

func Sign

func Sign(schemeType SchemeMPLType, sk *PrivateKey, data []byte) (*G2Element, error)

func (*G2Element) Add

func (e *G2Element) Add(target *G2Element) (*G2Element, error)

func (*G2Element) Bytes

func (e *G2Element) Bytes() []byte

func (*G2Element) Copy

func (e *G2Element) Copy() *G2Element

func (*G2Element) Equals

func (e *G2Element) Equals(target *G2Element) bool

func (*G2Element) Serialize

func (e *G2Element) Serialize() []byte

type PlotInfo

type PlotInfo struct {
	PoolPublicKey   *G1Element
	PuzzleHash      [32]byte
	FarmerPublicKey *G1Element
	MasterSk        *PrivateKey
	LocalSk         *PrivateKey
	PlotPublicKey   *G1Element
}

type PopSchemeMPL

type PopSchemeMPL struct{}

func NewPopSchemeMPL

func NewPopSchemeMPL() *PopSchemeMPL

func (*PopSchemeMPL) Aggregate

func (s *PopSchemeMPL) Aggregate(signatures ...*G2Element) (*G2Element, error)

func (*PopSchemeMPL) AggregateVerify

func (s *PopSchemeMPL) AggregateVerify(pks []*G1Element, datas [][]byte, signature *G2Element) (bool, error)

func (*PopSchemeMPL) DeriveChildPkUnhardened

func (s *PopSchemeMPL) DeriveChildPkUnhardened(pk *G1Element, index int) (*G1Element, error)

func (*PopSchemeMPL) DeriveChildSk

func (s *PopSchemeMPL) DeriveChildSk(sk *PrivateKey, index int) (*PrivateKey, error)

func (*PopSchemeMPL) DeriveChildSkUnhardened

func (s *PopSchemeMPL) DeriveChildSkUnhardened(sk *PrivateKey, index int) (*PrivateKey, error)

func (*PopSchemeMPL) FastAggregateVerify

func (s *PopSchemeMPL) FastAggregateVerify(pks []*G1Element, data []byte, signature *G2Element) (bool, error)

func (*PopSchemeMPL) KeyGen

func (s *PopSchemeMPL) KeyGen(seed []byte) (*PrivateKey, error)

func (*PopSchemeMPL) PopProve

func (s *PopSchemeMPL) PopProve(sk *PrivateKey) (*G2Element, error)

func (*PopSchemeMPL) PopVerify

func (s *PopSchemeMPL) PopVerify(pk *G1Element, signature *G2Element) (bool, error)

func (*PopSchemeMPL) Sign

func (s *PopSchemeMPL) Sign(sk *PrivateKey, data []byte) (*G2Element, error)

func (*PopSchemeMPL) SkToG1

func (s *PopSchemeMPL) SkToG1(sk *PrivateKey) (*G1Element, error)

func (*PopSchemeMPL) Verify

func (s *PopSchemeMPL) Verify(pk *G1Element, data []byte, signature *G2Element) (bool, error)

type PrivateKey

type PrivateKey [PrivateKeyBytes]byte

func AggregatePrivateKey

func AggregatePrivateKey(sks ...*PrivateKey) (*PrivateKey, error)

func AugDerivePath

func AugDerivePath(master *PrivateKey, paths []int) (key *PrivateKey, err error)

func DeriveChildSk

func DeriveChildSk(schemeType SchemeMPLType, unhardened bool, sk *PrivateKey, index int) (*PrivateKey, error)

TODO: check param

func KeyGen

func KeyGen(schemeType SchemeMPLType, seed []byte) (*PrivateKey, error)

func MasterSkToFarmerSk

func MasterSkToFarmerSk(master *PrivateKey) (*PrivateKey, error)

func MasterSkToLocalSk

func MasterSkToLocalSk(master *PrivateKey) (*PrivateKey, error)

func MasterSkToPoolSk

func MasterSkToPoolSk(master *PrivateKey) (*PrivateKey, error)

func NewPrivateKeyFromBytes

func NewPrivateKeyFromBytes(bytes []byte) (*PrivateKey, error)

func (*PrivateKey) Bytes

func (k *PrivateKey) Bytes() []byte

func (*PrivateKey) Copy

func (k *PrivateKey) Copy() *PrivateKey

func (*PrivateKey) Equals

func (k *PrivateKey) Equals(target *PrivateKey) bool

func (*PrivateKey) GetG1

func (k *PrivateKey) GetG1() (*G1Element, error)

type ProofOfSpace

type ProofOfSpace struct {
	Challenge     [32]byte
	PoolPublicKey *G1Element
	PuzzleHash    [32]byte
	PlotPublicKey *G1Element
	KSize         uint8
	Proof         []byte
}

func (*ProofOfSpace) Decode

func (pos *ProofOfSpace) Decode(data []byte) (err error)

func (*ProofOfSpace) Encode

func (pos *ProofOfSpace) Encode() []byte

func (*ProofOfSpace) GetID

func (pos *ProofOfSpace) GetID() ([32]byte, error)

func (*ProofOfSpace) GetQuality

func (pos *ProofOfSpace) GetQuality() ([]byte, error)

func (*ProofOfSpace) GetVerifiedQuality

func (pos *ProofOfSpace) GetVerifiedQuality(challenge [32]byte) ([]byte, error)

type ProofVerifier

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

func NewProofVerifier

func NewProofVerifier() *ProofVerifier

func (*ProofVerifier) Free

func (pv *ProofVerifier) Free()

func (*ProofVerifier) GetVerifiedQuality

func (pv *ProofVerifier) GetVerifiedQuality(plotSeed, proof []byte, challenge [32]byte, k int) ([]byte, error)

type SchemeMPLType

type SchemeMPLType int
const (
	SchemeMPLBasic SchemeMPLType = 1 + iota
	SchemeMPLAug
	SchemeMPLPop
)

Jump to

Keyboard shortcuts

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