From bd8966b530623b278b59bc5f9fb900cb00585a5f Mon Sep 17 00:00:00 2001 From: "daniel.vladco" Date: Fri, 26 Jul 2024 15:30:21 +0300 Subject: [PATCH] fix: Hk Hv and Hs --- internal/block/header.go | 17 +++++++++++++---- internal/crypto/bandersnatch.go | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 internal/crypto/bandersnatch.go diff --git a/internal/block/header.go b/internal/block/header.go index ca7cea0..aa14fe8 100644 --- a/internal/block/header.go +++ b/internal/block/header.go @@ -5,16 +5,25 @@ import ( "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 []crypto.Hash // He + EpochMarker *EpochMarker // He WinningTicketsMarker [time.TimeslotsPerEpoch]*Ticket // Hw JudgementsMarkers []crypto.Hash // Hj - BlockAuthorKey []byte // Hk - VRFSignature []byte // Hv - BlockSealSignature []byte // Hs + 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