<p>A raw private key is not on the elliptic curve, so there will be no ECPoint.  It is a random number as described <a href="https://bitcoin.stackexchange.com/a/79142/71151">here</a>.</p>

CC BY-SA 4.0
2018-10-25T01:09:27.400Z
2018-10-25T01:09:27.400Z
bryan
<p>How to create a bouncy castle ECPoint from a raw private key hex string?  I am getting a private key using the 'dumpprivkey' RPC and removing the header byte and the 4 bytes of checksum + 1 byte of discriminator trailer bytes, resulting in a 32 byte raw key LIKE this example (this sample comes from <a href="https://en.bitcoin.it/wiki/Private_key" rel="nofollow noreferrer">here</a>).  It causes the following exception.  Decoding public keys this way does not have this problem.</p>

<p>This is the code:</p>

<pre><code>public static void main(String[] args) {
    String priv_key = "E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67FC233AA33262"; 
    BigInteger value = new BigInteger(priv_key, 16);
    ECCurve BITCOIN_CURVE = new SecP256K1Curve();
    ECPoint point = BITCOIN_CURVE.decodePoint(value.toByteArray());
}
</code></pre>

<p>But it results in this exception:</p>

<pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Incorrect length for infinity encoding
    at org.bouncycastle.math.ec.ECCurve.decodePoint(Unknown Source)
    at Btc.main(Btc.java:19)
</code></pre>

<private-key><java>
How to create ECPoint from raw private key
bryan
# How to create ECPoint from raw private key

(Asked by: username_0 on 2018-10-25)

How to create a bouncy castle ECPoint from a raw private key hex string?  I am getting a private key using the 'dumpprivkey' RPC and removing the header byte and the 4 bytes of checksum + 1 byte of discriminator trailer bytes, resulting in a 32 byte raw key LIKE this example (this sample comes from here).  It causes the following exception.  Decoding public keys this way does not have this problem.
This is the code:
public static void main(String[] args) {
    String priv_key = "E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67FC233AA33262"; 
    BigInteger value = new BigInteger(priv_key, 16);
    ECCurve BITCOIN_CURVE = new SecP256K1Curve();
    ECPoint point = BITCOIN_CURVE.decodePoint(value.toByteArray());
}

But it results in this exception:
Exception in thread "main" java.lang.IllegalArgumentException: Incorrect length for infinity encoding
    at org.bouncycastle.math.ec.ECCurve.decodePoint(Unknown Source)
    at Btc.main(Btc.java:19)

**Tags:** private-key, java


---

## 1 answers

### Answer by username_0 on 2018-10-25. Score: 1

A raw private key is not on the elliptic curve, so there will be no ECPoint. It is a random number as described [here](https://bitcoin.stackexchange.com/a/79142/71151).


---

