R/hash.R

#' Hash functions
#' @description internal functions specific to the generation of cryptographic hashes.
#' @references Some reference for the ed25519 algorithm: http://ed25519.cr.yp.to/
#' @note These functions were adapted from this gist by Johan Stén: https://gist.github.com/johansten/3859fb4f9a24a5b6fee5bef86a3ad91c

.hint <- function(m) {
  h = .hash(m)
  t = lapply(0:511, function(i) {
    as.bigz(2) ** i * .bit(h, i)
  })
  return(sum(do.call(c, t)))
}

.hash <- function(m) {
  return(digest(m, "sha512", serialize = FALSE, raw = TRUE))
}
froocpu/stellaR documentation built on May 17, 2019, 7:05 p.m.