prysm-pulse/shared/forkutils/signature.go
Raul Jordan 19abe81472
Implement Randao Reveal Signing in Proposer Client (#1650)
* finish the BLS API wrapper

* all tests passing

* unexported comment

* gofmt tests for bls

* block processing test into own package to avoid cycle

* randao tests pass

* blocks test passing

* use common deposit generator

* helper

* resolved import cycle

* setup initial

* builds

* almost done with blockchain tests

* fix blockchain tests

* getting through with chaintests

* revert client change

* lint

* sync master conflict gazelle

* randao test fixes

* randao proposer impl

* tests pass
2019-02-20 12:58:34 -06:00

43 lines
1.2 KiB
Go

package forkutils
import (
"math"
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
)
// ForkVersion returns the fork version of the given epoch number.
//
// Spec pseudocode definition:
// def get_fork_version(fork: Fork,
// epoch: EpochNumber) -> int:
// """
// Return the fork version of the given ``epoch``.
// """
// if epoch < fork.epoch:
// return fork.previous_version
// else:
// return fork.current_version
func ForkVersion(fork *pb.Fork, epoch uint64) uint64 {
if epoch < fork.Epoch {
return fork.PreviousVersion
}
return fork.CurrentVersion
}
// DomainVersion returns the domain version for BLS private key to sign and verify.
//
// Spec pseudocode definition:
// def get_domain(fork: Fork,
// epoch: EpochNumber,
// domain_type: int) -> int:
// """
// Get the domain number that represents the fork meta and signature domain.
// """
// fork_version = get_fork_version(fork, epoch)
// return fork_version * 2**32 + domain_type
func DomainVersion(fork *pb.Fork, epoch uint64, domainType uint64) uint64 {
offset := uint64(math.Pow(2, 32))
return ForkVersion(fork, epoch)*offset + domainType
}