Skip to content

Commit

Permalink
parent c775ed3
Browse files Browse the repository at this point in the history
author daniel.vladco <vladcodaniel@gmail.com> 1721829553 +0300
committer daniel.vladco <vladcodaniel@gmail.com> 1721989837 +0300
gpgsig -----BEGIN PGP SIGNATURE-----

 iQIzBAABCAAdFiEEp/B5JgRVFrv4jeo0NRcmXQtfSkgFAmajes0ACgkQNRcmXQtf
 Skidrg//TebF4dKkt8fiVdgGCHLlVD4mI4JsE0ySEsIE1BQGz0myrRdKqd3psthK
 DtgPsJiMahcnivW8mkAVhG3E6pdZwFXqjArO3v47k/A0hmfSrr+CzF8AG9rU9ACf
 uY8/b1tjNgtMRbQQJLH3Ythjx2+yJaoywcJF9QgYRE+zk4D/WW/Rcr3AVkZhJ7Lk
 fgP4IltydVNYiT0k4xvLEqjjSQDKDT3bT4KFHDLIIkMS7ZF5fbAIQEC+cjCrz0az
 iC7v5HepV158FgmeEijJVvUh8PTWLF+Pifv0sybOgVx/VSMm048aRlbVZN3PVFPP
 zM4TAYJgb9YXHS2UtmSVAvkBLa6xVh7i97HNXzF9+Izxpk/HNoRd3scbgp/8Jk78
 Q7EFdc1VDaGo002U0DIBGaTLBleTQu1ukzPHtclrHlGMI5f4vTnWGUDStw97i5+L
 h0Fs+c+n4Ig7/Wy5+skTOGvaKNfMWGF+fZpg1Jnv9urLdzva6guelnpsf9/dwzI+
 ezh1tzn8L2+jNVTs4/Inv+K9nfqN7L0HPe6c9rheWmystNYKL3Z3h05W/3ulgW1M
 8kk3Y2AxcFugPGPaQ/49MezVn2SehlNJh8Z1RzRQio3I8+GKYj24O+TNrPyN3muc
 B0/5Psw7xbuQzNYmqjbZU9mdibU74kpomThW9D5sg7urNeteAF0=
 =5+iJ
 -----END PGP SIGNATURE-----

feat: add header fields

fix: use hash types where needed

feat: change epoch types to hash slice

Add ticket structs (#18)

fix: use existing ticket struct
  • Loading branch information
danielvladco committed Jul 26, 2024
1 parent c775ed3 commit 7721724
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/block/block.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
package block

// Block represents the main block structure
type Block struct {
Header *Header
Extrinsic *Extrinsic
}

// Extrinsic represents the block extrinsic data
type Extrinsic struct {
ET []*TicketProof
}
16 changes: 16 additions & 0 deletions internal/block/header.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
package block

import (
"github.com/eigerco/strawberry/internal/crypto"
"github.com/eigerco/strawberry/internal/time"
)

// 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
WinningTicketsMarker [time.TimeslotsPerEpoch]*Ticket // Hw
JudgementsMarkers []crypto.Hash // Hj
BlockAuthorKey []byte // Hk
VRFSignature []byte // Hv
BlockSealSignature []byte // Hs
}
20 changes: 20 additions & 0 deletions internal/block/ticket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package block

import "github.com/eigerco/strawberry/internal/crypto"

const (
maxTicketsPerBlock = 16 // `K` in the paper. The maximum number of tickets which may be submitted in a single extrinsic.
ticketProofSize = 784 // Size of F̄[]γz⟨XT ⌢ η′2 r⟩
)

// Ticket represents a single ticket (C in equation 50)
type Ticket struct {
Identifier crypto.Hash // y ∈ H 32bytes hash
EntryIndex uint8 // r ∈ Nn (0, 1)
}

// TicketProof represents a proof of a valid ticket
type TicketProof struct {
EntryIndex uint8 // r ∈ Nn (0, 1)
Proof [ticketProofSize]byte // RingVRF proof
}

0 comments on commit 7721724

Please sign in to comment.