~ /code /parameters
Code · Public parameters

Parameters.java

Store and expose the public Diffie–Hellman parameters used by all participants.

27 linesq · αsuperclass of KeyExchange

Role in the system#

A small value class for the two public parameters. KeyExchange extends it, and Main uses its toString() to print them.

Source#

Parameters.java
import java.math.BigInteger;

public class Parameters {

    private BigInteger q;
    private BigInteger alpha;

    public Parameters(BigInteger q, BigInteger alpha) {
        this.q = q;
        this.alpha = alpha;
    }

    public BigInteger getQ() {
        return q;
    }

    public BigInteger getAlpha() {
        return alpha;
    }

    @Override
    public String toString() {
        return "Public Parameters:\n" +
               "Prime number (q): " + q + "\n" +
               "Primitive root (alpha): " + alpha;
    }
}