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

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

        let message = merge(&[name_hash_bytes, merge_with_int(hash(stale_bytes), version)]);

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

        let output: Output = (&proof).into();
        let expected_label = NodeLabel {
            val: output.to_truncated_bytes(),
            len: 256u32,
        };
        if expected_label == label {
            Ok(())
        } else {
            Err(VerificationError::build(
                Some(VerificationErrorType::Vrf),
                Some(format!(
                    "Expected first {} bytes of the proof output did NOT match the supplied label",
                    NODE_LABEL_LEN
                )),
            ))
        }
    }
/// 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(crate) fn verify_label(
        &self,
        uname: &AkdLabel,
        stale: bool,
        version: u64,
        proof: &[u8],
        label: NodeLabel,
    ) -> Result<(), VerificationError> {
        // Initialization of VRF context by providing a curve
        let name_hash_bytes = hash(uname);
        let stale_bytes = if stale { &[0u8] } else { &[1u8] };
        let message = merge(&[name_hash_bytes, merge_with_int(hash(stale_bytes), version)]);
        // VRF proof verification (returns VRF hash output)
        let proof = Proof::try_from(proof)?;
        self.verify(&proof, &message)?;
        let output: Output = (&proof).into();
        let expected_label = NodeLabel {
            val: output.to_truncated_bytes(),
            len: 256u32,
        };
        if expected_label == label {
            Ok(())
        } else {
            Err(VerificationError::build(
                Some(VerificationErrorType::Vrf),
                Some(format!(
                    "Expected first {} bytes of the proof output did NOT match the supplied label",
                    NODE_LABEL_LEN
                )),
            ))
        }
    }
pub ( crate ) fn verify_label ( & self , uname : & AkdLabel , stale : bool , version : u64 , proof : & [ u8 ] , label : NodeLabel , ) -> Result < ( ) , VerificationError > { // Initialization of VRF context by providing a curve let name_hash_bytes = hash ( uname ) ; let stale_bytes = if stale { & [ 0u8 ] } else { & [ 1u8 ] } ; let message = merge ( & [ name_hash_bytes , merge_with_int ( hash ( stale_bytes ) , version ) ] ) ; // VRF proof verification (returns VRF hash output) let proof = Proof :: try_from ( proof ) ? ; self . verify ( & proof , & message ) ? ; let output : Output = ( & proof ) . into ( ) ; let expected_label = NodeLabel { val : output . to_truncated_bytes ( ) , len : 256u32 , } ; if expected_label == label { Ok ( ( ) ) } else { Err ( VerificationError :: build ( Some ( VerificationErrorType :: Vrf ) , Some ( format ! ( " " NODE_LABEL_LEN ) ) , ) ) } }
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