{
  public PrivateKey readPrivateKey() throws KeyAgreementException  {    if (in.available() < 4)      {        throw new KeyAgreementException(                                        "not enough bytes for a private key in message");      }    byte[] elementLengthBytes = new byte[4];    in.read(elementLengthBytes, 0, 4);    int elementLength = fourBytesToLength(elementLengthBytes);    if (in.available() < elementLength)      {        throw new KeyAgreementException("illegal private key encoding");      }    byte[] kb = new byte[elementLength];    in.read(kb, 0, elementLength);    // instantiate the right codec and decode    IKeyPairCodec kpc = KeyPairCodecFactory.getInstance(kb);    if (kpc == null)      {        throw new KeyAgreementException(                                        "invalid private key, or encoded with an unknown codec");      }    return kpc.decodePrivateKey(kb);  }