@Test public void encodeBigIntegerEdge_1() { BigInteger integer = new BigInteger("80", 10); byte[] encodedData = encodeBigInteger(integer); System.out.println(Hex.toHexString(encodedData)); }
public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.compareTo(BigInteger.ZERO) < 0) throw new RuntimeException("negative numbers are not allowed"); if (srcBigInteger.equals(BigInteger.ZERO)) return encodeByte((byte) 0); else return encodeElement(asUnsignedByteArray(srcBigInteger)); }
RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.compareTo(BigInteger.ZERO) < 0) throw new RuntimeException("negative numbers are not allowed"); if (srcBigInteger.equals(BigInteger.ZERO)) return encodeByte((byte) 0); else return encodeElement(asUnsignedByteArray(srcBigInteger)); } }
RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.compareTo(BigInteger.ZERO) < 0) throw new RuntimeException("negative numbers are not allowed"); if (srcBigInteger.equals(BigInteger.ZERO)) return encodeByte((byte) 0); else return encodeElement(asUnsignedByteArray(srcBigInteger)); }  }
RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.compareTo(BigInteger.ZERO) < 0) throw new RuntimeException("negative numbers are not allowed"); if (srcBigInteger.equals(BigInteger.ZERO)) return encodeByte((byte) 0); else return encodeElement(asUnsignedByteArray(srcBigInteger)); }  static int decodeInt(byte[] data, int index); static long decodeLong(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeIP4Bytes(byte[] data, int index); static int getFirstListElement(byte[] payload, int pos); static int getNextElementIndex(byte[] payload, int pos); static byte getCommandCode(byte[] data); static RLPList decode2(byte[] msgData, int depthLimit); static RLPList decode2(byte[] msgData); static RLPList unwrapList(byte[] msgData); static RLPElement decode2OneItem(byte[] msgData, int startPos); static DecodeResult decode(byte[] data, int pos); static LList decodeLazyList(byte[] data); static LList decodeLazyList(byte[] data, int pos, int length); static byte[] encode(Object input); static byte[] encodeLength(int length, int offset); static byte[] encodeByte(byte singleByte); static byte[] encodeShort(short singleShort); static byte[] encodeInt(int singleInt); static byte[] encodeString(String srcString); static byte[] encodeBigInteger(BigInteger srcBigInteger); static byte[] encodeElement(byte[] srcData); static int calcElementPrefixSize(byte[] srcData); static byte[] encodeListHeader(int size); static byte[] encodeLongElementHeader(int length); static byte[] encodeSet(Set<ByteArrayWrapper> data); static byte[] wrapList(byte[] ... data); static byte[] encodeList(byte[]... elements); }
RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.compareTo(BigInteger.ZERO) < 0) throw new RuntimeException("negative numbers are not allowed"); if (srcBigInteger.equals(BigInteger.ZERO)) return encodeByte((byte) 0); else return encodeElement(asUnsignedByteArray(srcBigInteger)); }  static int decodeInt(byte[] data, int index); static long decodeLong(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeIP4Bytes(byte[] data, int index); static int getFirstListElement(byte[] payload, int pos); static int getNextElementIndex(byte[] payload, int pos); static byte getCommandCode(byte[] data); static RLPList decode2(byte[] msgData, int depthLimit); static RLPList decode2(byte[] msgData); static RLPList unwrapList(byte[] msgData); static RLPElement decode2OneItem(byte[] msgData, int startPos); static DecodeResult decode(byte[] data, int pos); static LList decodeLazyList(byte[] data); static LList decodeLazyList(byte[] data, int pos, int length); static byte[] encode(Object input); static byte[] encodeLength(int length, int offset); static byte[] encodeByte(byte singleByte); static byte[] encodeShort(short singleShort); static byte[] encodeInt(int singleInt); static byte[] encodeString(String srcString); static byte[] encodeBigInteger(BigInteger srcBigInteger); static byte[] encodeElement(byte[] srcData); static int calcElementPrefixSize(byte[] srcData); static byte[] encodeListHeader(int size); static byte[] encodeLongElementHeader(int length); static byte[] encodeSet(Set<ByteArrayWrapper> data); static byte[] wrapList(byte[] ... data); static byte[] encodeList(byte[]... elements); static final byte[] EMPTY_ELEMENT_RLP; }