ln

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BigNOne is the Fmpz representation of -1
	BigNOne = fmp.NewFmpz(-1)
	// BigZero is the Fmpz representation of 0
	BigZero = fmp.NewFmpz(0)
	// BigOne is the Fmpz representation of 1
	BigOne = fmp.NewFmpz(1)
	// BigTwo is the Fmpz representation of 2
	BigTwo = fmp.NewFmpz(2)
	// BigThree is the Fmpz representation of 3
	BigThree = fmp.NewFmpz(3)
	// BigFour is the Fmpz representation of 4
	BigFour = fmp.NewFmpz(4)
	// BigFive is the Fmpz representation of 5
	BigFive = fmp.NewFmpz(5)
	// BigSix is the Fmpz representation of 6
	BigSix = fmp.NewFmpz(6)
	// BigSeven is the Fmpz representation of 7
	BigSeven = fmp.NewFmpz(7)
	// BigEight is the Fmpz representation of 8
	BigEight = fmp.NewFmpz(8)
	// BigNine is the Fmpz representation of 9
	BigNine = fmp.NewFmpz(9)
	// BigEleven is the Fmpz representation of 11
	BigEleven = fmp.NewFmpz(11)
	// BigSixteen is the Fmpz representation of 16
	BigSixteen = fmp.NewFmpz(0xf)
)

Functions

func BytesToNumber

func BytesToNumber(src []byte) *fmp.Fmpz

BytesToNumber takes a slice of bytes and returns a Fmpz integer representation.

func Combinations

func Combinations(set []*fmp.Fmpz, n int) (subsets [][]*fmp.Fmpz)

Combinations returns combinations of n elements for a given Fmpz array.

func ContfractToRational

func ContfractToRational(frac []int) (*fmp.Fmpz, *fmp.Fmpz)

ContfractToRational takes a slice of quotients and returns a rational x/y.

func ConvergantsFromContfract

func ConvergantsFromContfract(frac []int) [][2]*fmp.Fmpz

ConvergantsFromContfract takes a slice of quotients and returns the convergants.

func FindGcd

func FindGcd(a, b *fmp.Fmpz) *fmp.Fmpz

FindGcd returns a Fmpz GCD of a and b or 1 if a and b are co-prime.

func FindPGivenD

func FindPGivenD(d *fmp.Fmpz, e *fmp.Fmpz, n *fmp.Fmpz) *fmp.Fmpz

FindPGivenD finds p and q given d, e, and n - uses an algorithm from pycrypto _slowmath.py [0] [0]: https://github.com/dlitz/pycrypto/blob/master/lib/Crypto/PublicKey/_slowmath.py

func FmpFromIntSlice

func FmpFromIntSlice(is []int) []*fmp.Fmpz

FmpFromIntSlice returns a slice of Fmpz from a slice of int.

func FmpFromUInt64Slice

func FmpFromUInt64Slice(is []uint64) []*fmp.Fmpz

FmpFromUInt64Slice returns a slice of Fmpz from a slice of int.

func FmpString

func FmpString(s string) *fmp.Fmpz

FmpString returns a base 10 fmp.Fmpz integer from a string. It returns BigZero on error.

func FmpzMin

func FmpzMin(x, y *fmp.Fmpz) *fmp.Fmpz

FmpzMin returns the min(x,y)

func FracPow

func FracPow(x *fmp.Fmpz, m, n int) *fmp.Fmpz

FracPow raises x to the fractional power m/n and returns it.

func GetRand

func GetRand(state *fmp.FlintRandT, n *fmp.Fmpz) *fmp.Fmpz

GetRand takes a seed from the environment and iterates the state a random number of times to get a less deterministic random number from Flint.

func ILog

func ILog(x, b *fmp.Fmpz) *fmp.Fmpz

ILog returns the greatest integer l such that b**l <= x.

func IsPerfectSquare

func IsPerfectSquare(n *fmp.Fmpz) *fmp.Fmpz

IsPerfectSquare returns t if n is a perfect square -1 otherwise

func IsPower

func IsPower(n *fmp.Fmpz) *fmp.Fmpz

IsPower returns the largest integer that, when squared/cubed/etc, yields n, or 0 if no such integer exists.

func MLucas

func MLucas(v, a, n *fmp.Fmpz) *fmp.Fmpz

MLucas multiplies along a Lucas sequence modulo n.

func NumberToBytes

func NumberToBytes(src *fmp.Fmpz) []byte

NumberToBytes takes an Fmpz integer and returns the byte slice representation.

func RationalToContfract

func RationalToContfract(x, y *fmp.Fmpz) []int

RationalToContfract takes a rational represented by x and y and returns a slice of quotients.

func SegmentedSieveFmp

func SegmentedSieveFmp(n int) []*fmp.Fmpz

SegmentedSieveFmp is another prime sieve.

func SieveOfAtkin

func SieveOfAtkin(n int) []int

SieveOfAtkin finds primes from 0 to n using a SieveOfAtkin from primegen package.

func SieveOfAtkinFmp

func SieveOfAtkinFmp(n int) []*fmp.Fmpz

SieveOfAtkinFmp finds primes from 0 to n using a SieveOfAtkin from primegen package.

func SieveOfEratosthenes

func SieveOfEratosthenes(n int) []int

SieveOfEratosthenes returns primes from begin to n and this implementation comes from: https://stackoverflow.com/a/21923233.

func SieveOfEratosthenesFmp

func SieveOfEratosthenesFmp(n int) []*fmp.Fmpz

SieveOfEratosthenesFmp is a convenience function that simply returns []*fmp.Fmpz instead of []int. It does not support finding primes > max_int.

func SieveRangeOfAtkin

func SieveRangeOfAtkin(begin, n int) []int

SieveRangeOfAtkin finds primes from begin to the limit n using a SieveOfAtkin from primegen package.

func SolveCRT

func SolveCRT(mrs [][]*fmp.Fmpz) *fmp.Fmpz

SolveCRT solves the Chinese Remainder Theorem for sets of residues and moduli.

func SolveforD

func SolveforD(p *fmp.Fmpz, q *fmp.Fmpz, e *fmp.Fmpz) *fmp.Fmpz

SolveforD given e, p and q solve for the private exponent d.

func XGCD

func XGCD(a, b *fmp.Fmpz) (*fmp.Fmpz, *fmp.Fmpz, *fmp.Fmpz)

XGCD finds the coefficients of Bézout's identity using the Extended Euclidean algorithm.

Types

This section is empty.

Jump to

Keyboard shortcuts

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