#![allow(clippy::missing_safety_doc)]
use zisk_zkvm_interface::{
zkvm_status, zkvm_status_ZKVM_EFAIL as ZKVM_EFAIL, zkvm_status_ZKVM_EOK as ZKVM_EOK,
};
#[cfg_attr(not(feature = "hints"), no_mangle)]
#[cfg_attr(feature = "hints", export_name = "hints_zkvm_mulmod256")]
pub unsafe extern "C" fn zkvm_mulmod256(
a: *const u8,
b: *const u8,
m: *const u8,
output: *mut u8,
#[cfg(feature = "hints")] hints: &mut Vec<u64>,
) -> zkvm_status {
#[cfg(feature = "hints")]
{
super::mul_mod_bytes256_c(a, b, m, output, hints);
ZKVM_EOK
}
#[cfg(not(feature = "hints"))]
{
#[cfg(zisk_hints)]
unsafe {
crate::hints::hint_mulmod256(a, b, m);
}
#[cfg(zisk_hints_debug)]
crate::hint_log("hint_mulmod256".to_string());
super::mul_mod_bytes256_c(a, b, m, output);
ZKVM_EOK
}
}
#[cfg_attr(not(feature = "hints"), no_mangle)]
#[cfg_attr(feature = "hints", export_name = "hints_zkvm_reduce_mod256")]
pub unsafe extern "C" fn zkvm_reduce_mod256(
a: *const u8,
m: *const u8,
output: *mut u8,
#[cfg(feature = "hints")] hints: &mut Vec<u64>,
) -> zkvm_status {
#[cfg(feature = "hints")]
{
super::reduce_mod_bytes256_c(a, m, output, hints);
ZKVM_EOK
}
#[cfg(not(feature = "hints"))]
{
#[cfg(zisk_hints)]
unsafe {
crate::hints::hint_reduce_mod256(a, m);
}
#[cfg(zisk_hints_debug)]
crate::hint_log("hint_reduce_mod256".to_string());
super::reduce_mod_bytes256_c(a, m, output);
ZKVM_EOK
}
}
#[cfg_attr(not(feature = "hints"), no_mangle)]
#[cfg_attr(feature = "hints", export_name = "hints_zkvm_add_mod256")]
pub unsafe extern "C" fn zkvm_add_mod256(
a: *const u8,
b: *const u8,
m: *const u8,
output: *mut u8,
#[cfg(feature = "hints")] hints: &mut Vec<u64>,
) -> zkvm_status {
#[cfg(feature = "hints")]
{
super::add_mod_bytes256_c(a, b, m, output, hints);
ZKVM_EOK
}
#[cfg(not(feature = "hints"))]
{
#[cfg(zisk_hints)]
unsafe {
crate::hints::hint_add_mod256(a, b, m);
}
#[cfg(zisk_hints_debug)]
crate::hint_log("hint_add_mod256".to_string());
super::add_mod_bytes256_c(a, b, m, output);
ZKVM_EOK
}
}
#[cfg_attr(not(feature = "hints"), no_mangle)]
#[cfg_attr(feature = "hints", export_name = "hints_zkvm_square_mod256")]
pub unsafe extern "C" fn zkvm_square_mod256(
a: *const u8,
m: *const u8,
output: *mut u8,
#[cfg(feature = "hints")] hints: &mut Vec<u64>,
) -> zkvm_status {
#[cfg(feature = "hints")]
{
super::square_mod_bytes256_c(a, m, output, hints);
ZKVM_EOK
}
#[cfg(not(feature = "hints"))]
{
#[cfg(zisk_hints)]
unsafe {
crate::hints::hint_square_mod256(a, m);
}
#[cfg(zisk_hints_debug)]
crate::hint_log("hint_square_mod256".to_string());
super::square_mod_bytes256_c(a, m, output);
ZKVM_EOK
}
}
#[cfg_attr(not(feature = "hints"), no_mangle)]
#[cfg_attr(feature = "hints", export_name = "hints_zkvm_pow_mod256")]
pub unsafe extern "C" fn zkvm_pow_mod256(
base: *const u8,
exp: *const u8,
m: *const u8,
output: *mut u8,
#[cfg(feature = "hints")] hints: &mut Vec<u64>,
) -> zkvm_status {
#[cfg(feature = "hints")]
{
super::pow_mod_bytes256_c(base, exp, m, output, hints);
ZKVM_EOK
}
#[cfg(not(feature = "hints"))]
{
#[cfg(zisk_hints)]
unsafe {
crate::hints::hint_pow_mod256(base, exp, m);
}
#[cfg(zisk_hints_debug)]
crate::hint_log("hint_pow_mod256".to_string());
super::pow_mod_bytes256_c(base, exp, m, output);
ZKVM_EOK
}
}
#[cfg_attr(not(feature = "hints"), no_mangle)]
#[cfg_attr(feature = "hints", export_name = "hints_zkvm_inv_mod256")]
pub unsafe extern "C" fn zkvm_inv_mod256(
a: *const u8,
m: *const u8,
output: *mut u8,
#[cfg(feature = "hints")] hints: &mut Vec<u64>,
) -> zkvm_status {
#[cfg(feature = "hints")]
{
if super::inv_mod_bytes256_c(a, m, output, hints) == 1 {
ZKVM_EOK
} else {
ZKVM_EFAIL
}
}
#[cfg(not(feature = "hints"))]
{
#[cfg(zisk_hints)]
unsafe {
crate::hints::hint_inv_mod256(a, m);
}
#[cfg(zisk_hints_debug)]
crate::hint_log("hint_inv_mod256".to_string());
if super::inv_mod_bytes256_c(a, m, output) == 1 {
ZKVM_EOK
} else {
ZKVM_EFAIL
}
}
}