Documentation ¶
Index ¶
- Constants
- Variables
- func Amplitude(real, imag []float64) []float64
- func ApproximateEntropy(m uint64, n uint64) (float64, bool, error)
- func BerlekampMasseyAlgorithm(s []uint8) uint64
- func BerlekampMasseyAlgorithmFromNIST(s []uint8) uint64
- func BlockFrequency(M uint64, n uint64) (float64, bool, error)
- func CumulativeDistribution(z float64) float64
- func CumulativeSums(mode int, n uint64) (float64, bool, error)
- func CumulativeSums_All() ([]float64, []bool, error)
- func DFT(X []float64) ([]float64, []float64)
- func DFT_naive(input []float64) ([]float64, []float64)
- func DecisionRule(_P_value float64, level float64) bool
- func DecisionRule2(_P_value1 float64, _P_value2 float64, level float64) bool
- func DiscreteFourierTransform(n uint64) (float64, bool, error)
- func FFT(X []float64) ([]float64, []float64)
- func Frequency(n uint64) (float64, bool, error)
- func GetEpsilon() []uint8
- func GetLevel() float64
- func InputEpsilon(_input []uint8)
- func InputEpsilonAsString(_input string)
- func InputEpsilonAsString_NonRevert(_input string)
- func LinearComplexity(M uint64, n uint64) (float64, bool, error)
- func LongestRunOfOnes(n uint64) (float64, bool, error)
- func Max(a uint64, b uint64) uint64
- func Modulus(real, imag []float64) []float64
- func NonOverlappingTemplateMatching(B []uint8, eachBlockSize uint64) (float64, bool, error)
- func OverlappingTemplateMatching(B []uint8, eachBlockSize uint64) (float64, bool, error)
- func Pr(u int, eta float64) float64
- func Prepare_CONSTANT_E_asEpsilon() error
- func Prepare_CONSTANT_PI_asEpsilon() error
- func PrettyPrint_Add(testName string, P_value float64, isRandom bool)
- func PrettyPrint_Add_Array(testName string, P_value []float64, isRandom []bool)
- func PrettyPrint_Init()
- func PrettyPrint_Render()
- func RandomExcursions(n uint64) ([]float64, []bool, error)
- func RandomExcursionsVariant(n uint64) ([]float64, []bool, error)
- func Rank(n uint64) (float64, bool, error)
- func RankComputationOfBinaryMatrices(matrix [][]uint8) uint64
- func Runs(n uint64) (float64, bool, error)
- func Serial(m uint64, n uint64) ([]float64, []bool, error)
- func SetEpsilon(_input []uint8)
- func SetLevel(_level_between_0_and_1 float64)
- func Uint_To_BitsArray(input uint64) (bitArray []uint8)
- func Uint_To_BitsArray_size_N(input uint64, N uint64) (bitArray []uint8)
- func Universal(L uint64, Q uint64, n uint64) (float64, bool, error)
- func Universal_Recommended() (float64, bool, error)
Constants ¶
const NONE uint64 = ^uint64(0)
Variables ¶
var AperiodicTemplates [][][]uint8 = [][][]uint8{
{
{0, 1}, {1, 0}},
{
{0, 0, 1}, {0, 1, 1},
{1, 0, 0}, {1, 1, 0},
},
{
{0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1},
{1, 0, 0, 0}, {1, 1, 0, 0}, {1, 1, 1, 0},
},
{
{0, 0, 0, 0, 1}, {0, 0, 0, 1, 1}, {0, 0, 1, 0, 1}, {0, 1, 0, 1, 1},
{0, 0, 1, 1, 1}, {0, 1, 1, 1, 1}, {1, 1, 1, 0, 0}, {1, 1, 0, 1, 0},
{1, 0, 1, 0, 0}, {1, 1, 0, 0, 0}, {1, 0, 0, 0, 0}, {1, 1, 1, 1, 0},
},
{
{0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 1, 1}, {0, 0, 0, 1, 0, 1}, {0, 0, 0, 1, 1, 1}, {0, 0, 1, 0, 1, 1}, {0, 0, 1, 1, 0, 1}, {0, 0, 1, 1, 1, 1}, {0, 1, 0, 0, 1, 1}, {0, 1, 0, 1, 1, 1}, {0, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0}, {1, 0, 1, 0, 0, 0}, {1, 0, 1, 1, 0, 0}, {1, 1, 0, 0, 0, 0}, {1, 1, 0, 0, 1, 0}, {1, 1, 0, 1, 0, 0}, {1, 1, 1, 0, 0, 0}, {1, 1, 1, 0, 1, 0}, {1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 0},
},
{
{0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 1, 1}, {0, 0, 0, 0, 1, 0, 1}, {0, 0, 0, 0, 1, 1, 1},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, 1, 0, 0, 0, 1, 0, 0}, {1, 1, 0, 0, 1, 0, 0, 0}, {1, 1, 0, 0, 1, 0, 1, 0}, {1, 1, 0, 1, 0, 0, 0, 0}, {1, 1, 0, 1, 0, 0, 1, 0}, {1, 1, 0, 1, 0, 1, 0, 0}, {1, 1, 0, 1, 1, 0, 0, 0}, {1, 1, 0, 1, 1, 0, 1, 0}, {1, 1, 0, 1, 1, 1, 0, 0}, {1, 1, 1, 0, 0, 0, 0, 0}, {1, 1, 1, 0, 0, 0, 1, 0}, {1, 1, 1, 0, 0, 1, 0, 0}, {1, 1, 1, 0, 0, 1, 1, 0}, {1, 1, 1, 0, 1, 0, 0, 0}, {1, 1, 1, 0, 1, 0, 1, 0}, {1, 1, 1, 0, 1, 1, 0, 0}, {1, 1, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 1, 0, 0, 1, 0}, {1, 1, 1, 1, 0, 1, 0, 0}, {1, 1, 1, 1, 0, 1, 1, 0}, {1, 1, 1, 1, 1, 0, 0, 0}, {1, 1, 1, 1, 1, 0, 1, 0}, {1, 1, 1, 1, 1, 1, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 0},
},
}
According to Page 72. I found the pattern that all data is odd number. It means, 1, 3, 5, ..., maximum-3, maximum-1
var CONSTANT_E []uint8
var CONSTANT_PI []uint8
var LEVEL float64 = 0.01 // for Decision Rule
var MACHEP float64 = 1.38777878078144567553e-17
var MAXLOG float64 = 7.09782712893383996732e2
Functions ¶
func ApproximateEntropy ¶
Input Size Recommendation Choose m and n such that m < floor(log_2 (n))- 5.
func BerlekampMasseyAlgorithm ¶
TyeolRik's Implementation with Go-lang Handbook of Applied Cryptography, Page 201. 6.30 Algorithm Berlekamp-Massey algorithm
func BerlekampMasseyAlgorithmFromNIST ¶
From NIST SP800-22, linearComplexity.c Handbook of Applied Cryptography, Page 201. 6.30 Algorithm Berlekamp-Massey algorithm
func BlockFrequency ¶
Input Size Recommendation The block size M should be selected such that M >= 20, M > 0.01n and N < 100. n >= 100
func CumulativeDistribution ¶
https://stats.stackexchange.com/a/187909 Wolfram Alpha : Online Computation https://www.wolframalpha.com/input/?i=1+%2F+sqrt%282+*+pi%29+integral_%28-inf%29%5Ez+e%5E%28-u%5E2+%2F+2%29+du
func CumulativeSums ¶
param mode: A switch for applying the test either forward through the input sequence
mode = 0 : forward through the input sequence mode = 1 : backward through the sequence
func CumulativeSums_All ¶
func DFT ¶
Discrete Fourier Transform 3.6 Discrete Fourier Transform (Specral) Test, Page 68. Wiki definition // https://en.wikipedia.org/wiki/Discrete_Fourier_transform#Definition
func DecisionRule ¶
func FFT ¶
Motivated : https://github.com/mjibson/go-dsp/blob/master/fft/fft.go
func GetEpsilon ¶
func GetEpsilon() []uint8
func InputEpsilon ¶
func InputEpsilon(_input []uint8)
func InputEpsilonAsString ¶
func InputEpsilonAsString(_input string)
func InputEpsilonAsString_NonRevert ¶
func InputEpsilonAsString_NonRevert(_input string)
func LinearComplexity ¶
Input Size Recommendation n >= 10^6, 500 <= M <= 5000, (n / M) >= 200
func LongestRunOfOnes ¶
Input Size Recommendation n >= 128
func Modulus ¶
https://numpy.org/doc/stable/reference/generated/numpy.absolute.html For complex input, a + ib, the absolute value is Sqrt(a^2 + b^2)
func NonOverlappingTemplateMatching ¶
Input Size Recommendation Additionally, be sure that M > 0.01 * n and N=floor(n/M). Original Function in Official Document was func NonOverlappingTemplateMatching(m uint64, n uint64, eachBlockSize uint64) However, this parameter look slightly odd to Golang. So, I changed.
Variable B The m-bit template to be matched B is a string of ones and zeros (of length m) which is defined in a template library of non-periodic patterns contained within the test code.
func OverlappingTemplateMatching ¶
Input Size Recommendation NIST recommends m = 9 or m = 10, n >= 10^6 m should be chosen so that m ≈ log_2(M)
func Prepare_CONSTANT_E_asEpsilon ¶
func Prepare_CONSTANT_E_asEpsilon() error
func Prepare_CONSTANT_PI_asEpsilon ¶
func Prepare_CONSTANT_PI_asEpsilon() error
func PrettyPrint_Add ¶
func PrettyPrint_Add_Array ¶
func PrettyPrint_Init ¶
func PrettyPrint_Init()
func PrettyPrint_Render ¶
func PrettyPrint_Render()
func RankComputationOfBinaryMatrices ¶
According to NIST SP800-22 Revision 1a. Page. 123 F.1 Rank Computation of Binary Matrices
func Runs ¶
Runs function returns "The total number of runs" across all n bits. the total number of zero runs + the total number of one-runs
func SetEpsilon ¶
func SetEpsilon(_input []uint8)
func Uint_To_BitsArray ¶
func Universal ¶
Input Size Recommendation n >= (Q + K)L 6 <= L <= 16, Q = 10 * 2^{L}, K =floor(n/L)- Q ≈ 1000 * 2^{L} The values of L, Q and n should be chosen as follows
func Universal_Recommended ¶
Types ¶
This section is empty.
Source Files ¶
- approximateEntropy.go
- binaryMatrixRank.go
- blockFrequency.go
- cumulativeSums.go
- discreteFourierTransfrom_Spectral.go
- frequency.go
- globalMathFunction.go
- globalProgrammerFunction.go
- globalVariable.go
- linearComplexity.go
- longestRunOfOnesInABlock.go
- nonOverlappingTemplateMatching.go
- overlappingTemplateMatching.go
- pretty_print.go
- randomExcursions.go
- randomExcursionsVariant.go
- runs.go
- serial.go
- universal.go