arith

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsInIntervalLEps

func IsInIntervalLEps(n *safenum.Int) bool

IsInIntervalLEps returns true if n ∈ [-2ˡ⁺ᵉ,…,2ˡ⁺ᵉ].

func IsInIntervalLPrimeEps

func IsInIntervalLPrimeEps(n *safenum.Int) bool

IsInIntervalLPrimeEps returns true if n ∈ [-2ˡ'⁺ᵉ,…,2ˡ'⁺ᵉ].

func IsValidBigModN

func IsValidBigModN(N *big.Int, ints ...*big.Int) bool

IsValidBigModN checks that ints are all in the range [1,…,N-1] and co-prime to N.

func IsValidNatModN

func IsValidNatModN(N *safenum.Modulus, ints ...*safenum.Nat) bool

IsValidNatModN checks that ints are all in the range [1,…,N-1] and co-prime to N.

Types

type Modulus

type Modulus struct {
	// represents modulus n
	*safenum.Modulus
	// contains filtered or unexported fields
}

Modulus wraps a safenum.Modulus and enables faster modular exponentiation when the factorization is known. When n = p⋅q, xᵉ (mod n) can be computed with only two exponentiations with p and q respectively.

func ModulusFromFactors

func ModulusFromFactors(p, q *safenum.Nat) *Modulus

ModulusFromFactors creates the necessary cached values to accelerate exponentiation mod n.

func ModulusFromN

func ModulusFromN(n *safenum.Modulus) *Modulus

ModulusFromN creates a simple wrapper around a given modulus n. The modulus is not copied.

func (*Modulus) Exp

func (n *Modulus) Exp(x, e *safenum.Nat) *safenum.Nat

Exp is equivalent to (safenum.Nat).Exp(x, e, n.Modulus). It returns xᵉ (mod n).

func (*Modulus) ExpI

func (n *Modulus) ExpI(x *safenum.Nat, e *safenum.Int) *safenum.Nat

ExpI is equivalent to (safenum.Nat).ExpI(x, e, n.Modulus). It returns xᵉ (mod n).

Jump to

Keyboard shortcuts

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