Skip to content

Instantly share code, notes, and snippets.

@mdcallag
Created September 18, 2018 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdcallag/ae8c23a64b038026f9634a123a221104 to your computer and use it in GitHub Desktop.
Save mdcallag/ae8c23a64b038026f9634a123a221104 to your computer and use it in GitHub Desktop.
fpr = c(seq(0.00001, 0.00009, 0.00001), seq(0.0001, 0.0009, 0.0001), seq(0.001, 0.009, 0.001), seq(0.01, 0.09, 0.01))
bf <- function(e) { ceiling(log2(1/e) * 1.44) }
bf2 = sapply(fpr, bf)
cf <- function(e) { ceiling(log2(1/e) + 3) / 0.95 }
cf2 = sapply(fpr, cf)
bf2:
[1] 24 23 22 22 21 21 20 20 20 20 18 17 17 16 16 16 15 15 15 13 13 12 12 11 11 11 10 10 9 8
[31] 7 7 6 6 6 6
cf2:
[1] 21.052632 20.000000 20.000000 18.947368 18.947368 18.947368 17.894737 17.894737 17.894737
[10] 17.894737 16.842105 15.789474 15.789474 14.736842 14.736842 14.736842 14.736842 14.736842
[19] 13.684211 12.631579 12.631579 11.578947 11.578947 11.578947 11.578947 10.526316 10.526316
[28] 10.526316 9.473684 9.473684 8.421053 8.421053 8.421053 7.368421 7.368421 7.368421
plot(fpr, bf2, log="x", xlab="FPR", ylab="bits/key", col="red")
lines(fpr, cf2, type="p", col="blue")
legend(x=0.00001, y=10, legend=c("BF", "CF"), col=c("red", "blue"), lty=1:2)
plot(fpr, bf2/cf2, log="x", xlab="FPR", ylab="bits/key ratio")
legend(x=0.00001, y=0.8, legend=c("BF bits / CF bits"), lty=1:2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment