pkenc_elgamal85¶
ElGamal Public Key Encryption Scheme (ElGamal85)
Authors: T. ElGamal
Title: “A Public Key Cryptosystem and a Signature Scheme Based on Discrete Logarithms”
Published in: CRYPTO 1984
Available from: http://en.wikipedia.org/wiki/ElGamal_encryption
Notes:
Scheme Properties
Type: encryption (public key)
Setting: DDH-hard prime order group
Assumption: DDH
Implementation
- Authors:
Ayo Akinyele
- Date:
3/2011
- class pkenc_elgamal85.ElGamal(groupObj, p=0, q=0)[source]¶
Bases:
PKEnc>>> from charm.toolbox.eccurve import prime192v2 >>> from charm.toolbox.ecgroup import ECGroup >>> groupObj = ECGroup(prime192v2) >>> el = ElGamal(groupObj) >>> (public_key, secret_key) = el.keygen() >>> msg = b"hello world!12345678" >>> cipher_text = el.encrypt(public_key, msg) >>> decrypted_msg = el.decrypt(public_key, secret_key, cipher_text) >>> decrypted_msg == msg True >>> from charm.toolbox.integergroup import IntegerGroupQ, integer >>> p = integer(148829018183496626261556856344710600327516732500226144177322012998064772051982752493460332138204351040296264880017943408846937646702376203733370973197019636813306480144595809796154634625021213611577190781215296823124523899584781302512549499802030946698512327294159881907114777803654670044046376468983244647367) >>> q = integer(74414509091748313130778428172355300163758366250113072088661006499032386025991376246730166069102175520148132440008971704423468823351188101866685486598509818406653240072297904898077317312510606805788595390607648411562261949792390651256274749901015473349256163647079940953557388901827335022023188234491622323683) >>> groupObj = IntegerGroupQ() >>> el = ElGamal(groupObj, p, q) >>> (public_key, secret_key) = el.keygen() >>> msg = b"hello world!" >>> cipher_text = el.encrypt(public_key, msg) >>> decrypted_msg = el.decrypt(public_key, secret_key, cipher_text) >>> decrypted_msg == msg True