Skip to content

Commit

Permalink
version 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Haydar Demirhan authored and cran-robot committed Feb 25, 2016
1 parent e2ce8af commit e43f966
Show file tree
Hide file tree
Showing 12 changed files with 2,759 additions and 205 deletions.
21 changes: 15 additions & 6 deletions DESCRIPTION
@@ -1,15 +1,24 @@
Package: CryptRndTest
Type: Package
Title: Statistical Tests for Cryptographic Randomness
Version: 1.2.1
Date: 2015-12-24
Author: Haydar Demirhan
Version: 1.2.2
Date: 2016-02-24
Author: Haydar Demirhan
Maintainer: Haydar Demirhan <haydarde@hacettepe.edu.tr>
Description: Performs cryptographic randomness tests on a sequence of random integers or bits. Included tests are greatest common divisor, birthday spacings, book stack, adaptive chi-square, topological binary, and three random walk tests. Tests except greatest common divisor and birthday spacings are not covered by standard test suites. In addition to the chi-square goodness-of-fit test, results of Anderson-Darling, Kolmogorov-Smirnov, and Jarque-Bera tests are also generated by some of the cryptographic randomness tests.
Description: Performs cryptographic randomness tests on a sequence of random
integers or bits. Included tests are greatest common divisor, birthday spacings,
book stack, adaptive chi-square, topological binary, and three random walk
tests. Tests except greatest common divisor and birthday spacings are not
covered by standard test suites. In addition to the chi-square goodness-of-fit
test, results of Anderson-Darling, Kolmogorov-Smirnov, and Jarque-Bera tests are
also generated by some of the cryptographic randomness tests.
Depends: MissMech, kSamples, sfsmisc, Rmpfr, parallel
Imports: LambertW, gmp, tseries, methods
Suggests: R.rsp
VignetteBuilder: R.rsp
License: GPL-3
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2016-01-04 14:02:49 UTC; Stat
Packaged: 2016-02-25 00:43:41 UTC; e27752
Repository: CRAN
Date/Publication: 2016-01-04 15:28:45
Date/Publication: 2016-02-25 05:21:43
15 changes: 11 additions & 4 deletions MD5
@@ -1,13 +1,13 @@
89ff16fe4b2d24a05939a1041d6e21b6 *DESCRIPTION
0963ce0eccb698dace2a13f4c2374f5f *NAMESPACE
03199ba4455b989c8d367957783882d4 *DESCRIPTION
035b07521282a5dcbd699cf539f54f18 *NAMESPACE
a932de32fc9531dc82b578764ed2a871 *R/GCD.R
1b7c36ec62dbbabfecd8a2f51a23ac7b *R/GCD.big.R
991a5fdabd63162144bf066ae0239952 *R/GCD.q.R
3ae5da7ed136aac85a8518f33f23a372 *R/GCD.test.R
a9c19cd33bb198ae37669ed3d8a44bbb *R/GCD.test.default.R
39ca022cbc9abbd5e6b125cb5f31e925 *R/GCD.test.main.R
1d0b330f6fbf6df7cede853d1654702d *R/KSADCHRY.R
4b1f39183e0f932064e57c0e776e5489 *R/KSADdga.R
952870448e5ef997b933db99ba4402d8 *R/KSADdga.R
674b384db89264e1cd498000c1bf4cac *R/Random.walk.D.R
49b1ffdad04d96463b6e7fbdd2e509ae *R/Random.walk.G.R
44c5acbbf64b2ce7a6185ea1cfde1b75 *R/Random.walk.Y.R
Expand All @@ -33,8 +33,12 @@ d4d7cf67230cf1eeaf304922e40e53d4 *R/random.walk.tests.main.R
a32856d16ca0bc9115ff315de240a8b0 *R/topological.binary.R
e2c3869bc7ac9778cc91f540ca626a02 *R/topological.binary.default.R
eeff0d1eb017d5816107be7adb6fa1e6 *R/topological.binary.main.R
3f96c953126dc511038657340491a670 *build/vignette.rds
a081c6107dbe788e69580164ba1c7368 *inst/doc/CryptRndTest.R
93b0ef894967133ed0427fd90611779c *inst/doc/CryptRndTest.ltx
1397244805ae6826ae8e4f3515e33aab *inst/doc/CryptRndTest.pdf
9b78c028ccdde86a855a1044e308045d *man/CryptRndTest-internal.Rd
8417e8482197942e52749537d0abb273 *man/CryptRndTest-package.Rd
61329ef5035a31d2c475e5981b84307a *man/CryptRndTest-package.Rd
46426b0a1c9aa431340b333f7a425b58 *man/GCD.Rd
1dd353fe833e9128ba46aa48971c781c *man/GCD.big.Rd
1349f0f5ed2ad37201f883d75b3c06d0 *man/GCD.q.Rd
Expand All @@ -49,3 +53,6 @@ ed00fe05150d9001fcbb4f69ff04419b *man/birthday.spacings.Rd
0f3a9dc2818890821b8f6c0ff1a1062d *man/toBaseTen.Rd
cdd3c1619aeec3a159da599e83cc4008 *man/toBaseTwo.Rd
f8273920ea3772dd41a149405b8315e7 *man/topological.binary.Rd
fd29af2a7284e285bc7fd559dadabfbb *vignettes/CryptRndTest.ltx
8466d084a9513a46d715c12f678763c4 *vignettes/RJournal.sty
c2519c816a850199cc2b2f70bfd65909 *vignettes/demirhan_Crypt_2015.bib
92 changes: 42 additions & 50 deletions NAMESPACE
@@ -1,57 +1,49 @@
exportPattern("^[[:alpha:]]+")
# Generated by roxygen2: do not edit by hand

importFrom(sfsmisc,digitsBase)

importFrom(tseries,jarque.bera.test)

importFrom(kSamples,ad.test)

importFrom(MissMech,AndersonDarling)

importFrom(LambertW,W)

importFrom(gmp,Stirling2)

importFrom(Rmpfr,mpfr)

importFrom(Rmpfr,mpfrArray)

importFrom(parallel,makePSOCKcluster)

importFrom(parallel,setDefaultCluster)
importFrom(parallel,clusterExport)

importFrom(parallel,parLapply)

importFrom(parallel,stopCluster)

importFrom("stats", "chisq.test", "dpois", "ks.test", "pchisq","rnorm", "runif")

importFrom("methods", "new")

importFrom("utils", "write.table")

S3method(adaptive.chi.square,default)

S3method(birthday.spacings,default)

S3method(book.stack,default)

S3method(GCD.test,default)

S3method(random.walk.tests,default)
S3method(topological.binary,default)


S3method(GCD.test,main)
S3method(adaptive.chi.square,default)
S3method(adaptive.chi.square,main)

S3method(birthday.spacings,default)
S3method(birthday.spacings,main)

S3method(book.stack,default)
S3method(book.stack,main)

S3method(GCD.test,main)

S3method(print,CryptRndTest)
S3method(random.walk.tests,default)
S3method(random.walk.tests,main)
S3method(topological.binary,default)
S3method(topological.binary,main)

S3method(print,CryptRndTest)
export(GCD)
export(GCD.big)
export(GCD.q)
export(GCD.test)
export(Strlng2)
export(TBT.criticalValue)
export(adaptive.chi.square)
export(birthday.spacings)
export(book.stack)
export(random.walk.tests)
export(toBaseTen)
export(toBaseTwo)
export(topological.binary)
importFrom(LambertW,W)
importFrom(MissMech,AndersonDarling)
importFrom(Rmpfr,mpfr)
importFrom(Rmpfr,mpfrArray)
importFrom(gmp,Stirling2)
importFrom(kSamples,ad.test)
importFrom(methods,new)
importFrom(parallel,clusterExport)
importFrom(parallel,makePSOCKcluster)
importFrom(parallel,parLapply)
importFrom(parallel,setDefaultCluster)
importFrom(parallel,stopCluster)
importFrom(sfsmisc,digitsBase)
importFrom(stats,chisq.test)
importFrom(stats,dpois)
importFrom(stats,ks.test)
importFrom(stats,pchisq)
importFrom(stats,rnorm)
importFrom(stats,runif)
importFrom(tseries,jarque.bera.test)
importFrom(utils,write.table)
140 changes: 95 additions & 45 deletions R/KSADdga.R
@@ -1,46 +1,96 @@
KSADdga=function(e,alfa,n,m,lambda,num.class=10){
z=0
expected=0
p=0
p[1:(num.class+1)]=dpois(0:num.class,lambda=lambda)
p[num.class+1]=p[num.class+1]+sum(dpois((num.class+1):1000,lambda=lambda))
N=length(e)
expected=round(p*N)
if (sum(expected)!=N){
expected[which.max(expected)]=expected[which.max(expected)]-(sum(expected)-N)
}
z=rep(0:(length(expected)-1),expected)
test=kSamples::ad.test(e,z,method="simulated",dist=FALSE,Nsim=1000)
ADtest=test$ad
if (min(ADtest[,3])<alfa){
sonucAD=0
} else{
sonucAD=1
}

KStest=0
test2=ks.test(e,z)
KStest[1]=test2$statistic
KStest[2]=test2$p.value
if (KStest[2]<alfa){
sonucKS=0
} else{
sonucKS=1
}

k=length(expected)
observed=array(0,k)
observed[1:length(table(e))]=table(e)
KKtest=0
observed[which(observed==0)]=10^-5
expected[which(expected==0)]=10^-5
KKtest[1]=sum(((observed-expected)^2)/expected,na.rm=TRUE) #gives test statistic
KKtest[2]=pchisq(KKtest[1],(k-1),lower.tail=FALSE) #gives p.value of the chi-square test
if (KKtest[2]<alfa){
sonucKK=0
} else{
sonucKK=1
}
result=list(sonucAD=sonucAD,ADtest=ADtest,sonucKS=sonucKS,KStest=KStest,sonucKK=sonucKK,KKtest=KKtest)
return(result)
#' @importFrom stats ks.test
#' @importFrom stats chisq.test
#' @importFrom stats dpois
#' @importFrom stats pchisq
#' @importFrom stats rnorm
#' @importFrom stats runif
#' @importFrom parallel parLapply
#' @importFrom parallel clusterExport
#' @importFrom parallel setDefaultCluster
#' @importFrom parallel stopCluster
#' @importFrom parallel makePSOCKcluster
#' @importFrom Rmpfr mpfrArray
#' @importFrom Rmpfr mpfr
#' @importFrom gmp Stirling2
#' @importFrom LambertW W
#' @importFrom MissMech AndersonDarling
#' @importFrom kSamples ad.test
#' @importFrom tseries jarque.bera.test
#' @importFrom sfsmisc digitsBase
#' @importFrom methods new
#' @importFrom utils write.table

#' @S3method adaptive.chi.square default
#' @S3method birthday.spacings default
#' @S3method book.stack default
#' @S3method GCD.test default
#' @S3method random.walk.tests default
#' @S3method topological.binary default
#' @S3method adaptive.chi.square main
#' @S3method birthday.spacings main
#' @S3method book.stack main
#' @S3method GCD.test main
#' @S3method random.walk.tests main
#' @S3method topological.binary main
#' @S3method print CryptRndTest

#' @export adaptive.chi.square
#' @export birthday.spacings
#' @export book.stack
#' @export GCD.test
#' @export random.walk.tests
#' @export topological.binary
#' @export GCD
#' @export GCD.big
#' @export GCD.q
#' @export Strlng2
#' @export TBT.criticalValue
#' @export toBaseTen
#' @export toBaseTwo

KSADdga=function(e,alfa,n,m,lambda,num.class=10){
z=0
expected=0
p=0
p[1:(num.class+1)]=dpois(0:num.class,lambda=lambda)
p[num.class+1]=p[num.class+1]+sum(dpois((num.class+1):1000,lambda=lambda))
N=length(e)
expected=round(p*N)
if (sum(expected)!=N){
expected[which.max(expected)]=expected[which.max(expected)]-(sum(expected)-N)
}
z=rep(0:(length(expected)-1),expected)
test=kSamples::ad.test(e,z,method="simulated",dist=FALSE,Nsim=1000)
ADtest=test$ad
if (min(ADtest[,3])<alfa){
sonucAD=0
} else{
sonucAD=1
}

KStest=0
test2=ks.test(e,z)
KStest[1]=test2$statistic
KStest[2]=test2$p.value
if (KStest[2]<alfa){
sonucKS=0
} else{
sonucKS=1
}

k=length(expected)
observed=array(0,k)
observed[1:length(table(e))]=table(e)
KKtest=0
observed[which(observed==0)]=10^-5
expected[which(expected==0)]=10^-5
KKtest[1]=sum(((observed-expected)^2)/expected,na.rm=TRUE) #gives test statistic
KKtest[2]=pchisq(KKtest[1],(k-1),lower.tail=FALSE) #gives p.value of the chi-square test
if (KKtest[2]<alfa){
sonucKK=0
} else{
sonucKK=1
}
result=list(sonucAD=sonucAD,ADtest=ADtest,sonucKS=sonucKS,KStest=KStest,sonucKK=sonucKK,KKtest=KKtest)
return(result)
}
Binary file added build/vignette.rds
Binary file not shown.

0 comments on commit e43f966

Please sign in to comment.