cmpa 0.1.6

Multiprecision arithmetic primitives commonly needed for asymmetric cryptography
Documentation
// SPDX-License-Identifier: Apache-2.0
// Copyright 2023, 2026 SUSE LLC
// Author: Nicolai Stange <nstange@suse.de>

//! Multiprecision integer arithmetic primitives.

#![no_std]

#[cfg(test)]
mod test_helpers;

pub mod add;
pub mod cmp;
pub mod div;
pub mod euclid;
pub mod hexstr;
pub mod invmod;
pub mod lcm;
pub mod limb;
pub mod limbs;
pub mod montgomery;
pub mod mul;
pub mod prime;
pub mod shift;
pub mod usize_ct_cmp;

pub use limb::{
    CtLDivisor, CtLDivisorError, LimbChoice, LimbType, ct_eq_l_l, ct_geq_l_l, ct_gt_l_l,
    ct_is_nonzero_l, ct_is_zero_l, ct_leq_l_l, ct_lt_l_l, ct_neq_l_l,
};

pub use limbs::{
    MpBigEndianUIntByteSlice, MpLittleEndianUIntByteSlice, MpMutBigEndianUIntByteSlice,
    MpMutLittleEndianUIntByteSlice, MpMutNativeEndianUIntLimbsSlice, MpMutUInt, MpMutUIntSlice,
    MpNativeEndianUIntLimbsSlice, MpUInt, MpUIntCommon, MpUIntCommonTryIntoNativeError,
    MpUIntSlice, MpUIntSliceCommon, clear_bits_above_mp, clear_bits_below_mp,
    ct_clear_bits_above_mp, ct_clear_bits_below_mp, ct_find_first_set_bit_mp,
    ct_find_last_set_bit_mp, ct_find_last_set_byte_mp, ct_swap_cond_mp, find_last_set_byte_mp,
    limb_slice_as_bytes, limb_slice_as_bytes_mut,
};

pub use add::{
    CtAddModMpMpError, CtNegateModMpError, CtSubModMpMpError, ct_add_cond_mp_mp, ct_add_mod_mp_mp,
    ct_add_mp_l, ct_add_mp_mp, ct_negate_cond_mp, ct_negate_mod_mp, ct_negate_mp,
    ct_sub_cond_mp_mp, ct_sub_mod_mp_mp, ct_sub_mp_l, ct_sub_mp_mp,
};

pub use cmp::{
    ct_eq_mp_mp, ct_geq_mp_mp, ct_gt_mp_mp, ct_is_one_mp, ct_is_zero_mp, ct_leq_mp_l, ct_leq_mp_mp,
    ct_lt_mp_mp, ct_neq_mp_mp,
};

pub use div::{
    CtDivLshiftedMpMpError, CtDivMpLError, CtDivMpMpError, CtDivPow2MpError,
    CtModLshiftedMpMpError, CtModPow2MpError, CtMpDivisor, CtMpDivisorError, ct_div_lshifted_mp_mp,
    ct_div_mp_l, ct_div_mp_mp, ct_div_pow2_mp, ct_mod_lshifted_mp_mp, ct_mod_mp_l, ct_mod_mp_mp,
    ct_mod_pow2_mp,
};

pub use euclid::{
    CtGcdMpMpError, CtGcdOddMpMpError, CtInvModOddMpMpError, ct_gcd_mp_mp, ct_gcd_odd_mp_mp,
    ct_inv_mod_odd_mp_mp,
};

pub use invmod::{CtInvModMpMpError, ct_inv_mod_mp_mp};

pub use lcm::{CtLcmMpMpError, ct_lcm_mp_mp};

pub use montgomery::{
    CtExpModOddMpMpError, CtMontgomeryExpModOddMpMpError, CtMontgomeryMulModMpMpError,
    CtMontgomeryNegN0InvModLMpError, CtMontgomeryRedcMpError, CtMontgomeryTransformationError,
    CtToMontgomeryFormMpError, ct_exp_mod_odd_mp_mp, ct_montgomery_mul_mod_mp_mp,
    ct_montgomery_neg_n0_inv_mod_l_mp, ct_montgomery_radix_shift_len,
    ct_montgomery_radix2_mod_n_mp, ct_montgomery_redc_mp, ct_montogmery_exp_mod_odd_mp_mp,
    ct_to_montgomery_form_direct_mp, ct_to_montgomery_form_mp,
};

pub use mul::{ct_mul_trunc_cond_mp_mp, ct_mul_trunc_mp_l, ct_mul_trunc_mp_mp, ct_square_trunc_mp};

pub use prime::{
    CtCompositeTestSmallPrimeGcdMpError, CtPrimeTestMillerRabinMpError, PrimeWheelSieve,
    ct_composite_test_small_prime_gcd_mp, ct_prime_test_miller_rabin_mp,
};

pub use shift::{ct_lshift_mp, ct_rshift_mp};

pub use usize_ct_cmp::{
    ct_eq_usize_usize, ct_geq_usize_usize, ct_gt_usize_usize, ct_leq_usize_usize, ct_lt_usize_usize,
};