1

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 ;)

BTC address generation flowchart

1 Answer 1

3

The 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:

  1. https://polkadot.js.org/docs/util-crypto/examples/create-multisig
  2. https://github.com/polkadot-js/build-deno.land/blob/ac5fab607364eda37099f2d08ec1bb5ecc75402d/util-crypto/address/keyMulti.ts#L15-L24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.