purify
C++ Purify implementation with native circuit and BPP support
Loading...
Searching...
No Matches
numeric.hpp File Reference

Fixed-width integer and field arithmetic helpers used throughout Purify. More...

#include "purify/common.hpp"
#include "purify/uint.h"

Go to the source code of this file.

Data Structures

class  purify::detail::UInt128
 
struct  purify::detail::BigUIntCBridge< Words >
 
struct  purify::BigUInt< Words >
 Little-endian fixed-width unsigned integer with simple arithmetic utilities. More...
 
class  purify::FieldElement
 Field element modulo the backend scalar field used by this implementation. More...
 

Namespaces

namespace  purify
 
namespace  purify::detail
 

Macros

#define PURIFY_DEFINE_BIGUINT_C_BRIDGE(words, bits)
 

Typedefs

using purify::UInt256 = BigUInt< 4 >
 256-bit unsigned integer used for field elements and curve orders.
 
using purify::UInt320 = BigUInt< 5 >
 320-bit unsigned integer used during hash-to-curve sampling.
 
using purify::UInt512 = BigUInt< 8 >
 512-bit unsigned integer used for private and packed public keys.
 

Functions

std::size_t purify::detail::bit_length_u64 (std::uint64_t value)
 
 purify::detail::PURIFY_DEFINE_BIGUINT_C_BRIDGE (4, 256)
 
 purify::detail::PURIFY_DEFINE_BIGUINT_C_BRIDGE (5, 320)
 
 purify::detail::PURIFY_DEFINE_BIGUINT_C_BRIDGE (8, 512)
 
template<std::size_t OutWords, std::size_t InWords>
BigUInt< OutWords > purify::widen (const BigUInt< InWords > &value)
 Widens an integer to a larger limb count by zero-extending high limbs.
 
template<std::size_t OutWords, std::size_t InWords>
Result< BigUInt< OutWords > > purify::try_narrow (const BigUInt< InWords > &value)
 Narrows an integer to a smaller limb count, rejecting truncated high bits.
 
template<std::size_t OutWords, std::size_t InWords>
BigUInt< OutWords > purify::narrow (const BigUInt< InWords > &value)
 Narrows an integer to a smaller limb count, requiring that no high bits are lost.
 
template<std::size_t Words>
Result< std::pair< BigUInt< Words >, BigUInt< Words > > > purify::try_divmod_same (const BigUInt< Words > &numerator, const BigUInt< Words > &denominator)
 Performs long division where numerator and denominator have the same width.
 
template<std::size_t Words>
std::pair< BigUInt< Words >, BigUInt< Words > > purify::divmod_same (const BigUInt< Words > &numerator, const BigUInt< Words > &denominator)
 Performs long division where numerator and denominator have the same width.
 
template<std::size_t LeftWords, std::size_t RightWords>
BigUInt< LeftWords+RightWords > purify::multiply (const BigUInt< LeftWords > &lhs, const BigUInt< RightWords > &rhs)
 Multiplies two fixed-width integers and returns the full-width product.
 
const UInt256purify::prime_p ()
 Returns the Purify base-field modulus.
 
FieldElement purify::square (const FieldElement &value)
 Squares a field element.
 
int purify::legendre_symbol (const FieldElement &value)
 Returns 0 for zero, 1 for quadratic residues, and -1 for non-residues.
 

Macro Definition Documentation

◆ PURIFY_DEFINE_BIGUINT_C_BRIDGE

#define PURIFY_DEFINE_BIGUINT_C_BRIDGE (   words,
  bits 
)

Definition at line 142 of file numeric.hpp.