	
/*  A's Diffie-Hellmann parameters (P, g) are (24691, 106) respectively and his public key is 12375. 
    This program computes A's private key .*/

	#include <stdio.h> 
	int main() {
		long gen = 106 , prime = 24691 ;  /* Generator and the prime number*/
		int publickey = 12375 , privatekey , i = 1;
		char flag = 0 ;
		while ( !flag) {
			i++ ;
			gen = gen*(106 % prime) % prime ;
			if (gen == publickey ) {
				flag = 1 ;
				privatekey = i ;
			}
		}
		printf ( "Private key is %i \n",privatekey ) ;
	}
