public class Handshake
{
    public static final long MAGIC_NUMBER = 20201227;
    public static final int SUBJECT_NUMBER = 7;
    public static final int START_NUMBER = 1;

    public Handshake (boolean debug)
    {
        _debug = debug;
    }
    
    public boolean encryptionKey (int cardPublicKey, int doorPublicKey)
    {
        // fill in the blanks...

        return false;
    }

    private boolean _debug;
}
public class Handshake
{
    public static final long MAGIC_NUMBER = 20201227L;
    public static final long SUBJECT_NUMBER = 7L;
    public static final long START_NUMBER = 1L;

    public Handshake (boolean debug)
    {
        _debug = debug;
    }
    
    public long encryptionKey (long cardPublicKey, long doorPublicKey)
    {
        long count = loopSize(doorPublicKey);
        long curr = START_NUMBER;

        for (int i = 0; i < count; i++)
        {
            curr *= cardPublicKey;
            curr %= MAGIC_NUMBER;
        }

        return curr;
    }

    private long loopSize (long publicKey)
    {
        long curr = START_NUMBER;
        long iter = 0;

        while (value != publicKey)
        {
            curr *= SUBJECT_NUMBER;
            curr %= MAGIC_NUMBER;

            iter++;
        }

        return iter;
    }

    private boolean _debug;
}
Update Handshake.java