oa::crypto::bigint
Module published by the oa::crypto module.
MdRust public API
Public Types
Public Functions
pub fn barrett_multiply( left: &Matrix, right: &Matrix, modulus: &Matrix, ) -> Result<(Matrix, Matrix)>pub fn div_rem_mixed( left: &Matrix, right: &Matrix, quotient_words: u32, ) -> Result<(Matrix, Matrix, Matrix)>Function Documentation
Compute batched unsigned limb add. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns same-width rows; arithmetic overflow/underflow wraps modulo 2^width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb add mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data add_scalar on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Unsigned scalar arithmetic wraps within the complete declared limb width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb barrett multiply. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb bit and. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns same-width rows; arithmetic overflow/underflow wraps modulo 2^width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb bit not. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns the complement within the complete fixed operand width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb bit or. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns same-width rows; arithmetic overflow/underflow wraps modulo 2^width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb bit xor. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns same-width rows; arithmetic overflow/underflow wraps modulo 2^width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb compare. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns U32 [batch] order codes: 0 less, 1 equal, 2 greater. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data compare_scalar on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns U32 order codes: 0 less, 1 equal, 2 greater. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb div rem. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (quotient, remainder, status); status is U32 [batch]. A zero divisor produces status 0, quotient 0 and remainder equal to the dividend. Otherwise status is 1 and division is exact. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data div_rem_mixed on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Division returns (quotient, remainder, status): 1 success, 0 zero divisor, 2 quotient overflow. Invalid rows have completely zero outputs. The divisor may be one shared row. Mixed division accepts independent dividend (1..=256), divisor (1..=128) and quotient (1..=256) word counts; wide/narrow division takes a double-width dividend. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data div_rem_narrow on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Division returns (quotient, remainder, status): 1 success, 0 zero divisor, 2 quotient overflow. Invalid rows have completely zero outputs. The divisor may be one shared row. Mixed division accepts independent dividend (1..=256), divisor (1..=128) and quotient (1..=256) word counts; wide/narrow division takes a double-width dividend. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data div_rem_scalar on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (quotient, remainder, status). Scalar zero yields status 0 and zero outputs; valid status is 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data div_rem_wide on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Division returns (quotient, remainder, status): 1 success, 0 zero divisor, 2 quotient overflow. Invalid rows have completely zero outputs. The divisor may be one shared row. Mixed division accepts independent dividend (1..=256), divisor (1..=128) and quotient (1..=256) word counts; wide/narrow division takes a double-width dividend. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb from montgomery. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Montgomery operations require an odd modulus; even moduli return status 0 and zero output. R = 2^(32words). Conversion multiplies by R or R^-1; multiplication computes ab*R^-1 modulo m. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data from_u32 on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Zero-extends one-word U32 or two-word U64 rows into the requested word width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data from_u64 on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Zero-extends one-word U32 or two-word U64 rows into the requested word width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb inverse mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Non-invertible values also return status 0 and zero output. Odd/even and composite moduli are accepted. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb leading zeros. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns U32 [batch] leading-zero counts in the complete operand width; zero returns width_bits. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb montgomery multiply. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Montgomery operations require an odd modulus; even moduli return status 0 and zero output. R = 2^(32words). Conversion multiplies by R or R^-1; multiplication computes ab*R^-1 modulo m. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb multiply high. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns the upper half of the exact double-width product, with all low-half carries retained. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb multiply low. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns same-width rows; arithmetic overflow/underflow wraps modulo 2^width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb multiply mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data multiply_scalar on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Unsigned scalar arithmetic wraps within the complete declared limb width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb multiply wide. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns exact double-width rows (up to 8192 output bits). Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb pow mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. right is the unsigned exponent; zero exponents yield 1 modulo m, including 0^0. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Reduce double-width public rows using a prepared immutable Barrett snapshot. Returns (output, status): one for success, zero for a zero modulus, two when T is outside the significant-width Barrett bound T < 2^(64*k). Invalid rows produce zero. The prepared modulus may have one shared row. Errors Rejects dtype, shape, ownership, byte extents, allocation or recording failures.
Compute batched unsigned limb reduce mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data reduce_montgomery on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status). Computes T * R^-1 mod m for a double-width T. R = 2^(32*words); odd nonzero m is required. Invalid rows are zero. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Prepare a device-owned public Barrett modulus snapshot and reciprocal. Errors Rejects dtype, rank, width, byte extents, allocation or recording failures.
Compute batched unsigned limb shift left. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Shifts at or beyond the operand width produce zero; discarded bits are lost. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb shift right. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Shifts at or beyond the operand width produce zero; discarded bits are lost. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb square mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb square wide. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns exact double-width rows (up to 8192 output bits). Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb subtract. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns same-width rows; arithmetic overflow/underflow wraps modulo 2^width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb subtract mod. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data subtract_scalar on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Unsigned scalar arithmetic wraps within the complete declared limb width. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute batched unsigned limb to montgomery. Operands are public U32 [batch, words] rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status) with U32 [batch] status flags. modulus is U32 [1, words] or [batch, words], with matching Engine ownership. A zero modulus returns status 0 and zero output; valid rows return status 1. Montgomery operations require an odd modulus; even moduli return status 0 and zero output. R = 2^(32words). Conversion multiplies by R or R^-1; multiplication computes ab*R^-1 modulo m. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data to_u32 on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status); 1 means exact conversion, 0 means overflow with zero output. U64 values use two little-endian U32 words per row, without shaderInt64. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.
Compute public-data to_u64 on unsigned device limb rows. Operands are public rank-two U32 rows of little-endian limbs, with 1..=128 words (32..=4096 bits). Records device work without host reads or a host wait. This public-data route does not accept cryptographic secrets and makes no constant-time or performance claim. Returns (output, status); 1 means exact conversion, 0 means overflow with zero output. U64 values use two little-endian U32 words per row, without shaderInt64. Errors Rejects rank, dtype, shape, ownership, address limits, allocation or recording failures.