<p>Did a bit of digging and in order to extract the private key, you can use:
<code>$privateKey = $key-&gt;getPrivateKey()-&gt;toWif();</code> And then sign the transaction.</p>

CC BY-SA 3.0
2017-12-10T12:09:24.317Z
2017-12-10T12:09:24.317Z
user2298995
<p>I'm generating multiple children using one extended key. I have no problem generating public addresses:</p>

<pre><code>$master = HierarchicalKeyFactory::fromExtended(myKey);
$key = $master-&gt;deriveChild(1);
$publicAddress = $key-&gt;getPublicKey()-&gt;getAddress()-&gt;getAddress();
</code></pre>

<p>In order to sign a transaction, I need the public address' private key. How do I generate / extract the private key of a derived child? I'm assuming I'm not using the extended key for that.</p>

CC BY-SA 4.0
2018-12-05T13:01:26.497Z
Why is getAddress() called twice?
James C.
<bitwasp>
deriveChild and signing transactions using Bit-Wasp
user2298995
# deriveChild and signing transactions using Bit-Wasp

(Asked by: username_0 on 2017-12-10)

I'm generating multiple children using one extended key. I have no problem generating public addresses:
$master = HierarchicalKeyFactory::fromExtended(myKey);
$key = $master->deriveChild(1);
$publicAddress = $key->getPublicKey()->getAddress()->getAddress();

In order to sign a transaction, I need the public address' private key. How do I generate / extract the private key of a derived child? I'm assuming I'm not using the extended key for that.

**Tags:** bitwasp

> **Comments:**
> **username_1**: Why is getAddress() called twice?  

---

## 1 answers

### Answer by username_0 on 2017-12-10. Score: 0

Did a bit of digging and in order to extract the private key, you can use:
`$privateKey = $key->getPrivateKey()->toWif();` And then sign the transaction.


---

