final long now = System.currentTimeMillis();
int modulusLength = getModulusLength(negType);
// Pre negtype 9 we were sending Ni as opposed to Ni'
int nonceSize = getNonceSize(negType);
KeyAgreementSchemeContext ctx = pn.getKeyAgreementSchemeContext();
if(negType < 8) { // Legacy DH
if((ctx == null) || !(ctx instanceof DiffieHellmanLightContext) || ((pn.jfkContextLifetime + DH_GENERATION_INTERVAL*DH_CONTEXT_BUFFER_SIZE) < now)) {
pn.jfkContextLifetime = now;
pn.setKeyAgreementSchemeContext(ctx = getLightDiffieHellmanContext());
}
} else {
if((ctx == null) || !(ctx instanceof ECDHLightContext) || ((pn.jfkContextLifetime + DH_GENERATION_INTERVAL*DH_CONTEXT_BUFFER_SIZE) < now)) {
pn.jfkContextLifetime = now;
pn.setKeyAgreementSchemeContext(ctx = getECDHLightContext());
}
}
int offset = 0;
byte[] nonce = new byte[nonceSize];
byte[] myExponential = ctx.getPublicKeyNetworkFormat();
node.random.nextBytes(nonce);
synchronized (pn) {
pn.jfkNoncesSent.add(nonce);
if(pn.jfkNoncesSent.size() > MAX_NONCES_PER_PEER)