/** * Creates and returns the payload to send to the other participant during round 2. * <p> * {@link #validateRound1PayloadReceived(JPAKERound1Payload)} must be called prior to this method. * <p> * After execution, the {@link #getState() state} will be {@link #STATE_ROUND_2_CREATED}. * * @throws IllegalStateException if called prior to {@link #validateRound1PayloadReceived(JPAKERound1Payload)}, or multiple times */ public JPAKERound2Payload createRound2PayloadToSend() { if (this.state >= STATE_ROUND_2_CREATED) { throw new IllegalStateException("Round2 payload already created for " + this.participantId); } if (this.state < STATE_ROUND_1_VALIDATED) { throw new IllegalStateException("Round1 payload must be validated prior to creating Round2 payload for " + this.participantId); } BigInteger gA = JPAKEUtil.calculateGA(p, gx1, gx3, gx4); BigInteger s = JPAKEUtil.calculateS(password); BigInteger x2s = JPAKEUtil.calculateX2s(q, x2, s); BigInteger A = JPAKEUtil.calculateA(p, q, gA, x2s); BigInteger[] knowledgeProofForX2s = JPAKEUtil.calculateZeroKnowledgeProof(p, q, gA, A, x2s, participantId, digest, random); this.state = STATE_ROUND_2_CREATED; return new JPAKERound2Payload(participantId, A, knowledgeProofForX2s); }
/** * Creates and returns the payload to send to the other participant during round 2. * <p> * {@link #validateRound1PayloadReceived(JPAKERound1Payload)} must be called prior to this method. * <p> * After execution, the {@link #getState() state} will be {@link #STATE_ROUND_2_CREATED}. * * @throws IllegalStateException if called prior to {@link #validateRound1PayloadReceived(JPAKERound1Payload)}, or multiple times */ public JPAKERound2Payload createRound2PayloadToSend() { if (this.state >= STATE_ROUND_2_CREATED) { throw new IllegalStateException("Round2 payload already created for " + this.participantId); } if (this.state < STATE_ROUND_1_VALIDATED) { throw new IllegalStateException("Round1 payload must be validated prior to creating Round2 payload for " + this.participantId); } BigInteger gA = JPAKEUtil.calculateGA(p, gx1, gx3, gx4); BigInteger s = JPAKEUtil.calculateS(password); BigInteger x2s = JPAKEUtil.calculateX2s(q, x2, s); BigInteger A = JPAKEUtil.calculateA(p, q, gA, x2s); BigInteger[] knowledgeProofForX2s = JPAKEUtil.calculateZeroKnowledgeProof(p, q, gA, A, x2s, participantId, digest, random); this.state = STATE_ROUND_2_CREATED; return new JPAKERound2Payload(participantId, A, knowledgeProofForX2s); }