Call VerifyBeacon, hack around genesis

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-04-14 16:52:18 +02:00
parent 624dd7d2ce
commit 5ab9636365
2 changed files with 15 additions and 6 deletions

View File

@ -13,6 +13,7 @@ import (
logging "github.com/ipfs/go-log" logging "github.com/ipfs/go-log"
dbeacon "github.com/drand/drand/beacon"
"github.com/drand/drand/core" "github.com/drand/drand/core"
dkey "github.com/drand/drand/key" dkey "github.com/drand/drand/key"
dnet "github.com/drand/drand/net" dnet "github.com/drand/drand/net"
@ -149,10 +150,19 @@ func (db *DrandBeacon) getCachedValue(round uint64) *types.BeaconEntry {
return &v return &v
} }
func (db *DrandBeacon) VerifyEntry(from types.BeaconEntry, to types.BeaconEntry) error { func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error {
return nil if prev.Round == 0 {
// TODO: this doesnt work for some reason // TODO handle genesis better
//return dbeacon.Verify(db.pubkey.Key(), from.Data, to.Round, from.Round) return nil
}
b := &dbeacon.Beacon{
PreviousRound: prev.Round,
PreviousSig: prev.Data,
Round: curr.Round,
Signature: curr.Data,
}
//log.Warnw("VerifyEntry", "beacon", b)
return dbeacon.VerifyBeacon(db.pubkey.Key(), b)
} }
func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 { func (db *DrandBeacon) MaxBeaconRoundForEpoch(filEpoch abi.ChainEpoch, prevEntry types.BeaconEntry) uint64 {

View File

@ -23,7 +23,6 @@ import (
"go.opencensus.io/stats" "go.opencensus.io/stats"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"go.uber.org/multierr" "go.uber.org/multierr"
"go.uber.org/zap"
amt "github.com/filecoin-project/go-amt-ipld/v2" amt "github.com/filecoin-project/go-amt-ipld/v2"
@ -894,7 +893,7 @@ func (cs *ChainStore) TryFillTipSet(ts *types.TipSet) (*FullTipSet, error) {
} }
func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { func DrawRandomness(rbase []byte, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) {
log.Desugar().WithOptions(zap.AddCallerSkip(2)).Sugar().Warnw("DrawRandomness", "base", rbase, "dsep", pers, "round", round, "entropy", entropy) //log.Desugar().WithOptions(zap.AddCallerSkip(2)).Sugar().Warnw("DrawRandomness", "base", rbase, "dsep", pers, "round", round, "entropy", entropy)
h := blake2b.New256() h := blake2b.New256()
if err := binary.Write(h, binary.BigEndian, int64(pers)); err != nil { if err := binary.Write(h, binary.BigEndian, int64(pers)); err != nil {
return nil, xerrors.Errorf("deriving randomness: %w", err) return nil, xerrors.Errorf("deriving randomness: %w", err)