Ejemplo n.º 1
0
  @Override
  public void parse(byte[] data) {
    RLPList list = (RLPList) RLP.decode2OneItem(data, 0);

    this.token = list.get(0).getRLPData();
    RLPItem expires = (RLPItem) list.get(1);
    this.expires = ByteUtil.byteArrayToLong(expires.getRLPData());
  }
  static AuthResponseMessageV4 decode(byte[] wire) {

    AuthResponseMessageV4 message = new AuthResponseMessageV4();

    RLPList params = (RLPList) RLP.decode2OneItem(wire, 0);

    byte[] pubKeyBytes = params.get(0).getRLPData();

    byte[] bytes = new byte[65];
    System.arraycopy(pubKeyBytes, 0, bytes, 1, 64);
    bytes[0] = 0x04; // uncompressed
    message.ephemeralPublicKey = ECKey.CURVE.getCurve().decodePoint(bytes);

    message.nonce = params.get(1).getRLPData();

    byte[] versionBytes = params.get(2).getRLPData();
    message.version = ByteUtil.byteArrayToInt(versionBytes);

    return message;
  }