View Javadoc
1   package civitas.crypto.decriptionshare;
2   
3   import org.springframework.beans.factory.annotation.Autowired;
4   import org.springframework.stereotype.Controller;
5   
6   import civitas.crypto.ciphertext.ElGamalCiphertext;
7   import civitas.crypto.parameters.ElGamalParameters;
8   import civitas.crypto.proofdisclog.VerifyElGamalProofDiscLogEquality;
9   import civitas.crypto.publickey.ElGamalPublicKey;
10  
11  @Controller
12  public class VerifyElGamalDecryptionShare {
13  
14  	@Autowired
15  	public VerifyElGamalProofDiscLogEquality verifyElGamalProofDiscLogEquality;
16  
17  	public boolean apply(final ElGamalDecryptionShare that, final ElGamalCiphertext c, final ElGamalPublicKey key)
18  			throws Error {
19  		if (c == null) {
20  			throw new IllegalArgumentException("null ciphertext");
21  		}
22  		if (key == null) {
23  			throw new IllegalArgumentException("null key");
24  		}
25  		ElGamalParameters params = key.params;
26  		if (that.proof().g1().equals(c.a)
27  				&& that.proof().g2().equals(params.g)
28  				&& that.proof().v().equals(that.ai())
29  				&& that.proof().w().equals(key.y)) {
30  			return verifyElGamalProofDiscLogEquality.apply(that.proof(), params);
31  		}
32  
33  		return false;
34  	}
35  }