# Generation signature
Generation signature is the variable in the average block generation time formula. It is used to check whether the current generating node is eligible to generate the next block.
The computation of the block's generation signature generationSignature
i+1 is done by the following steps:
- Choosing the block. Let
h
will be the current blockchain height. Ifh
≥ 100, then the block at heighth-100
will be chosen. Otherwise, the block at heighth-1
will be chosen. - Hashing the chosen block's generation signature
generationSignature
i and miner's account public keypk
using Blake2b256 (opens new window):generationSignature
i+1 =Blake2b256
(generationSignature
i,pk
)
The resulting hash is the generation signature.
The first 8 bytes of the resulting 32 bytes hash is converted to a number, referred to as the account hit. The hit from i
-th block affects how soon a i+100
-th block’s generator (current miner) will be able to generate a block after i+99
-th block.
From version 1.2.0, after activation of feature #15 “Ride V4, VRF, Protobuf, Failed transactions” the generation signature is improved by implementing VRF (opens new window) (A Verifiable Random Function with Short Proofs and Keys) — a pseudo-random function that uses a message and the private key of an account to provide a non-interactively verifiable proof for the correctness of its output.
This improvement will allow resisting stake grinding (opens new window) attacks aimed at influencing block generation randomness to skip miner's opportunity to create a block. In the prior implementation of the generation signature formula (see above), the randomness of a blockN+1
is dependent on the generator of the blockN
and is determined for each miner.
The use of VRF makes signature generation unpredictable because of the need to know the private key for calculation. Only the holder of the private key can compute the hash, but verifying the correctness of the hash using the public key from block header is available to anyone.
The VRF containscalculateVRF
function, which calculates proof for some message, andverifyVRF
function, which verifies proof fromcalculateVRF
function with a message and the public key of the signer.
Considering that a block’s generation signature is equal tocalculateVRF
output for a previous generation signature with account private keysk
(of generator ofi+1
-th block):
generationSignature
i+1 =VRFproof
=calculateVRF
sk(VRFi)
The output ofcalculateVRF
function is a VRF proof, which means that the validity of the signature can be checked. Before VRF implementation, thegenerationSignature
i was used in consensus to define the time delay betweeni+99
andi+100
blocks for concrete block generator. With VRF, the output of functionverifyVRF
(pk
i,generationSignature
i) is used to define the time delay betweeni+99
andi+100
blocks for concrete block generator.