ElGamal encryption, Signature algorithm notes

Source: Internet
Author: User
Tags asymmetric encryption

ElGamal encryption Algorithm is an asymmetric encryption algorithm, based on the Diffie-hellman key exchange algorithm, proposed by Taher ElGamal in 1985.

The ElGamal encryption algorithm can be applied to any cyclic group (cyclic group). It is difficult to solve some operations in a group, these operations are usually related to solving discrete logarithm (discrete logarithm), and the difficulty of solving determines the security of the algorithm.

Definition of a group (group):

A group is a concept in mathematics.

A collection of elements that, if the element satisfies the following conditions, is called a group of these elements:

A 2-element operation can be defined on the element, which satisfies the sealing, binding law, unit element and inverse element.

Examples of groups:

All integers form a group, if the defined 2-dollar operation is an integer addition. Addition can satisfy the above conditions:

Closed: A+b is still an integer after

Set Rate: (A + b) + c = A + (b + c)

Unit meta: 0 + a = a + 0 = A, the integer 0 is the unit of the addition

Inverse: A + b = b + A = 0, then integer b is called an inverse of integer a

Therefore, it is easy to understand the group as a set of elements plus a selected operation mode.

Cyclic group definition of:

All other elements in the loop group are computed by using a different number of selected operations for an element G.

Public key generation:

1. Select a cyclic group G, and the Order of the cyclic group G is Q

2. Select a random number x,1<x<q-1

3. Calculation h=g^x

H and G,g,q constitute the public key

X is confidential, and X together with H,g,g,q form the key

Public Key cryptography:

1. Select a random number y,1<y<q-1

2. Calculation C1=g^y

3. Calculation s=h^y= (g^x) ^y=g^ (x*y)

4, the number of encryption m to c2=m*s

C1, C2 constitute the result of encryption, to the private key decryption

Private key decryption:

1. s=c1^x= (g^y) ^x=g^ (x*y) obtained by C1 calculation

2, Calculate c2* (s^-1) = (m*s) * (s^-1), get the original number M

Note that the above operation is no longer an ordinary multiplication (*) and a exponentiation (^) operation, and there is an operation derived from the cyclic group G corresponding to the operation. But the meanings and laws of these operations are the same as those of ordinary numerical operations, so the equation above is still true.

As seen above, the calculation of S is similar to the Diffie-hellman key exchange algorithm.

The cyclic group G commonly used in the application is the integer modulo n multiplication Group (multiplicative group of integers modulo n).

Co-yu:

If the integer A, B's modulo equal to the integer n is a%n=b%n, then it is called a and about modulo n congruence. Can remember to do:

A≡b (mod n)

coprime (coprime integers):

If the maximum common factor of integers A and B is 1, then A, b coprime.

integer modulo n multiplication Group : A multiplication group is formed by the coprime of modulo n.

Signature and validation algorithms, based on the integer modulo n multiplication Group:

Private key, public key generation:

1. Select a random number k,1<x<p-1

2. Calculation y=g^x%p

(g, p, y) is the public key and X is the private key.

Sign with private key:

1, select a random number k,1<k<p-1, and K and p-1 congruence

2, Calculation R,r meet: r≡g^k (mod p)

3, Calculation S,s meet: S≡ (H (M)-xr) * (k^ ( -1)) (mod p-1)

M is the message to be signed, and H (m) is the hash of M (for example, SHA1) result.

(r,s) constitutes the signature of M

To verify the signature with the public key:

1. Verification: 0<r<p,0<s<p-1

2. Verification: g^ (H (m)) ≡ (y^r) * (r^s) (mod p)

The correctness of signature algorithm proves that:

By signature process: H (m) ≡s*k+x*r (mod p-1)

According to Fermat theorem:

g^ (H (m)) ≡g^ (x*r) *g^ (k*s) (mod p) ≡ ((g^x) ^r) * (g^k) ^s (mod p) ≡ (y^r) * (r^s) (mod p)

Reference:

ElGamal Encryption algorithm: http://en.wikipedia.org/wiki/ElGamal_encryption

Group: Http://zh.wikipedia.org/wiki/%E7%BE%A4

Cycle Group: Http://zh.wikipedia.org/wiki/%E5%BE%AA%E7%92%B0%E7%BE%A4

Same remainder operation: http://zh.wikipedia.org/wiki/%E5%90%8C%E9%A4%98

Coprime: Http://zh.wikipedia.org/wiki/%E4%BA%92%E8%B3%AA

Integer modulus n multiplication Group: http://zh.wikipedia.org/wiki/%E6%95%B4%E6%95%B0%E6%A8%A1n%E4%B9%98%E6%B3%95%E7%BE%A4

Discrete logarithm: http://en.wikipedia.org/wiki/Discrete_logarithm

Diffie-hellman key exchange algorithm: http://my.oschina.net/u/1382972/blog/330456

Fermat theorem: http://zh.wikipedia.org/wiki/%E8%B4%B9%E9%A9%AC%E5%B0%8F%E5%AE%9A%E7%90%86



ElGamal encryption, Signature algorithm notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.