This demo is a two party threshold encryption based on the algorithm ECC-Elliptic-curve cryptography
Elliptical curve cryptography (ECC) is a public key encryption technique based on elliptic curve theory that can be used to create faster, smaller and more efficient cryptographic keys.
ECC is an alternative to the Rivest-Shamir-Adleman ( RSA ) encryption algorithm and is most commonly used for digital signatures in cryptocurrencies such as Bitcoin and Ether, and for one-way encryption of email, data, and software.
ECC uses a mathematical process to merge two different keys and then uses the output to encrypt and decrypt the data. One is a public key known to anyone, and the other is a private key known only to the sender and receiver of the data
In cryptography, the ElGamal encryption system is an asymmetric key encryption algorithm for public-key cryptography based on the Diffie–Hellman key exchange.
Compared with RSA algorithm, the characteristic of ElGamal algorithm is that even if the same private key is used to encrypt the same plaintext, the signatures obtained after each encryption are different, which effectively prevents possible replay attacks in the network.
ElGamal encryption consists of three components: the Key Generator, the Encryption Algorithm, and the Decryption Algorithm.
Reference:
https://medium.com/asecuritysite-when-bob-met-alice/elgamal-and-elliptic-curve-cryptography-ecc-8b72c3c3555e
https://link.springer.com/chapter/10.1007/3-540-39568-7_2
Two-party EC-ElGamal scheme: two-party computation of ciphertext
The global decryption key is:
The global encryption key is:
Pros: The key share could be refreshed
Symbol | Notion | Symbol | Notion |
---|---|---|---|
The base point of the elliptic curve | Global private key (no one knows it) (type: scalar) | ||
The order of the base point | Global public key (type: ecpoint) | ||
The order of the base point | party-i 's private key (key share of |
||
+ | Numerical addition | party-i 's public key (key share of |
|
* | Numerical multiplication | party-i 's commiment (type: scalar) | |
Elliptic curve point addition operation | Random number (type: scalar) | ||
Elliptic curve multiplier operation | message | ||
keccak256 | ciphertext | ciphertext of m under AES with symmetric key | |
Point can derive symmetric key | sym_key | symmetric key k |
step1: Generate the keypair
Function | Math operation |
---|---|
generate_key_share(m, n) at party-i | |
rand(p) at party-i | r \stackrel{R}{\longleftarrow} [1,p] |
generate_commitment(m, n) at party-i | c = H(m || n) |
verify_commitment(c, m, n) at party-i |
|
This process is a standard hybrid encryption EC-ElGamal, provided that the encrypting party itself obtains the global encryption key
step1: encrypt-party call generate_sym_key(p) to generate a random
Function | Math operation |
---|---|
generate_key_point(p) at party-i |
|
compute_sym_key( |
step2: encrypt-party invokes AES algorithm, encrypts message m with symmetric key sym_key to get symmetric cipher
Function | Math operation |
---|---|
elgamal_encrypt( |
|
step3: Disclose the ciphertext(ciphertext, C1, C2)
step1: Party-i computes a partial decryption of
Function | Math operation |
---|---|
compute_partial_decryption( |
step2: party-i sends
step3: party-i calls elgamal_decrypt(D1, D2, C2), get
Function | Math operation |
---|---|
elgamal_decrypt(D1, D2, C2) at party-i |
|
step4: party-i calls the AES algorithm and decrypts the symmetric cipher
Implement two-party EC-ElGamal with Python
and Dart
respectively
You could find these two demos in the subdirectory elgamal_python
and elgamal_dart