Skip to main content

verify_ironshield_solution

Function verify_ironshield_solution 

Source
pub fn verify_ironshield_solution(
    response: &IronShieldChallengeResponse,
) -> bool
Expand description

Verify that an IronShieldChallengeResponse contains a valid solution.

This function uses the same optimized hashing approach as find_solution_single_threaded. It extracts the challenge and solution from the response and verifies that the solution is valid for the challenge.

§Arguments

  • response: The IronShieldChallengeResponse containing both the challenge and solution

§Returns

  • bool: true if the solution produces a hash less than the challenge_param, false if the solution is invalid or doesn’t meet the requirements.

§Example

use ironshield_core::{find_solution, verify_ironshield_solution, IronShieldChallenge, SigningKey};

let dummy_key = SigningKey::from_bytes(&[0u8; 32]);
let challenge = IronShieldChallenge::new(
    "test_website".to_string(),
    1, // Easy difficulty
    dummy_key,
    [0x00; 32],
);

let response = find_solution(&challenge, None, None, None, None).unwrap();
assert!(verify_ironshield_solution(&response));