/** * Creates and returns the payload to send to the other participant during round 1. * <p> * After execution, the {@link #getState() state} will be {@link #STATE_ROUND_1_CREATED}. */ public JPAKERound1Payload createRound1PayloadToSend() { if (this.state >= STATE_ROUND_1_CREATED) { throw new IllegalStateException("Round1 payload already created for " + participantId); } this.x1 = JPAKEUtil.generateX1(q, random); this.x2 = JPAKEUtil.generateX2(q, random); this.gx1 = JPAKEUtil.calculateGx(p, g, x1); this.gx2 = JPAKEUtil.calculateGx(p, g, x2); BigInteger[] knowledgeProofForX1 = JPAKEUtil.calculateZeroKnowledgeProof(p, q, g, gx1, x1, participantId, digest, random); BigInteger[] knowledgeProofForX2 = JPAKEUtil.calculateZeroKnowledgeProof(p, q, g, gx2, x2, participantId, digest, random); this.state = STATE_ROUND_1_CREATED; return new JPAKERound1Payload(participantId, gx1, gx2, knowledgeProofForX1, knowledgeProofForX2); }
/** * Creates and returns the payload to send to the other participant during round 1. * <p> * After execution, the {@link #getState() state} will be {@link #STATE_ROUND_1_CREATED}. */ public JPAKERound1Payload createRound1PayloadToSend() { if (this.state >= STATE_ROUND_1_CREATED) { throw new IllegalStateException("Round1 payload already created for " + participantId); } this.x1 = JPAKEUtil.generateX1(q, random); this.x2 = JPAKEUtil.generateX2(q, random); this.gx1 = JPAKEUtil.calculateGx(p, g, x1); this.gx2 = JPAKEUtil.calculateGx(p, g, x2); BigInteger[] knowledgeProofForX1 = JPAKEUtil.calculateZeroKnowledgeProof(p, q, g, gx1, x1, participantId, digest, random); BigInteger[] knowledgeProofForX2 = JPAKEUtil.calculateZeroKnowledgeProof(p, q, g, gx2, x2, participantId, digest, random); this.state = STATE_ROUND_1_CREATED; return new JPAKERound1Payload(participantId, gx1, gx2, knowledgeProofForX1, knowledgeProofForX2); }
/** * 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); }