From 3683a1ab81fc0662213e5de8a73fa6131c078b51 Mon Sep 17 00:00:00 2001 From: Emanuel Date: Wed, 24 Jul 2024 11:55:03 +0300 Subject: [PATCH] Add basic structure for crypto, state, time --- internal/crypto/constants.go | 9 +++++++++ internal/crypto/hash.go | 3 +++ internal/crypto/keys.go | 8 ++++++++ internal/state/state.go | 4 ++++ internal/time/constants.go | 9 +++++++++ internal/time/epoch.go | 3 +++ internal/time/timeslot.go | 3 +++ 7 files changed, 39 insertions(+) create mode 100644 internal/crypto/constants.go create mode 100644 internal/crypto/hash.go create mode 100644 internal/crypto/keys.go create mode 100644 internal/state/state.go create mode 100644 internal/time/constants.go create mode 100644 internal/time/epoch.go create mode 100644 internal/time/timeslot.go diff --git a/internal/crypto/constants.go b/internal/crypto/constants.go new file mode 100644 index 0000000..1aeb486 --- /dev/null +++ b/internal/crypto/constants.go @@ -0,0 +1,9 @@ +package crypto + +const ( + HashSize = 32 + BandersnatchSize = 32 + Ed25519PublicSize = 32 + Ed25519PrivateSize = 64 + BLSSize = 144 +) diff --git a/internal/crypto/hash.go b/internal/crypto/hash.go new file mode 100644 index 0000000..e519686 --- /dev/null +++ b/internal/crypto/hash.go @@ -0,0 +1,3 @@ +package crypto + +type Hash [HashSize]byte diff --git a/internal/crypto/keys.go b/internal/crypto/keys.go new file mode 100644 index 0000000..27cc119 --- /dev/null +++ b/internal/crypto/keys.go @@ -0,0 +1,8 @@ +package crypto + +import ( + "crypto/ed25519" +) + +type Ed25519PublicKey ed25519.PublicKey +type Ed25519PrivateKey ed25519.PrivateKey diff --git a/internal/state/state.go b/internal/state/state.go new file mode 100644 index 0000000..a268c97 --- /dev/null +++ b/internal/state/state.go @@ -0,0 +1,4 @@ +package state + +type State struct { +} diff --git a/internal/time/constants.go b/internal/time/constants.go new file mode 100644 index 0000000..186c1e8 --- /dev/null +++ b/internal/time/constants.go @@ -0,0 +1,9 @@ +package time + +import "time" + +const ( + TimeslotsPerEpoch = 600 + TimeslotDuration = 6 * time.Second + EpochDuration = TimeslotsPerEpoch * TimeslotDuration +) diff --git a/internal/time/epoch.go b/internal/time/epoch.go new file mode 100644 index 0000000..9dc60b0 --- /dev/null +++ b/internal/time/epoch.go @@ -0,0 +1,3 @@ +package time + +type Epoch uint32 diff --git a/internal/time/timeslot.go b/internal/time/timeslot.go new file mode 100644 index 0000000..2b3b77e --- /dev/null +++ b/internal/time/timeslot.go @@ -0,0 +1,3 @@ +package time + +type Timeslot uint32