ffi

package module
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0, MIT Imports: 7 Imported by: 0

README

Filecoin FFI stub

For testing and non-production purposes only.

This is an FFI stub that can be used with a go.mod replace directive in tests that do not require real proofs.

Usage

In your go.mod:

replace github.com/filecoin-project/filecoin-ffi => github.com/filecoin-project/ffi-stub ${version}

License

Dual-licensed: MIT, Apache Software License v2, by way of the Permissive License Stack.

Documentation

Index

Constants

View Source
const DigestBytes = 96

DigestBytes is the length of a BLS message hash/digest

View Source
const PrivateKeyBytes = 32

PrivateKeyBytes is the length of a BLS private key

View Source
const PublicKeyBytes = 48

PublicKeyBytes is the length of a BLS public key

View Source
const SignatureBytes = 96

SignatureBytes is the length of a BLS signature

Variables

View Source
var SectorUpdate = FunctionsSectorUpdate{}

Functions

func AggregateSealProofs added in v0.2.0

func AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) (out []byte, err error)

func ClearCache

func ClearCache(uint64, string) error

func FauxRep

func FauxRep(abi.RegisteredSealProof, string, string) (cid.Cid, error)

func GeneratePieceCIDFromFile

func GeneratePieceCIDFromFile(_ abi.RegisteredSealProof, _ io.Reader, _ abi.UnpaddedPieceSize) (cid.Cid, error)

func GenerateSingleVanillaProof

func GenerateSingleVanillaProof(replica PrivateSectorInfo, challange []uint64) ([]byte, error)

func GenerateUnsealedCID

func GenerateUnsealedCID(_ abi.RegisteredSealProof, _ []abi.PieceInfo) (cid.Cid, error)

func GenerateWindowPoStWithVanilla added in v0.4.0

func GenerateWindowPoStWithVanilla(
	proofType abi.RegisteredPoStProof,
	minerID abi.ActorID,
	randomness abi.PoStRandomness,
	proofs [][]byte,
) ([]proof.PoStProof, error)

func GenerateWinningPoStWithVanilla added in v0.4.0

func GenerateWinningPoStWithVanilla(
	proofType abi.RegisteredPoStProof,
	minerID abi.ActorID,
	randomness abi.PoStRandomness,
	proofs [][]byte,
) ([]proof.PoStProof, error)

func GetGPUDevices

func GetGPUDevices() ([]string, error)

func HashVerify

func HashVerify(signature *Signature, messages []Message, publicKeys []PublicKey) bool

func MergeWindowPoStPartitionProofs added in v0.4.0

func MergeWindowPoStPartitionProofs(
	proofType abi.RegisteredPoStProof,
	partitionProofs []PartitionProof,
) (*proof.PoStProof, error)

func SealCommitPhase2

func SealCommitPhase2([]byte, abi.SectorNumber, abi.ActorID) ([]byte, error)

func SealPreCommitPhase1

func SealPreCommitPhase1(_ abi.RegisteredSealProof, _, _, _ string, _ abi.SectorNumber, _ abi.ActorID, _ abi.SealRandomness, _ []abi.PieceInfo) ([]byte, error)

func SealPreCommitPhase2

func SealPreCommitPhase2(_ []byte, _, _ string) (cid.Cid, cid.Cid, error)

func UnsealRange

func UnsealRange(_ abi.RegisteredSealProof, _ string, _, _ *os.File, _ abi.SectorNumber, _ abi.ActorID, _ abi.SealRandomness, _ cid.Cid, _, _ uint64) error

func Verify

func Verify(signature *Signature, digests []Digest, publicKeys []PublicKey) bool

func VerifyAggregateSeals added in v0.2.0

func VerifyAggregateSeals(aggregate proof.AggregateSealVerifyProofAndInfos) (bool, error)

func VerifySeal

func VerifySeal(proof.SealVerifyInfo) (bool, error)

func VerifyWindowPoSt

func VerifyWindowPoSt(proof.WindowPoStVerifyInfo) (bool, error)

func VerifyWinningPoSt

func VerifyWinningPoSt(proof.WinningPoStVerifyInfo) (bool, error)

Types

type ApplyRet added in v0.4.0

type ApplyRet struct {
	Return             []byte
	ExitCode           uint64
	GasUsed            int64
	MinerPenalty       abi.TokenAmount
	MinerTip           abi.TokenAmount
	BaseFeeBurn        abi.TokenAmount
	OverEstimationBurn abi.TokenAmount
	Refund             abi.TokenAmount
	GasRefund          int64
	GasBurned          int64
	ExecTraceBytes     []byte
	FailureInfo        string
	EventsRoot         *cid.Cid
	EventsBytes        []byte
}

type Digest

type Digest [DigestBytes]byte

Digest is a compressed affine

func Hash

func Hash(message Message) Digest

type FVM added in v0.4.0

type FVM struct{}

func CreateFVM added in v0.4.0

func CreateFVM(*FVMOpts) (*FVM, error)

func (*FVM) ApplyImplicitMessage added in v0.4.0

func (*FVM) ApplyImplicitMessage(msgBytes []byte) (*ApplyRet, error)

func (*FVM) ApplyMessage added in v0.4.0

func (*FVM) ApplyMessage(msgBytes []byte, chainLen uint) (*ApplyRet, error)

func (*FVM) Flush added in v0.4.0

func (*FVM) Flush() (cid.Cid, error)

type FVMOpts added in v0.4.0

type FVMOpts struct {
	FVMVersion uint64
	Externs    cgo.Externs

	Epoch          abi.ChainEpoch
	Timestamp      uint64
	ChainID        uint64
	BaseFee        abi.TokenAmount
	BaseCircSupply abi.TokenAmount
	NetworkVersion network.Version
	StateBase      cid.Cid
	Manifest       cid.Cid
	Tracing        bool

	Debug         bool
	ActorRedirect cid.Cid
}

type FallbackChallenges

type FallbackChallenges struct {
	Sectors    []abi.SectorNumber
	Challenges map[abi.SectorNumber][]uint64
}

func GeneratePoStFallbackSectorChallenges

func GeneratePoStFallbackSectorChallenges(proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, sectorIds []abi.SectorNumber) (*FallbackChallenges, error)

type FunctionsSectorUpdate added in v0.3.0

type FunctionsSectorUpdate struct{}

func (FunctionsSectorUpdate) DecodeFrom added in v0.3.0

func (FunctionsSectorUpdate) DecodeFrom(
	proofType abi.RegisteredUpdateProof,
	outDataPath string,
	replicaPath string,
	sectorKeyPath string,
	sectorKeyCachePath string,
	unsealedCID cid.Cid,
) error

func (FunctionsSectorUpdate) EncodeInto added in v0.3.0

func (FunctionsSectorUpdate) EncodeInto(
	proofType abi.RegisteredUpdateProof,
	newReplicaPath string,
	newReplicaCachePath string,
	sectorKeyPath string,
	sectorKeyCachePath string,
	stagedDataPath string,
	pieces []abi.PieceInfo,
) (sealedCID cid.Cid, unsealedCID cid.Cid, err error)

func (FunctionsSectorUpdate) GenerateUpdateProof added in v0.3.0

func (FunctionsSectorUpdate) GenerateUpdateProof(
	proofType abi.RegisteredUpdateProof,
	oldSealedCID cid.Cid,
	newSealedCID cid.Cid,
	unsealedCID cid.Cid,
	newReplicaPath string,
	newReplicaCachePath string,
	sectorKeyPath string,
	sectorKeyCachePath string,
) ([]byte, error)

func (FunctionsSectorUpdate) GenerateUpdateProofWithVanilla added in v0.3.0

func (FunctionsSectorUpdate) GenerateUpdateProofWithVanilla(
	proofType abi.RegisteredUpdateProof,
	oldSealedCID cid.Cid,
	newSealedCID cid.Cid,
	unsealedCID cid.Cid,
	vanillaProofs [][]byte,
) ([]byte, error)

func (FunctionsSectorUpdate) GenerateUpdateVanillaProofs added in v0.3.0

func (FunctionsSectorUpdate) GenerateUpdateVanillaProofs(
	proofType abi.RegisteredUpdateProof,
	oldSealedCID cid.Cid,
	newSealedCID cid.Cid,
	unsealedCID cid.Cid,
	newReplicaPath string,
	newReplicaCachePath string,
	sectorKeyPath string,
	sectorKeyCachePath string,
) ([][]byte, error)

func (FunctionsSectorUpdate) RemoveData added in v0.3.0

func (FunctionsSectorUpdate) RemoveData(
	proofType abi.RegisteredUpdateProof,
	sectorKeyPath string,
	sectorKeyCachePath string,
	replicaPath string,
	replicaCachePath string,
	dataPath string,
	unsealedCID cid.Cid,
) error

func (FunctionsSectorUpdate) VerifyUpdateProof added in v0.3.0

func (FunctionsSectorUpdate) VerifyUpdateProof(info proof.ReplicaUpdateInfo) (bool, error)

func (FunctionsSectorUpdate) VerifyVanillaProofs added in v0.3.0

func (FunctionsSectorUpdate) VerifyVanillaProofs(
	proofType abi.RegisteredUpdateProof,
	oldSealedCID cid.Cid,
	newSealedCID cid.Cid,
	unsealedCID cid.Cid,
	vanillaProofs [][]byte,
) (bool, error)

type Message

type Message []byte

Message is a byte slice

type PartitionProof added in v0.4.0

type PartitionProof proof.PoStProof

func GenerateSinglePartitionWindowPoStWithVanilla added in v0.4.0

func GenerateSinglePartitionWindowPoStWithVanilla(
	proofType abi.RegisteredPoStProof,
	minerID abi.ActorID,
	randomness abi.PoStRandomness,
	proofs [][]byte,
	partitionIndex uint,
) (*PartitionProof, error)

type PrivateKey

type PrivateKey [PrivateKeyBytes]byte

PrivateKey is a compressed affine

func PrivateKeyGenerate

func PrivateKeyGenerate() PrivateKey

func PrivateKeyGenerateWithSeed

func PrivateKeyGenerateWithSeed(seed PrivateKeyGenSeed) PrivateKey

type PrivateKeyGenSeed

type PrivateKeyGenSeed [32]byte

Used when generating a private key deterministically

type PrivateSectorInfo

type PrivateSectorInfo struct {
	abi.SectorNumber
	CacheDirPath     string
	PoStProofType    abi.RegisteredPoStProof
	SealedSectorPath string
	SectorInfo       proof.SectorInfo
}

type PublicKey

type PublicKey [PublicKeyBytes]byte

PublicKey is a compressed affine

func PrivateKeyPublicKey

func PrivateKeyPublicKey(privateKey PrivateKey) PublicKey

type Signature

type Signature [SignatureBytes]byte

Signature is a compressed affine

func Aggregate

func Aggregate(signatures []Signature) *Signature

func CreateZeroSignature

func CreateZeroSignature() Signature

func PrivateKeySign

func PrivateKeySign(privateKey PrivateKey, message Message) *Signature

type SortedPrivateSectorInfo

type SortedPrivateSectorInfo struct{ abi.SectorNumber }

func NewSortedPrivateSectorInfo

func NewSortedPrivateSectorInfo(...PrivateSectorInfo) SortedPrivateSectorInfo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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