[Pkg-privacy-commits] [obfsproxy] 200/353: Add function for fast modular exponentiation.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:01:59 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfsproxy.

commit 65d5f4f3947b115421f273b7edb22420035c3ca3
Author: Philipp Winter <phw at torproject.org>
Date:   Sat Oct 26 19:05:27 2013 +0200

    Add function for fast modular exponentiation.
    
    The function uses GMPY's bignum arithmetic which speeds up the calculation.
---
 obfsproxy/common/modexp.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/obfsproxy/common/modexp.py b/obfsproxy/common/modexp.py
new file mode 100644
index 0000000..7c07f98
--- /dev/null
+++ b/obfsproxy/common/modexp.py
@@ -0,0 +1,15 @@
+import gmpy
+
+def powMod( x, y, mod ):
+    """
+    Efficiently calculate and return `x' to the power of `y' mod `mod'.
+
+    Before the modular exponentiation, the three numbers are converted to
+    GMPY's bignum representation which speeds up exponentiation.
+    """
+
+    x = gmpy.mpz(x)
+    y = gmpy.mpz(y)
+    mod = gmpy.mpz(mod)
+
+    return pow(x, y, mod)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfsproxy.git



More information about the Pkg-privacy-commits mailing list