• Breaking News

    Sunday, December 23, 2018

    Cryptography trying to implement signature of ElGamal

    Cryptography trying to implement signature of ElGamal


    trying to implement signature of ElGamal

    Posted: 22 Dec 2018 08:49 AM PST

    I'm trying to implement the signature algorithm of ElGamal. The steps I'm following are:

    1. Choose a random number h ∈ [2,p – 2] that is coprime with p - 1, i.e., gcd(h, p-1)=1.
    2. Calculate r = alpha^h mod p
    3. Calculate s = (m – d · r) · h^–1 mod p – 1

    Note: k_priv is the tuple with (prime, alpha, d)

    My code is:

    from math import gcd from operator import mod def elgamal_sign(k_priv, m, k=None): if k is not None: h = k else: h = random.randrange(2, k_priv[0]-2) while True: if gcd(h, k_priv[0]-1) == 1: continue r = pow(k_priv[1], h, k_priv[0]) d = k_priv[2] h_inverse = pow(h, -1) dummy = (m - d * r) * h_inverse s = mod(dummy, k_priv[0]-1) return r, s 

    Suppose the following values:

    m = 42 k_priv = (141627058957340093855620484680587497231, 49407674567884478422262585667470127500, 91557801542207645804476483173676169513) h = 6505205550934361491179720631243 exp_r = 16070586247864526048715174304611921161 exp_s = 79906657969558945308772045181673566953 

    For r, I'm getting the proper value but not for s (I get 2.9919091950952993e+37 instead of exp_s), so I guess my formula of calculating s is wrong.

    submitted by /u/daviddoji
    [link] [comments]

    First time noob using SFTP. Help needed.

    Posted: 22 Dec 2018 12:06 PM PST

    Hello, I'm trying to use FileZilla to connect to a server via sftp. I was given a username, password, and a PGP Signature with a .asc extension. All works well until I get an "Authentication failed." error. I assume I need to add a key file in the Public Key Authentication settings page in FileZilla, but all I have is that PGP signature.

    How would I go about using this .asc file to get the necessary key?

    submitted by /u/Pyqtenoch
    [link] [comments]

    No comments:

    Post a Comment