user54847: I am trying to generate SegWit paper wallet address from WIF:
My WIF is L5mHKZsCLS27nSoGM3RdAwuxjvg7XhJdP25LgqdXe6zF11wpWdbT.
I am converting WIF to compressed public key:
Compressed public key: 03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb
I am creating P2SH-P2WPKH address using instructions at Creation of P2SH-P2WPKH Address
using following algorithm:

Calculate the RIPEMD160 of the SHA256 of a public key:

SHA256 of public key: cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9
RIPEMD160 of SHA256 hash: d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d

Create P2SH redeemScript as OP_PUSH publicKeyHash:

redeemScript: 0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d

Generate scriptPubKey as OP_HASH160 hash160(redeemScript) OP_EQUAL

scriptPubKey: a914a19949e546c2f4d410cbb061c986b9ff3099ae7087

Generate RIPEMD160 hash of scriptPubKey:

hash: dc62e525af22d1f0f17cc2a091cf2c9fb36bf553

Generate address with 0x05 prefix and double SHA256 hash checksum:

result: 3MnK46gvixm8hk7mJTQTAqenniSodjXPrJ
Expected result according to segwitaddress is:
33voQqbNAYyig272KjcX8GkucWn2x25WEg
What am I doing wrong?
Update
Thanks to the accepted answer, here are correct steps to do this:
Public key - compressed: 
03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb

SHA256(public key) =
cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9

RIPEMD160(SHA256(public key)) =
7646c030f7e75b80f0a31cdcab731e6f424f22b2

redeemScript (OP_0 pubkeyHash160):
00147646c030f7e75b80f0a31cdcab731e6f424f22b2

SHA256(redeemScript) =
a10e523968ba784d24ccd54e613d8f747d6649e42b1df4fdcec6658262620651

RIPEMD160(SHA256(redeemScript)) =
188ba16284702258959d8bb63bb9a5d979b57875

P2SH address base58(0x05 | hash | 4-byte sha256 checksum) =
33voQqbNAYyig272KjcX8GkucWn2x25WEg


user48884: 

Create P2SH redeemScript as OP_PUSH publicKeyHash:

redeemScript: 0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d

It's actually `OP_0  but you have resulted in the right thing anyways.


Generate scriptPubKey as OP_HASH160 hash160(redeemScript) OP_EQUAL

scriptPubKey: a914a19949e546c2f4d410cbb061c986b9ff3099ae7087

Generate RIPEMD160 hash of scriptPubKey:

hash: dc62e525af22d1f0f17cc2a091cf2c9fb36bf553

These steps are incorrect. The thing that is hashed for a P2SH address is the redeemScript, not the scriptPubKey. Instead of doing step 3, you would skip directly to step 4 and hash the redeemScript instead of the scriptPubKey.

54847: <p>I am trying to generate SegWit paper wallet address from WIF:</p>

<p>My WIF is <code>L5mHKZsCLS27nSoGM3RdAwuxjvg7XhJdP25LgqdXe6zF11wpWdbT</code>.</p>

<p>I am converting WIF to compressed public key:</p>

<p>Compressed public key: <code>03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb</code></p>

<p>I am creating P2SH-P2WPKH address using instructions at <a href="https://bitcoincore.org/en/segwit_wallet_dev/" rel="noreferrer">Creation of P2SH-P2WPKH Address</a></p>

<p>using following algorithm:</p>

<ol>
<li>Calculate the RIPEMD160 of the SHA256 of a public key:</li>
</ol>

<p>SHA256 of public key: <code>cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9</code></p>

<p>RIPEMD160 of SHA256 hash: <code>d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d</code></p>

<ol start="2">
<li>Create P2SH redeemScript as <code>OP_PUSH publicKeyHash</code>:</li>
</ol>

<p>redeemScript: <code>0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d</code></p>

<ol start="3">
<li>Generate scriptPubKey as <code>OP_HASH160 hash160(redeemScript) OP_EQUAL</code></li>
</ol>

<p>scriptPubKey: <code>a914a19949e546c2f4d410cbb061c986b9ff3099ae7087</code></p>

<ol start="4">
<li>Generate RIPEMD160 hash of scriptPubKey:</li>
</ol>

<p>hash: <code>dc62e525af22d1f0f17cc2a091cf2c9fb36bf553</code></p>

<ol start="5">
<li>Generate address with <code>0x05</code> prefix and double SHA256 hash checksum:</li>
</ol>

<p>result: <code>3MnK46gvixm8hk7mJTQTAqenniSodjXPrJ</code></p>

<p>Expected result according to <a href="https://segwitaddress.org" rel="noreferrer">segwitaddress</a> is:</p>

<p><code>33voQqbNAYyig272KjcX8GkucWn2x25WEg</code></p>

<p>What am I doing wrong?</p>

<p><strong>Update</strong></p>

<p>Thanks to the accepted answer, here are correct steps to do this:</p>

<pre><code>Public key - compressed: 
03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb

SHA256(public key) =
cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9

RIPEMD160(SHA256(public key)) =
7646c030f7e75b80f0a31cdcab731e6f424f22b2

redeemScript (OP_0 pubkeyHash160):
00147646c030f7e75b80f0a31cdcab731e6f424f22b2

SHA256(redeemScript) =
a10e523968ba784d24ccd54e613d8f747d6649e42b1df4fdcec6658262620651

RIPEMD160(SHA256(redeemScript)) =
188ba16284702258959d8bb63bb9a5d979b57875

P2SH address base58(0x05 | hash | 4-byte sha256 checksum) =
33voQqbNAYyig272KjcX8GkucWn2x25WEg
</code></pre>
 48884: <blockquote>
  <ol start="2">
  <li>Create P2SH redeemScript as <code>OP_PUSH publicKeyHash</code>:</li>
  </ol>
  
  <p>redeemScript: <code>0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d</code></p>
</blockquote>

<p>It's actually `OP_0  but you have resulted in the right thing anyways.</p>

<blockquote>
  <ol start="3">
  <li>Generate scriptPubKey as <code>OP_HASH160 hash160(redeemScript) OP_EQUAL</code></li>
  </ol>
  
  <p>scriptPubKey: <code>a914a19949e546c2f4d410cbb061c986b9ff3099ae7087</code></p>
  
  <ol start="4">
  <li>Generate RIPEMD160 hash of scriptPubKey:</li>
  </ol>
  
  <p>hash: <code>dc62e525af22d1f0f17cc2a091cf2c9fb36bf553</code></p>
</blockquote>

<p>These steps are incorrect. The thing that is hashed for a P2SH address is the redeemScript, not the scriptPubKey. Instead of doing step 3, you would skip directly to step 4 and hash the redeemScript instead of the scriptPubKey.</p>
