View Javadoc
1   package civitas.crypto.parameters.encoder;
2   
3   import org.springframework.stereotype.Controller;
4   
5   import civitas.crypto.CryptoException;
6   import civitas.crypto.parameters.ElGamalParameters;
7   import civitas.util.CivitasBigInteger;
8   
9   @Controller
10  public class SchnorrPrimeEncode {
11  	public CivitasBigInteger apply(final CivitasBigInteger x, final ElGamalParameters elGamalParameters)
12  			throws CryptoException {
13  		if (x.compareTo(elGamalParameters.q) > 0) {
14  			throw new CryptoException("Message is too large for parameters");
15  		}
16  		return elGamalParameters.g.modPow(x, elGamalParameters.p);
17  	}
18  }