implement sector commitments and proof verification
This commit is contained in:
@@ -2,6 +2,7 @@ package sectorbuilder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"unsafe"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/chain/address"
|
||||
@@ -29,10 +30,9 @@ type SectorBuilderConfig struct {
|
||||
}
|
||||
|
||||
func New(cfg *SectorBuilderConfig) (*SectorBuilder, error) {
|
||||
var proverId [31]byte
|
||||
copy(proverId[:], cfg.Miner.Payload())
|
||||
proverId := addressToProverID(cfg.Miner)
|
||||
|
||||
sbp, err := sectorbuilder.InitSectorBuilder(cfg.SectorSize, 2, 2, 1, cfg.MetadataDir, [31]byte{}, cfg.SealedDir, cfg.StagedDir, 16)
|
||||
sbp, err := sectorbuilder.InitSectorBuilder(cfg.SectorSize, 2, 2, 1, cfg.MetadataDir, proverId, cfg.SealedDir, cfg.StagedDir, 16)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -42,6 +42,18 @@ func New(cfg *SectorBuilderConfig) (*SectorBuilder, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func addressToProverID(a address.Address) [31]byte {
|
||||
var proverId [31]byte
|
||||
copy(proverId[:], a.Payload())
|
||||
return proverId
|
||||
}
|
||||
|
||||
func sectorIDtoBytes(sid uint64) [31]byte {
|
||||
var out [31]byte
|
||||
binary.LittleEndian.PutUint64(out[:], sid)
|
||||
return out
|
||||
}
|
||||
|
||||
func (sb *SectorBuilder) Run(ctx context.Context) {
|
||||
go sb.pollForSealedSectors(ctx)
|
||||
}
|
||||
@@ -84,9 +96,15 @@ func (sb *SectorBuilder) SealedSectorChan() <-chan SectorSealingStatus {
|
||||
|
||||
var UserBytesForSectorSize = sectorbuilder.GetMaxUserBytesPerStagedSector
|
||||
|
||||
func VerifySeal(sectorSize uint64, commR, commD, commRStar [CommLen]byte, proverID address.Address, sectorID uint64, proof []byte) (bool, error) {
|
||||
panic("TODO")
|
||||
// return sectorbuilder.VerifySeal(sectorSize, commR, commD, commRStar, providerID, sectorID, proof)
|
||||
func VerifySeal(sectorSize uint64, commR, commD, commRStar []byte, proverID address.Address, sectorID uint64, proof []byte) (bool, error) {
|
||||
var commRa, commDa, commRStara [32]byte
|
||||
copy(commRa[:], commR)
|
||||
copy(commDa[:], commD)
|
||||
copy(commRStara[:], commRStar)
|
||||
proverIDa := addressToProverID(proverID)
|
||||
sectorIDa := sectorIDtoBytes(sectorID)
|
||||
|
||||
return sectorbuilder.VerifySeal(sectorSize, commRa, commDa, commRStara, proverIDa, sectorIDa, proof)
|
||||
}
|
||||
|
||||
func VerifyPost(sectorSize uint64, sortedCommRs [][CommLen]byte, challengeSeed [CommLen]byte, proofs [][]byte, faults []uint64) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user