This directory contains verilog source codes for PSEC-KEM in endomorphic curve.
The source files are attached with the ISC 11.1 project file "ScalarMultiplier.xise".

To perform encryption, make the "kem_enc" top module.
It takes the public and the base point as input to perform encryption.
The random number is considered as an input to the module.

To perform decryption, make the "kem_dec" top module.
It takes the received message from the encryption hardware 
and the secret key to perform decryption. The output is 
the session key and the validation bit.

Sample test bench codes for the decryption module is "tb_kem_dec".

IMPORTANT POINTS TO NOTE
=========================
Since the scalar multiplication takes a loat of time, we have reduced the scalar size to only 4 bits in the source code. Shorter scalar size makes simulation faster.

To keep original size of the scalar, follow the steps listed bellow.

1) In kem_enc module change the following line 
ScalarMultiplier scm(ecp_rst, clk, {252'd0,alpha[3:0]}, base_x, base_y, sx, sy, decom_state, scm_state, scm_counter, ecp_done);
to
ScalarMultiplier scm(ecp_rst, clk, alpha, base_x, base_y, sx, sy, decom_state, scm_state, scm_counter, ecp_done);

2) In kem_dec module change the following line 
mux2_256bit   m3(secret_key, {252'd0,alpha[3:0]}, scalar_sel, scalar_out);	
to
mux2_256bit   m3(secret_key, alpha, scalar_sel, scalar_out);


	
