It's the same b58check(HASH160)
, but you're hashing a script.
The script for 1-to-1 multisig P2SH addresses is OP_0 hash160(pubkey)
.
So your address would be b58check(hash160('\x00\x14' + hash160(pubkey)))
.
Long story short:
1) WIF to pubkey:
secret = b58check_decode(WIF)
pubkey = ECKey(secret).pubkey
2) pubkey to P2PKH (legacy address):
addrtype = 0
addr = b58check(addrtype, hash160(pubkey))
3) pubkey to P2SH (1-to-1 multisig address):
addrtype = 5
addr = b58check(addrtype, hash160('\x00\x14' + hash160(pubkey)))
where hash160(x) = ripemd160(sha256(x))
That's, basically, it. Also see https://github.com/joric/pywallet/issues/1
Regarding 32-byte secret to WIF conversion - bitcoin core doesn't tell apart different WIF's it's just b58check(secret) type 0x80. Importprivkey command generates 3 different addresses - P2PKH, P2SH and BECH32 from the same secret, and you can reexport-reimport the secret anytime.