mathutils

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

README

Mathutils

Mathematical utility functions for cryptographic and numerical operations.

Features

  • Random Number Generation - Generate random uint64 values and ranges from a PRNG
  • Integer Operations - Ceiling division and floor logarithm functions

Designed for cryptographic use with proper rejection sampling for uniform distribution.

Documentation

Overview

Package mathutils provides mathematical utility functions for cryptographic and numerical operations.

See README.md for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CeilDiv

func CeilDiv(numerator, denominator int) int

CeilDiv returns `ceil(numerator/denominator) for integer inputs. Equivalently, it returns `x`, the smallest integer that satisfies `(x*b) >= a`.

func CeilLog2

func CeilLog2(x int) int

CeilLog2 return ceil(log2(x)).

func FloorLog2

func FloorLog2(x int) int

FloorLog2 return floor(log2(x)).

func RandomUint64

func RandomUint64(prng io.Reader) (uint64, error)

RandomUint64 samples a random uint64 from the provided PRNG.

func RandomUint64Range

func RandomUint64Range(prng io.Reader, bound uint64) (uint64, error)

RandomUint64Range samples a random uint64 in the range [0, bound) from the provided PRNG.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL