arith

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 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 *saferith.Int) bool

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

func IsInIntervalLEpsPlus1RootN

func IsInIntervalLEpsPlus1RootN(n *saferith.Int) bool

IsInIntervalLEpsPlus1RootN returns true if n ∈ [-2¹⁺ˡ⁺ᵉ√N,…,2¹⁺ˡ⁺ᵉ√N], for a Paillier modulus N.

func IsInIntervalLPrimeEps

func IsInIntervalLPrimeEps(n *saferith.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 *saferith.Modulus, ints ...*saferith.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
	*saferith.Modulus
	// contains filtered or unexported fields
}

Modulus wraps a saferith.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 *saferith.Nat) *Modulus

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

func ModulusFromN

func ModulusFromN(n *saferith.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 *saferith.Nat) *saferith.Nat

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

func (*Modulus) ExpI

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

ExpI is equivalent to (saferith.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