diff --git a/chain/beacon/drand/drand.go b/chain/beacon/drand/drand.go index 74818d312..f2e0fcb54 100644 --- a/chain/beacon/drand/drand.go +++ b/chain/beacon/drand/drand.go @@ -13,6 +13,7 @@ import ( logging "github.com/ipfs/go-log" + dbeacon "github.com/drand/drand/beacon" "github.com/drand/drand/core" dkey "github.com/drand/drand/key" dnet "github.com/drand/drand/net" @@ -149,10 +150,19 @@ func (db *DrandBeacon) getCachedValue(round uint64) *types.BeaconEntry { return &v } -func (db *DrandBeacon) VerifyEntry(from types.BeaconEntry, to types.BeaconEntry) error { - return nil - // TODO: this doesnt work for some reason - //return dbeacon.Verify(db.pubkey.Key(), from.Data, to.Round, from.Round) +func (db *DrandBeacon) VerifyEntry(curr types.BeaconEntry, prev types.BeaconEntry) error { + if prev.Round == 0 { + // TODO handle genesis better + 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 { diff --git a/chain/store/store.go b/chain/store/store.go index fc032f5f9..6d8bf4ce9 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -23,7 +23,6 @@ import ( "go.opencensus.io/stats" "go.opencensus.io/trace" "go.uber.org/multierr" - "go.uber.org/zap" 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) { - 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() if err := binary.Write(h, binary.BigEndian, int64(pers)); err != nil { return nil, xerrors.Errorf("deriving randomness: %w", err)