pub fn hook_fp_sqrt(_: HookEnv, buf: &[u8]) -> Vec<Vec<u8>> {
        let len: usize = u32::from_be_bytes(buf[0..4].try_into().unwrap()) as usize;

        assert!(buf.len() == 4 + 3 * len, "FpOp: Invalid buffer length");

        let buf = &buf[4..];
        let element = BigUint::from_bytes_be(&buf[..len]);
        let modulus = BigUint::from_bytes_be(&buf[len..2 * len]);
        let nqr = BigUint::from_bytes_be(&buf[2 * len..3 * len]);

        assert!(
            element < modulus,
            "Element is not less than modulus, the hook only accepts canonical representations"
        );
        assert!(
            nqr < modulus,
            "NQR is zero or non-canonical, the hook only accepts canonical representations"
        );

        // The sqrt of zero is zero.
        if element.is_zero() {
            return vec![vec![1], vec![0; len]];
        }

        // Compute the square root of the element using the general Tonelli-Shanks algorithm.
        // The implementation can be used for any field as it is field-agnostic.
        if let Some(root) = sqrt_fp(&element, &modulus, &nqr) {
            vec![vec![1], pad_to_be(&root, len)]
        } else {
            let qr = (&nqr * &element) % &modulus;
            let root = sqrt_fp(&qr, &modulus, &nqr).unwrap();

            vec![vec![0], pad_to_be(&root, len)]
        }
    }
Compute the square root of a field element.

# Arguments:
* `buf` - The buffer containing the data needed to compute the square root.
- [ len || Element || Modulus || NQR ]
- len is the length of the element, modulus, and nqr in big endian.
- Element is the field element to compute the square root of, interpreted as a big
endian integer of `len` bytes.
- Modulus is the modulus of the field, interpreted as a big endian integer of `len`
bytes.
- NQR is the non-quadratic residue of the field, interpreted as a big endian integer of
`len` bytes.

# Assumptions
- NQR is a non-quadratic residue of the field.

# Returns:
[ `status_u8` || `root_bytes` ]

If the status is 0, this is the root of NQR * element.
If the status is 1, this is the root of element.

# Panics:
- If the buffer length is not valid.
- If the element is not less than the modulus.
- If the nqr is not less than the modulus.
- If the element is zero.
crates/core/executor/src/hook.rs