, or how one or derived from the other? Thank you.
In order to understand how the addresses are generated, you need to have an insight on how the public keys and private keys are derived based on the elliptic curve algorithm which is being followed in the bitcoin. Every address is generated from the private keys. With a private key you can generate either a legacy address (that starts with 1) or a segregated witness address commonly known as segwit (that starts with 3 or bc1). Some wallets like electrum can generate only addresses which are of legacy type or native segwit or bech32 type.
A public key is generally derived from the private key with a help of one way multiplication function. This means that, you can generate a public key from the private key but you cannot do the other way (i.e a private key cannot be derived from a public key). A private key is a ordinary number which lies in between 1 and 2^256. I am not going deep inside about private keys and their functions, as it would become slightly off-topic and the post would become so lengthy and cumbersome.
A private key is a hexadecimal representation of 256 bit random number. From that hexadecimal number, you generate the public key by doing a multiplication. This multiplication can be represented by
K = k * G
where
G = Constant from the elliptic curve
k = Private Key
K = Public
The constant G is derived from
Elliptic Curve and when you multiply your generated Private Key with the Constant, it will yield a new string of characters known as the public key.
Note that, it is a one way function where only multiplication is possible and dividing Public Key with constant won't yield you the Private Key.
Legacy AddressesOnce you have the Public Key, you can either generate a legacy address or a segwit address. A legacy address is the common address used in the early days and will generate a higher transaction size. With higher transaction sizes, you need to pay higher fees. Here with the generated public key, you will double hash them to get a resulting legacy address.
The public key is first hashed with Sha256 algorithm and the resulting number is hashed with RiPEMD160 algorithm. We can simply write this as,
Address = RIPEMD160[SHA256[PubKey]]]The resulting version of the hash is longer enough, hence they are encoded using Base58 encoding method which brings down the total character to 58.
P2SH AddressesA P2SH is similar to the hashing function, but here we don't hash the public key rather we double hash the script. Addresses that start with 3 are generally called as p2sh rather than calling them as segwit. Segwit removes unwanted witnesses which increases the size of a transaction significantly. By reducing the space, more transactions can be included in a block which certainly helps in scalability of the bitcoin network.
Yep, I surmised as much. What I'd like to know is, how do I see the list of SegWit addresses linked to that legacy address? I'd like to give proof of funds from a 3XXX address rather than a 1XXX address, so I want to figure out how the two are linked.
They are linked together only by private keys. With a single private key, you can either generate a legacy or a segwit address.