Created
October 22, 2013 18:37
-
-
Save maxtaco/7105751 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cryptographic blinding: compute random r, | |
# r_e <- r^e mod n | |
# and x <- x*r_e mod n | |
n = @pub.n | |
await SRF().random_zn n, defer r | |
r_inv = r.modInverse(n) | |
r_e = r.modPow(@pub.e,n) | |
x_1 = x.multiply(r_e).mod(n) | |
# calculate xp and xq | |
xp = x_1.mod(@p).modPow(@dP, @p) | |
xq = x_1.mod(@q).modPow(@dQ, @q) | |
# xp must be larger than xq to avoid signed bit usage | |
while xp.compareTo(xq) < 0 | |
xp = xp.add @p | |
# do last step | |
y_0 = xp.subtract(xq).multiply(@qInv).mod(@p).multiply(@q).add(xq) | |
# multiply by r^-1... | |
y = y_0.multiply(r_inv).mod(n) | |
cb y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment