<p>I found my answer in this post: <a href="https://bitcoin.stackexchange.com/questions/88526/find-senders-public-key-in-segwit-transaction?rq=1">Find sender&#39;s public key in SegWit Transaction</a></p>
<p>Without witness:</p>
<p>address = base58check( 0x00 + hash160(publicKey) )</p>
<p>With witness:</p>
<p>address = base58check( 0x05 + hash160( 0x00 + 0x14 + hash160(publicKey) ) )</p>
<p>With:</p>
<ul>
<li>&quot;+&quot; operator is concatenation</li>
<li>hash160() is SHA256 + RIPEMD160</li>
<li>publicKey is the second element of the witness (the one I correctly identified in my question above), or the second element of sigscript if no witness</li>
</ul>
<p>Well note that this is not a global rule, but the rule for the transactions I mentioned.</p>

CC BY-SA 4.0
2022-06-22T14:38:32.520Z
2022-06-22T17:41:15.477Z
2022-06-22T17:41:15.477Z
Olivierrt
<p>I am learning how transactions are coded in the blockchain, so I used a python script to compute bitcoin address from public key. This works with the public key:
<code>03416fe9ba17be8fe3f88011923135e83c6a0666fcb575de6ab337c7d6c8f41a5f</code></p>
<p>within the sigscript if this transaction:
<a href="https://www.blockchain.com/btc/tx/56beef8afe5a4b5b41225211e62c3e7bce5747c4c8dcdd982173e8496687794b" rel="nofollow noreferrer">https://www.blockchain.com/btc/tx/56beef8afe5a4b5b41225211e62c3e7bce5747c4c8dcdd982173e8496687794b</a>
I correctly get the corresponding address:</p>
<p><code>15nrxBDLts1tEbowH1dLm5z84RVas7USmP</code></p>
<p>I tried with the same python code to check where is the public key of the first input of this transaction:
<a href="https://www.blockchain.com/btc/tx/01e7c525a5759cde1d04d2e9a363424053ace3ff1d2dde9cd1b368493254bd0d" rel="nofollow noreferrer">https://www.blockchain.com/btc/tx/01e7c525a5759cde1d04d2e9a363424053ace3ff1d2dde9cd1b368493254bd0d</a></p>
<p>I tried to check if I get the address of this input:
<code>34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo</code>
Unfortunately, I didn't manage to end with this address when I use the second field of the witness of this input, which should be the public key of the address I am trying to get (the one starting with 34xp):
<code>02a720e54e39b28434a4c55462718b4584db973331a834141b8cad7e52c317f695</code></p>
<p>SHA256+RIPEMD160+b58encode on this data doesn't correspond to the address above (the one starting with 34xp), and I didn't figured out why, and where is the public key of this address in this transaction input.
Could anyone please give me a clue about it?</p>

<transactions><public-key>
Why this witness doesn't seems to contain a public key?
Olivierrt
# Why this witness doesn't seems to contain a public key?

(Asked by: username_0 on 2022-06-21)

I am learning how transactions are coded in the blockchain, so I used a python script to compute bitcoin address from public key. This works with the public key:
`03416fe9ba17be8fe3f88011923135e83c6a0666fcb575de6ab337c7d6c8f41a5f`

within the sigscript if this transaction:
<https://www.blockchain.com/btc/tx/56beef8afe5a4b5b41225211e62c3e7bce5747c4c8dcdd982173e8496687794b>
I correctly get the corresponding address:

`15nrxBDLts1tEbowH1dLm5z84RVas7USmP`

I tried with the same python code to check where is the public key of the first input of this transaction:
<https://www.blockchain.com/btc/tx/01e7c525a5759cde1d04d2e9a363424053ace3ff1d2dde9cd1b368493254bd0d>

I tried to check if I get the address of this input:
`34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo`
Unfortunately, I didn't manage to end with this address when I use the second field of the witness of this input, which should be the public key of the address I am trying to get (the one starting with 34xp):
`02a720e54e39b28434a4c55462718b4584db973331a834141b8cad7e52c317f695`

SHA256+RIPEMD160+b58encode on this data doesn't correspond to the address above (the one starting with 34xp), and I didn't figured out why, and where is the public key of this address in this transaction input.
Could anyone please give me a clue about it?

**Tags:** transactions, public-key


---

## 1 answers

### Answer by username_0 on 2022-06-22. Score: 2

I found my answer in this post: [Find sender's public key in SegWit Transaction](https://bitcoin.stackexchange.com/questions/88526/find-senders-public-key-in-segwit-transaction?rq=1)

Without witness:

address = base58check( 0x00 + hash160(publicKey) )

With witness:

address = base58check( 0x05 + hash160( 0x00 + 0x14 + hash160(publicKey) ) )

With:

* "+" operator is concatenation
* hash160() is SHA256 + RIPEMD160
* publicKey is the second element of the witness (the one I correctly identified in my question above), or the second element of sigscript if no witness

Well note that this is not a global rule, but the rule for the transactions I mentioned.


---

