Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(BEEFY): Add beefy primitives #4180

Open
dimartiro opened this issue Sep 12, 2024 · 0 comments
Open

(BEEFY): Add beefy primitives #4180

dimartiro opened this issue Sep 12, 2024 · 0 comments

Comments

@dimartiro
Copy link
Contributor

dimartiro commented Sep 12, 2024

Description

Add all primitives required by BEEFY

This is a suggestion of the primitives we could need (but could be more)

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant