Struct BlockHeader
The block header which contains a link to the previous block header, unless it's the genesis header.
struct BlockHeader
;
Fields
Name | Type | Description |
---|---|---|
enrollments
|
Enrollment[] | Enrolled validators |
height
|
Height | Block height (genesis is #0) |
merkle_root
|
geod24 | The hash of the merkle root of the transactions |
preimages
|
geod24 | The pre-images propagated in this block |
prev_block
|
geod24 | Hash of the previous block in the chain of blocks |
signature
|
agora | Schnorr multisig of all validators which signed this block |
validators
|
agora | BitMask containing the validators' key indices which signed the block |
Methods
Name | Description |
---|---|
clone
()
|
Create a mutable clone |
computeHash
(dg)
|
Implements hashing support |
randomSeed
()
|
Convenience function |
sign
(secret_key, preimage)
|
Create the block signature for the given keypair |
updateSignature
(signature, validators)
|
|
verify
(pubkey, preimage, sig)
|
Verify that the provided signature is a valid signature for pubkey
|
Example
hashing test
import std .conv : to;
auto address = `boa1xrra39xpg5q9zwhsq6u7pw508z2let6dj8r5lr4q0d0nff240fvd27yme3h`;
PublicKey pubkey = PublicKey .fromString(address);
Output[1] outputs = [ Output(Amount(100), pubkey) ];
Transaction tx = Transaction(outputs[]);
BlockHeader header = { merkle_root : tx .hashFull() };
assert(hashFull(header) != Hash .init);