I want to add the homomorphic property to Elgamal in libgcrypt.
This is the core code I added to the library.
static void
do_homo_mul (gcry_mpi_t a, gcry_mpi_t b, gcry_mpi_t data1_a, gcry_mpi_t data1_b, gcry_mpi_t data2_a, gcry_mpi_t data2_b, ELG_public_key *pkey)
{
mpi_normalize (data1_a);
mpi_normalize (data1_b);
mpi_normalize (data2_a);
mpi_normalize (data2_b);
mpi_mulm (a, data1_a, data2_a, pkey->p);
mpi_mulm (b, data1_b, data2_b, pkey->p);
}
But I cannot get the right result. What is wrong with my code?