What are the (high-level) steps to, firstly, create a substrate address from a private key and secondly, to create a m-of-n multisig address?
A description similar to this image would be just about my level ;)
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.
Sign up to join this communityThe Substrate address is actually derived from the public key:
For most networks, the public key associated with an account is how that account is identified on the network and is used as the destination address for transactions. However, Substrate-based chains use the underlying public key to derive one or more public addresses. Instead of using the public key directly, Substrate allows you to generate multiple addresses and address formats for an account.
In Substrate-based networks, the sr25519 encoded keys are used to produce SS58 addresses as the public keys for interacting with the blockchain.
Additionally, Substrate has a multi-format address wrapper for on-chain accounts:
pub enum MultiAddress<AccountId, AccountIndex> {
/// It's an account ID (pubkey).
Id(AccountId),
/// It's an account index.
Index(#[codec(compact)] AccountIndex),
/// It's some arbitrary raw bytes.
Raw(Vec<u8>),
/// It's a 32 byte representation.
Address32([u8; 32]),
/// Its a 20 byte representation.
Address20([u8; 20]),
}
You can see this gives support to 20 bytes, 32 bytes, arbitrary raw bytes, and you could even have a simple custom index number to represent the address.
Substrate is highly configurable and supports a number of different signature schemes e.g. ed25519 (Edwards), sr25519 (schnorrkel), ecdsa (non-Bitcoin compatible), and it is not limited to these.
To see the process of generating keys in Substrate:
More info can be found here:
As far as how a multisig address is generated, I recommend looking at this code here: