Skip to main content

forest/blocks/
vrf_proof.rs

1// Copyright 2019-2026 ChainSafe Systems
2// SPDX-License-Identifier: Apache-2.0, MIT
3
4use crate::utils::encoding::serde_byte_array;
5use get_size2::GetSize;
6use serde::{Deserialize, Serialize};
7
8/// The output from running a VRF proof.
9#[cfg_attr(
10    test,
11    derive(derive_quickcheck_arbitrary::Arbitrary, derive_more::Constructor)
12)]
13#[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Default, Serialize, Deserialize, Hash)]
14pub struct VRFProof(#[serde(with = "serde_byte_array")] pub Vec<u8>);
15
16impl VRFProof {
17    /// Returns reference to underlying proof bytes.
18    pub fn as_bytes(&self) -> &[u8] {
19        &self.0
20    }
21
22    /// Compute the `BLAKE2b256` digest of the proof.
23    #[allow(dead_code)]
24    pub fn digest(&self) -> [u8; 32] {
25        crate::utils::encoding::blake2b_256(&self.0)
26    }
27}
28
29impl GetSize for VRFProof {
30    fn get_heap_size(&self) -> usize {
31        self.0.get_heap_size()
32    }
33}