C# 클래스 MpcLib.Common.FiniteField.NumTheoryUtils

Implements some number-theoretic utility functions.
파일 보기 프로젝트 열기: mahdiz/mpclib 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
DHPrime1536 System.Numerics.BigInteger
DHPrime2048 System.Numerics.BigInteger
DHPrime768 System.Numerics.BigInteger

공개 메소드들

메소드 설명
CalcInverse ( System.Numerics.BigInteger n, System.Numerics.BigInteger prime ) : System.Numerics.BigInteger

Returns the inverse of n modulo p.

DLEncrypt ( BigZp x, System.Numerics.BigInteger p ) : System.Numerics.BigInteger

Discrete logarithm encryption.

ExtendedEuclidean ( System.Numerics.BigInteger a, System.Numerics.BigInteger b, System.Numerics.BigInteger &x, System.Numerics.BigInteger &y ) : System.Numerics.BigInteger

Performs the Extended Euclidean algorithm and returns gcd(a,b). The function also returns integers x and y such that ax + by = gcd(a,b). If gcd(a,b) = 1, then x is a multiplicative inverse of "a mod b" and y is a multiplicative inverse of "b mod a".

ExtendedEuclidean ( int a, int b, int &x, int &y ) : int

Performs the Extended Euclidean algorithm and returns gcd(a,b). The function also returns integers x and y such that ax + by = gcd(a,b). If gcd(a,b) = 1, then x is a multiplicative inverse of "a mod b" and y is a multiplicative inverse of "b mod a".

ExtendedEuclidean ( long a, long b, long &x, long &y ) : long

Performs the Extended Euclidean algorithm and returns gcd(a,b). The function also returns integers x and y such that ax + by = gcd(a,b). If gcd(a,b) = 1, then x is a multiplicative inverse of "a mod b" and y is a multiplicative inverse of "b mod a".

GetBitDecomposition ( System.Numerics.BigInteger a, System.Numerics.BigInteger prime ) : List
GetBitDecomposition ( System.Numerics.BigInteger a, System.Numerics.BigInteger prime, int length ) : List
GetBitLength ( System.Numerics.BigInteger a ) : int

Returns the actual number of bits of a byte array by ignoring trailing zeros in the binary representation.

GetBitLength ( byte a ) : int

Returns the actual number of bits of a byte array by ignoring trailing zeros in the binary representation.

GetBitLength2 ( System.Numerics.BigInteger a ) : int
GetFieldInverse ( int prime ) : int[]

Returns an array containing inverses of all field elements.

GetFieldMinimumPrimitive ( int prime ) : int
IsPrime ( int n ) : bool

Performs a O(sqrt(|n|)) primality test, where |n| is the bit-length of the input.

MillerRabin ( System.Numerics.BigInteger n, int k ) : bool

Implements the Miller-Rabin algorithm for fast compositeness test. Returns true if n is a composite number. If n is prime, returns false with high probability (this probability increases with k).

ModPow ( int powerBase, int exp, int prime ) : int

Performs modular exponentiation.

ModSqrRoot ( System.Numerics.BigInteger val, System.Numerics.BigInteger prime ) : System.Numerics.BigInteger
MultiplicativeInverse ( System.Numerics.BigInteger a, System.Numerics.BigInteger m ) : System.Numerics.BigInteger

Returns the multiplicative inverse of a modulo m.

MultiplicativeInverse ( int a, int m ) : int

Returns the multiplicative inverse of a modulo m.

MultiplicativeInverse ( long a, long m ) : long

Returns the multiplicative inverse of a modulo m.

NextRandomBigInt ( RNGCryptoServiceProvider rng, System.Numerics.BigInteger minValue, System.Numerics.BigInteger maxValue ) : System.Numerics.BigInteger

Returns a random big integer in the specified range. This is based on a simple probabilistic algorithm.

메소드 상세

CalcInverse() 공개 정적인 메소드

Returns the inverse of n modulo p.
public static CalcInverse ( System.Numerics.BigInteger n, System.Numerics.BigInteger prime ) : System.Numerics.BigInteger
n System.Numerics.BigInteger
prime System.Numerics.BigInteger
리턴 System.Numerics.BigInteger

DLEncrypt() 공개 정적인 메소드

Discrete logarithm encryption.
public static DLEncrypt ( BigZp x, System.Numerics.BigInteger p ) : System.Numerics.BigInteger
x BigZp Value to be encrypted.
p System.Numerics.BigInteger Prime modulus. Should be large enough (> 1024 bits) to ensure security.
리턴 System.Numerics.BigInteger

ExtendedEuclidean() 공개 정적인 메소드

Performs the Extended Euclidean algorithm and returns gcd(a,b). The function also returns integers x and y such that ax + by = gcd(a,b). If gcd(a,b) = 1, then x is a multiplicative inverse of "a mod b" and y is a multiplicative inverse of "b mod a".
public static ExtendedEuclidean ( System.Numerics.BigInteger a, System.Numerics.BigInteger b, System.Numerics.BigInteger &x, System.Numerics.BigInteger &y ) : System.Numerics.BigInteger
a System.Numerics.BigInteger
b System.Numerics.BigInteger
x System.Numerics.BigInteger
y System.Numerics.BigInteger
리턴 System.Numerics.BigInteger

ExtendedEuclidean() 공개 정적인 메소드

Performs the Extended Euclidean algorithm and returns gcd(a,b). The function also returns integers x and y such that ax + by = gcd(a,b). If gcd(a,b) = 1, then x is a multiplicative inverse of "a mod b" and y is a multiplicative inverse of "b mod a".
public static ExtendedEuclidean ( int a, int b, int &x, int &y ) : int
a int
b int
x int
y int
리턴 int

ExtendedEuclidean() 공개 정적인 메소드

Performs the Extended Euclidean algorithm and returns gcd(a,b). The function also returns integers x and y such that ax + by = gcd(a,b). If gcd(a,b) = 1, then x is a multiplicative inverse of "a mod b" and y is a multiplicative inverse of "b mod a".
public static ExtendedEuclidean ( long a, long b, long &x, long &y ) : long
a long
b long
x long
y long
리턴 long

GetBitDecomposition() 공개 정적인 메소드

public static GetBitDecomposition ( System.Numerics.BigInteger a, System.Numerics.BigInteger prime ) : List
a System.Numerics.BigInteger
prime System.Numerics.BigInteger
리턴 List

GetBitDecomposition() 공개 정적인 메소드

public static GetBitDecomposition ( System.Numerics.BigInteger a, System.Numerics.BigInteger prime, int length ) : List
a System.Numerics.BigInteger
prime System.Numerics.BigInteger
length int
리턴 List

GetBitLength() 공개 정적인 메소드

Returns the actual number of bits of a byte array by ignoring trailing zeros in the binary representation.
public static GetBitLength ( System.Numerics.BigInteger a ) : int
a System.Numerics.BigInteger
리턴 int

GetBitLength() 공개 정적인 메소드

Returns the actual number of bits of a byte array by ignoring trailing zeros in the binary representation.
public static GetBitLength ( byte a ) : int
a byte
리턴 int

GetBitLength2() 공개 정적인 메소드

public static GetBitLength2 ( System.Numerics.BigInteger a ) : int
a System.Numerics.BigInteger
리턴 int

GetFieldInverse() 공개 정적인 메소드

Returns an array containing inverses of all field elements.
public static GetFieldInverse ( int prime ) : int[]
prime int
리턴 int[]

GetFieldMinimumPrimitive() 공개 정적인 메소드

public static GetFieldMinimumPrimitive ( int prime ) : int
prime int
리턴 int

IsPrime() 공개 정적인 메소드

Performs a O(sqrt(|n|)) primality test, where |n| is the bit-length of the input.
public static IsPrime ( int n ) : bool
n int
리턴 bool

MillerRabin() 공개 정적인 메소드

Implements the Miller-Rabin algorithm for fast compositeness test. Returns true if n is a composite number. If n is prime, returns false with high probability (this probability increases with k).
public static MillerRabin ( System.Numerics.BigInteger n, int k ) : bool
n System.Numerics.BigInteger
k int
리턴 bool

ModPow() 공개 정적인 메소드

Performs modular exponentiation.
public static ModPow ( int powerBase, int exp, int prime ) : int
powerBase int
exp int
prime int
리턴 int

ModSqrRoot() 공개 정적인 메소드

public static ModSqrRoot ( System.Numerics.BigInteger val, System.Numerics.BigInteger prime ) : System.Numerics.BigInteger
val System.Numerics.BigInteger
prime System.Numerics.BigInteger
리턴 System.Numerics.BigInteger

MultiplicativeInverse() 공개 정적인 메소드

Returns the multiplicative inverse of a modulo m.
public static MultiplicativeInverse ( System.Numerics.BigInteger a, System.Numerics.BigInteger m ) : System.Numerics.BigInteger
a System.Numerics.BigInteger
m System.Numerics.BigInteger
리턴 System.Numerics.BigInteger

MultiplicativeInverse() 공개 정적인 메소드

Returns the multiplicative inverse of a modulo m.
public static MultiplicativeInverse ( int a, int m ) : int
a int
m int
리턴 int

MultiplicativeInverse() 공개 정적인 메소드

Returns the multiplicative inverse of a modulo m.
public static MultiplicativeInverse ( long a, long m ) : long
a long
m long
리턴 long

NextRandomBigInt() 공개 정적인 메소드

Returns a random big integer in the specified range. This is based on a simple probabilistic algorithm.
public static NextRandomBigInt ( RNGCryptoServiceProvider rng, System.Numerics.BigInteger minValue, System.Numerics.BigInteger maxValue ) : System.Numerics.BigInteger
rng System.Security.Cryptography.RNGCryptoServiceProvider
minValue System.Numerics.BigInteger Inclusive lower bound.
maxValue System.Numerics.BigInteger Exclusive upper bound.
리턴 System.Numerics.BigInteger

프로퍼티 상세

DHPrime1536 공개적으로 정적으로 프로퍼티

public static BigInteger,System.Numerics DHPrime1536
리턴 System.Numerics.BigInteger

DHPrime2048 공개적으로 정적으로 프로퍼티

public static BigInteger,System.Numerics DHPrime2048
리턴 System.Numerics.BigInteger

DHPrime768 공개적으로 정적으로 프로퍼티

public static BigInteger,System.Numerics DHPrime768
리턴 System.Numerics.BigInteger