Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ledger/babbage/babbage.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ func (b *BabbageBlock) Utxorpc() *utxorpc.Block {
return block
}

type BabbageBlockHeaderVrfResult struct {
cbor.StructAsArray
Output []byte
Proof []byte
}

type BabbageBlockHeader struct {
cbor.StructAsArray
cbor.DecodeStoreCbor
Expand All @@ -151,7 +157,7 @@ type BabbageBlockHeader struct {
PrevHash common.Blake2b256
IssuerVkey common.IssuerVkey
VrfKey []byte
VrfResult interface{}
VrfResult BabbageBlockHeaderVrfResult
BlockBodySize uint64
BlockBodyHash common.Blake2b256
OpCert struct {
Expand Down
8 changes: 3 additions & 5 deletions ledger/verify_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,16 @@ func VerifyBlock(block BlockHexCbor) (error, bool, string, uint64, uint64) {
), false, "", 0, 0
}
vrfBytes := header.Body.VrfKey[:]
vrfResult := header.Body.VrfResult.([]interface{})
vrfProofBytes := vrfResult[1].([]byte)
vrfOutputBytes := vrfResult[0].([]byte)
vrfResult := header.Body.VrfResult
seed := MkInputVrf(int64(header.Body.Slot), epochNonceByte)
output, errVrf := VrfVerifyAndHash(vrfBytes, vrfProofBytes, seed)
output, errVrf := VrfVerifyAndHash(vrfBytes, vrfResult.Proof, seed)
if errVrf != nil {
return fmt.Errorf(
"VerifyBlock: vrf invalid, %v",
errVrf.Error(),
), false, "", 0, 0
}
isVrfValid := bytes.Equal(output, vrfOutputBytes)
isVrfValid := bytes.Equal(output, vrfResult.Output)

// check if block data valid
blockBodyHash := header.Body.BlockBodyHash
Expand Down
Loading