handshake-org / handshake-org/hsd
Pay To Pubkey? Bare Pubkeys in Addresses
- Dominant language
- JavaScript
- Stars
- 2.1k
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
There are remnants of pay to pubkey in the codebase.
See here on the `Script` object:
https://github.com/handshake-org/hsd/blob/cc1ef7ab8dfcadbcc1b18b934ccf2d2ec1776042/lib/script/script.js#L1368-L1383
Looking at the code right before the VM execution, an address can be 32 bytes (p2sh) or 20 bytes (p2pkh). Anything else will fail validation.
https://github.com/handshake-org/hsd/blob/4b04d9a2f9094b9c4c8e17346e7f24517f0a0336/lib/script/script.js#L2300-L2315
This means that the only way to do pay to pubkey is by wrapping it in p2sh which makes me feel like its just left over from bcoin. If pay to pubkey was truly supported, there would be a check here for `address.hash.length === 33`. This would be the bare pubkey in the address "hash" (data) field.
Pieter Wuille thinks that it is safe to put a bare pubkey in the address instead of the pubkey hash. I think that this could result in more interesting cryptographic schemes being developed since sharing an address will be the same as sharing a public key. It would make key aggregation easier, proof of reserves easier and stealth addresses easier.
Leaving standard p2pkh would decrease the anonymity set of users using p2pk and it would be a decent amount of work to change everything.
Contributor guide
Assessment
This issue has not been assessed yet.