Homomorphic encryption addition using Exponential ElGamal

Hello I have the following code with which I am trying to test homomorphic encryption using different algorithms for a csv file generated random but the Exponential ElGamal approach does not work properly my program stops and gives not responding even for a small number of transactions generated
The code is here:

import tkinter as tk
from tkinter import filedialog, scrolledtext, ttk
import csv
import random
import time
from lightphe import LightPHE
import os

def generate_and_write_transactions(filename, num_transactions):
    transactions = []
    for _ in range(num_transactions):
        amount_received = round(random.uniform(10, 500), 2)  
        transactions.append(("Deposit", amount_received))
    
    with open(filename, "w", newline="") as csvfile:
        csvwriter = csv.writer(csvfile)
        csvwriter.writerow(["Transaction Type", "Amount"])
        csvwriter.writerows(transactions)

def compute_total_amount():
    try:
        start_time = time.time()
        filename = "transaction_history.csv"
        total_amount = 0
        
        with open(filename, 'r') as file:
            reader = csv.reader(file)
            next(reader)  # Skip header row
            for row in reader:
                if row[0] == 'Deposit':
                    total_amount += float(row[1])
        
        end_time = time.time()
        result_label.config(text=f"Total amount (traditional computation): ${total_amount:.2f}nTime taken: {end_time - start_time:.6f} seconds")
    except Exception as e:
        result_label.config(text="Error: " + str(e))

def compute_total_amount_homomorphic():
    try:
        start_time = time.time()
        filename = "transaction_history.csv"

        cs = LightPHE(algorithm_name="Paillier")
        
        encrypted_values = []  

        with open(filename, 'r') as file:
            reader = csv.reader(file)
            next(reader)  
            for row in reader:
                if row[0] == 'Deposit':
                    encrypted_amount = cs.encrypt(plaintext=[float(row[1])])  # Encrypt float as a tensor
                    encrypted_values.append(encrypted_amount)
        
        # Homomorphically add all encrypted values together
        total_encrypted_sum = encrypted_values[0]
        for encrypted_amount in encrypted_values[1:]:
            total_encrypted_sum += encrypted_amount
        
        # Decrypt the total sum
        total_sum_decrypted = cs.decrypt(total_encrypted_sum)[0]  # Convert tensor back to float
        
        end_time = time.time()
        
        result_text = f"Total amount (homomorphic encryption Paillier): ${total_sum_decrypted:.2f}nTime taken: {end_time - start_time:.6f} seconds"
        result_label.config(text=result_text)
    except Exception as e:
        result_label.config(text="Error: " + str(e))
def compute_total_amount_elgamal():
    try:
        start_time = time.time()
        filename = "transaction_history.csv"

        cs = LightPHE(algorithm_name="Exponential-ElGamal")

        encrypted_values = []  

        with open(filename, 'r') as file:
            reader = csv.reader(file)
            next(reader)  
            for row in reader:
                if row[0] == 'Deposit':
                    encrypted_amount = cs.encrypt(plaintext=[float(row[1])])  # Encrypt float as a tensor
                    encrypted_values.append(encrypted_amount)
        
        # Homomorphically add all encrypted values together
        total_encrypted_sum = encrypted_values[0]
        for encrypted_amount in encrypted_values[1:]:
            total_encrypted_sum += encrypted_amount
        
        # Decrypt the total sum
        total_sum_decrypted = cs.decrypt(total_encrypted_sum)[0]  # Convert tensor back to float
        
        end_time = time.time()
        
        result_text = f"Total amount (homomorphic encryption ElGamal): ${total_sum_decrypted:.2f}nTime taken: {end_time - start_time:.6f} seconds"
        result_label.config(text=result_text)
    except Exception as e:
        result_label.config(text="Error: " + str(e))
def update_transaction_count():
    try:
        global num_transactions
        num_transactions = int(transaction_entry.get())
        generate_and_write_transactions("transaction_history.csv", num_transactions)
        transaction_count_label.config(text=f"Transactions generated: {num_transactions}")
    except ValueError:
        transaction_count_label.config(text="Invalid input. Please enter a valid integer.")

def view_csv():
    try:
        with open("transaction_history.csv", 'r') as file:
            data = file.read()
            csv_display.delete(1.0, tk.END)
            csv_display.insert(tk.END, data)
    except FileNotFoundError:
        csv_display.delete(1.0, tk.END)
        csv_display.insert(tk.END, "CSV file not found.")

def delete_csv_file():
    try:
        os.remove("transaction_history.csv")
        root.destroy()
    except FileNotFoundError:
        root.destroy()

root = tk.Tk()
root.title("Bank Account Testing")

root.geometry("800x600") 

# Styling
root.configure(bg="#8f9c92")
style = ttk.Style()
style.configure('TButton', background='#3a32a8', foreground='#070807')

# Input for number of transactions
transaction_label = tk.Label(root, text="Enter number of transactions to generate:", bg="#f0f0f0")
transaction_label.pack(pady=(20, 0))

transaction_entry = tk.Entry(root, width=10)
transaction_entry.pack()

generate_button = ttk.Button(root, text="Generate Transactions", command=update_transaction_count)
generate_button.pack(pady=10)

transaction_count_label = tk.Label(root, text="", bg="#8f9c92")
transaction_count_label.pack()

# Display CSV data
csv_display = scrolledtext.ScrolledText(root, width=60, height=15, wrap=tk.WORD)
csv_display.pack(pady=10)

view_csv_button = ttk.Button(root, text="View CSV", command=view_csv)
view_csv_button.pack(pady=5)

# Buttons to compute total amount
compute_button = ttk.Button(root, text="Compute Total Amount (Traditional)", command=compute_total_amount)
compute_button.pack(pady=10)

compute_homomorphic_button = ttk.Button(root, text="Compute Total Amount (Homomorphic encryption Paillier)", command=compute_total_amount_homomorphic)
compute_homomorphic_button.pack(pady=5)

# Button to compute total amount using ElGamal encryption
compute_elgamal_button = ttk.Button(root, text="Compute Total Amount (Homomorphic encryption ElGamal)", command=compute_total_amount_elgamal)
compute_elgamal_button.pack(pady=5)

result_label = tk.Label(root, text="", bg="#8f9c92")
result_label.pack()

# Exit button to delete CSV file and close the application
exit_button = ttk.Button(root, text="Exit", command=delete_csv_file)
exit_button.pack(pady=10)

root.mainloop()

The program works well for Paillier and normal addition but It crashes when trying to use it for exponential elgamal algorithm

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật