View Javadoc
1   package civitas.crypto.petshare;
2   
3   import org.springframework.beans.factory.annotation.Autowired;
4   import org.springframework.stereotype.Controller;
5   
6   import civitas.crypto.CryptoBase;
7   import civitas.crypto.ciphertext.ElGamalCiphertextish;
8   import civitas.crypto.parameters.ElGamalParameters;
9   import civitas.util.CivitasBigInteger;
10  
11  @Controller
12  public class ConstructPETShare {
13  
14  	@Autowired
15  	CryptoBase cryptoBase;
16  
17  	public PETShare apply(final ElGamalParameters params, final ElGamalCiphertextish a, final ElGamalCiphertextish b) {
18  		if (a == null || b == null || params == null) {
19  			return null;
20  		}
21  		CivitasBigInteger z = cryptoBase.generateRandomElement(params.q);
22  		return new PETShare(a, b, z);
23  	}
24  }