ChainSafe / ChainSafe/gossamer
(BEEFY): Add beefy primitives
- Dominant language
- Go
- Stars
- 454
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Add all primitives required by BEEFY
This is a suggestion of the primitives we could need (but could be more)
```go
type BeefyPayloadId [2]byte
type PayloadElement struct {
payloadId BeefyPayloadId
data []byte
}
type ValidatorSetId uint64
// AuthorityId is the ECDSA public key (or any other crypto scheme we want to use)
type ValidatorSet[AuthorityId any] struct {
/// Public keys of the validator set elements
validators []AuthorityId
/// Identifier of the validator set
id ValidatorSetId
}
type Commitment[Number runtime.Number] struct{
/// A collection of payloads to be signed
payload []PayloadElement
/// Finalized block number this commitment is for.
block_number Number
/// BEEFY validator set supposed to sign this commitment.
validator_set_id ValidatorSetId
}
type SignedCommitment[Number runtime.Number, Signature] struct {
/// The commitment signatures are collected for.
Commitment Commitment[Number]
/// GRANDPA validators' signatures for the commitment.
Signatures []*Signature
}
type CompactSignedCommitment[Number runtime.Number, Signature] struct {
/// The commitment, unchanged compared to regular [`SignedCommitment`].
commitment Commitment[Number]
/// A bitfield representing presence of a signature coming from a validator at some index.
///
/// The bit at index `0` is set to `1` in case we have a signature coming from a validator at
/// index `0`
signaturesFrom []bool
// Number of validators in the Validator Set
ValidatorSetLen uint32
/// A `Vec` containing all `Signature`s present in the original [`SignedCommitment`].
signaturesCompact []Signature
}
// SignatureAccumulator could be a merkle root or a single aggregated BLS signature
type SignedCommitmentWitness[BNumber runtime.Number, SAccumulator] struct {
/// The full content of the commitment.
Commitment Commitment[BNumber]
/// The bit vector of validators who signed the commitment.
SignedBy []bool
/// Either a merkle root of signatures in the original signed commitment or a single aggregated
/// BLS signature aggregating all original signatures.
SignatureAccumulator SAccumulator
}
// Signature is a ECDSA signature (or any other crypto scheme)
type VoteMessage[Number runtime.Number, Id, Signature] struct {
/// Commit to information extracted from a finalized block
Commitment Commitment[Number]
/// Node authority id
Id Id
/// Node signature
Signature Signature
}type BeefyPayloadId [2]byte
type PayloadElement struct {
payloadId BeefyPayloadId
data []byte
}
type ValidatorSetId uint64
// AuthorityId is the ECDSA public key (or any other crypto scheme we want to use)
type ValidatorSet[AuthorityId any] struct {
/// Public keys of the validator set elements
validators []AuthorityId
/// Identifier of the validator set
id ValidatorSetId
}
type Commitment[Number runtime.Number] struct{
/// A collection of payloads to be signed
payload []PayloadElement
/// Finalized block number this commitment is for.
block_number Number
/// BEEFY validator set supposed to sign this commitment.
validator_set_id ValidatorSetId
}
type SignedCommitment[Number runtime.Number, Signature] struct {
/// The commitment signatures are collected for.
Commitment Commitment[Number]
/// GRANDPA validators' signatures for the commitment.
Signatures []*Signature
}
type CompactSignedCommitment[Number runtime.Number, Signature] struct {
/// The commitment, unchanged compared to regular [`SignedCommitment`].
commitment Commitment[Number]
/// A bitfield representing presence of a signature coming from a validator at some index.
///
/// The bit at index `0` is set to `1` in case we have a signature coming from a validator at
/// index `0`
signaturesFrom []bool
// Number of validators in the Validator Set
ValidatorSetLen uint32
/// A `Vec` containing all `Signature`s present in the original [`SignedCommitment`].
signaturesCompact []Signature
}
// SignatureAccumulator could be a merkle root or a single aggregated BLS signature
type SignedCommitmentWitness[BNumber runtime.Number, SAccumulator] struct {
/// The full content of the commitment.
Commitment Commitment[BNumber]
/// The bit vector of validators who signed the commitment.
SignedBy []bool
/// Either a merkle root of signatures in the original signed commitment or a single aggregated
/// BLS signature aggregating all original signatures.
SignatureAccumulator SAccumulator
}
// Signature is a ECDSA signature (or any other crypto scheme)
type VoteMessage[Number runtime.Number, Id, Signature] struct {
/// Commit to information extracted from a finalized block
Commitment Commitment[Number]
/// Node authority id
Id Id
/// Node signature
Signature Signature
}
```
Contributor guide
Assessment
This issue has not been assessed yet.