Skip to content

Instantly share code, notes, and snippets.

@cyborch
Created August 2, 2019 11:24
Show Gist options
  • Save cyborch/78e156fc3ea9636826ef0bbc77593e85 to your computer and use it in GitHub Desktop.
Save cyborch/78e156fc3ea9636826ef0bbc77593e85 to your computer and use it in GitHub Desktop.
Prove membership of a set in an RSA accumulator
fun proveMembershipOrNull(x: BigInteger): RSAProof? {
return if (!data.containsKey(x)) {
null
} else {
var product = BigInteger.ONE
for ((k, v) in data) {
if (k != x) {
product *= hashToPrime(k, ACCUMULATED_PRIME_SIZE, v).first
}
}
RSAProof(A0.modPow(product, n), hashToPrime(x, ACCUMULATED_PRIME_SIZE, getNonce(x)).first)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment