polkadot-developers / substrate-developer-hub.github.io

Substrate Documentation
https://substrate-developer-hub.github.io
Apache License 2.0
135 stars 209 forks source link

Create docs for substrate address format #90

Closed joepetrowski closed 5 years ago

joepetrowski commented 5 years ago

Related to deprecation of the wiki. Need up to date docs on address format. https://github.com/paritytech/wiki/pull/335

Old:


title: External Address Format (SS58)

SS58 is a simple address format designed for Substrate based chains. There's no problem with using other address formats for a chain, but this serves as a robust default. It is heavily based on Bitcoin's Base-58-check format with a few alterations.

The basic idea is a base-58 encoded value which can identify a specific account on the Substrate chain. Different chains have different means of identifying accounts. SS58 is designed to be extensible for this reason.

Basic Format

The basic format conforms to:

base58encode ( concat ( <address-type>, <address>, <checksum> ) )   

That is, the concatenated byte series of address type, address and checksum then passed into a base-58 encoder. The base58encode function is exactly as defined in Bitcoin and IPFS, using the same alphabet as both.

Address Type

The <address-type> is one or more bytes that describe the precise format of the following bytes.

Currently, there exist four valid values:

JoshOrndorff commented 5 years ago

When this doc is written, we should link to it from the subkey writeup.

- Address (aka **Public Address**) - An SS58-encoded address based on the public key.
+ Address (aka **Public Address**) - An [SS58-encoded](link here) address based on the public key.

@joepetrowski Are the docs you pasted above known to be incorrect? Any pointers on where I can confirm for myself and update them?

joepetrowski commented 5 years ago

Are the docs you pasted above known to be incorrect?

No, but they are quite old so I wouldn't trust them.

JoshOrndorff commented 5 years ago

Looks like a good place to jump in https://github.com/paritytech/substrate/blob/cf4a28a7e707190c44e73451e9da38de6bb160ec/core/primitives/src/crypto.rs#L235

JoshOrndorff commented 5 years ago

Most of the changes from what's written above seem to have happened in https://github.com/paritytech/substrate/pull/1795

JoshOrndorff commented 5 years ago

I've made a draft in #108

JoshOrndorff commented 5 years ago

Seems we should revert to the original article after discussion in riot today

JoshOrndorff commented 5 years ago

Here's a new PR https://github.com/substrate-developer-hub/substrate-developer-hub.github.io/pull/144

JoshOrndorff commented 5 years ago

So here's my question after thinking about this issue for a few days now. Under what circumstances would someone use an address format other than the sr25519 or ed25519 ones that I had written up?

When I wrote my first version, I thought I was answering the question: Given an sr25519 or ed25519 raw public key, how can I calculate the same SS58 address that subkey or Apps gives me?

What is the actual question that I should have been answering?

joepetrowski commented 5 years ago

If this is an address for holding tokens then I don't know of other curves from which one would derive an address. GRANDPA validators use a BLS18-381 key to sign commit messages though so they would be identifiable by their key, although this wouldn't hold funds.