pub fn verify_label<H: Hasher>(
        &self,
        uname: &AkdLabel,
        stale: bool,
        version: u64,
        proof: &[u8],
        label: NodeLabel,
    ) -> Result<(), VrfError> {
        // Initialization of VRF context by providing a curve

        let name_hash_bytes = H::hash(&uname.0);
        let stale_bytes = if stale { &[0u8] } else { &[1u8] };

        let hashed_label = H::merge(&[
            name_hash_bytes,
            H::merge_with_int(H::hash(stale_bytes), version),
        ]);
        let message_vec = crate::serialization::from_digest::<H>(hashed_label);
        let message: &[u8] = message_vec.as_slice();

        // VRF proof verification (returns VRF hash output)
        let proof = Proof::try_from(proof)?;
        self.verify(&proof, message)?;

        let output: Output = (&proof).into();
        if NodeLabel::new(output.to_truncated_bytes(), 256u32) == label {
            Ok(())
        } else {
            Err(VrfError::Verification(
                "Expected first 32 bytes of the proof output did NOT match the supplied label"
                    .to_string(),
            ))
        }
    }
/// This function is called to verify that a given NodeLabel is indeed
/// the VRF for a given version (fresh or stale) for a username.
/// Hence, it also takes as input the server's public key.
This function is called to verify that a given NodeLabel is indeed
the VRF for a given version (fresh or stale) for a username.
Hence, it also takes as input the server's public key.
This function is called to verify that a given NodeLabel is indeed the VRF for a given version ( fresh or stale ) for a username . Hence it also takes as input the server ' s public key .
pub fn verify_label<H: Hasher>(
        &self,
        uname: &AkdLabel,
        stale: bool,
        version: u64,
        proof: &[u8],
        label: NodeLabel,
    ) -> Result<(), VrfError> {
        // Initialization of VRF context by providing a curve
        let name_hash_bytes = H::hash(&uname.0);
        let stale_bytes = if stale { &[0u8] } else { &[1u8] };
        let hashed_label = H::merge(&[
            name_hash_bytes,
            H::merge_with_int(H::hash(stale_bytes), version),
        ]);
        let message_vec = crate::serialization::from_digest::<H>(hashed_label);
        let message: &[u8] = message_vec.as_slice();
        // VRF proof verification (returns VRF hash output)
        let proof = Proof::try_from(proof)?;
        self.verify(&proof, message)?;
        let output: Output = (&proof).into();
        if NodeLabel::new(output.to_truncated_bytes(), 256u32) == label {
            Ok(())
        } else {
            Err(VrfError::Verification(
                "Expected first 32 bytes of the proof output did NOT match the supplied label"
                    .to_string(),
            ))
        }
    }
pub fn verify_label < H : Hasher > ( & self , uname : & AkdLabel , stale : bool , version : u64 , proof : & [ u8 ] , label : NodeLabel , ) -> Result < ( ) , VrfError > { // Initialization of VRF context by providing a curve let name_hash_bytes = H :: hash ( & uname . 0 ) ; let stale_bytes = if stale { & [ 0u8 ] } else { & [ 1u8 ] } ; let hashed_label = H :: merge ( & [ name_hash_bytes , H :: merge_with_int ( H :: hash ( stale_bytes ) , version ) , ] ) ; let message_vec = crate :: serialization :: from_digest :: < H > ( hashed_label ) ; let message : & [ u8 ] = message_vec . as_slice ( ) ; // VRF proof verification (returns VRF hash output) let proof = Proof :: try_from ( proof ) ? ; self . verify ( & proof , message ) ? ; let output : Output = ( & proof ) . into ( ) ; if NodeLabel :: new ( output . to_truncated_bytes ( ) , 256u32 ) == label { Ok ( ( ) ) } else { Err ( VrfError :: Verification ( " " . to_string ( ) , ) ) } }
This function is called to verify that a given NodeLabel is indeed
the VRF for a given version (fresh or stale) for a username.
This function is called to verify that a given NodeLabel is indeed the VRF for a given version ( fresh or stale ) for a username .
&self
uname
&AkdLabel
stale
bool
version
u64
proof
&[u8]
label
NodeLabel
&self
uname
&AkdLabel
stale
bool
version
u64
proof
&[u8]
label
NodeLabel