/* -------------------------------------------------------------
Verification Process of (Balanced) Oil and Vinegar
loads public key from Balanced_OV/public_key.txt and signature and hash value from Balanced_OV/signature.txt
checks if signature is a valid OV Signature for the hash value and outputs TRUE or FALSE
---------------------------------------------------------------*/
clear ;

printf "******************************************************* \n";
printf "**** OV Signature Scheme - Signature Verification ***** \n";
printf "******************************************************* \n \n";

timet := Cputime() ;
load "public_key.txt";
load "signature.txt";

printf "signature:= %o \n\n", signature;

printf "message     := %o \n", hashvalue;

for i:=1 to o do
	for j:=1 to n do
		Pk[i]:=Evaluate(Pk[i],x[j],signature[j]);
	end for;
end for;
hash2:=Hashspace!(Pk);

printf "P(signature):= %o \n \n", hash2;
printf "Balanced OV time to verify: %o\n\n",Cputime(timet) ;

if hashvalue eq hash2 then
	printf"CORRECT!";
else
	printf"FALSE!";
end if;





