diff --git a/internal/block/header.go b/internal/block/header.go index 50bb32b..aa14fe8 100644 --- a/internal/block/header.go +++ b/internal/block/header.go @@ -1,4 +1,29 @@ package block +import ( + "github.com/eigerco/strawberry/internal/crypto" + "github.com/eigerco/strawberry/internal/time" +) + +const NumberOfValidators uint16 = 1023 + +// Header as defined in the section 5 in the paper type Header struct { + ParentHash crypto.Hash // Hp + PriorStateRoot crypto.Hash // Hr + ExtrinsicHash crypto.Hash // Hx + TimeSlotIndex time.Timeslot // Ht + EpochMarker *EpochMarker // He + WinningTicketsMarker [time.TimeslotsPerEpoch]*Ticket // Hw + JudgementsMarkers []crypto.Hash // Hj + PublicKeyIndex uint16 // Hk + VRFSignature crypto.BandersnatchSignature // Hv + BlockSealSignature crypto.BandersnatchSignature // Hs +} + +// EpochMarker consists of epoch randomness and a sequence of +// Bandersnatch keys defining the Bandersnatch validator keys (kb) beginning in the next epoch. +type EpochMarker struct { + Keys [NumberOfValidators]crypto.BandersnatchPublicKey + Entropy crypto.Hash } diff --git a/internal/crypto/bandersnatch.go b/internal/crypto/bandersnatch.go new file mode 100644 index 0000000..b70e5db --- /dev/null +++ b/internal/crypto/bandersnatch.go @@ -0,0 +1,4 @@ +package crypto + +type BandersnatchPublicKey [BandersnatchSize]byte +type BandersnatchSignature [96]byte