1

I'm working on the Swift library for Substrate networks and can't understand how AccountId should work for ECDSA.

In Polkadot/Kusama, metadata returns AccountId as AccountId32 - 32-byte array.

This 32-byte array is serialized and used in calls like system_accountNextIndex, which allows us to fetch the next index for extrinsic.

In Polkadot and Kusama, Signature is the MultiSignature enum, which can be created with an ECDSA signature.

But for ECDSA public key, AccountId will be AccountId33, one byte bigger.

So in case, I want to use ECDSA keypair with Polkadot/Kusama, how can I obtain AccountId, which then can be used to get the next index in the network?

Am I'm missing something?

1

1 Answer 1

1

For ECDSA in Substrate you will get a 32 byte Account:

Self::Ecdsa(who) => sp_io::hashing::blake2_256(who.as_ref()).into()

If you want to replicate this outside of Substrate you can hash the 33 byte Ecdsa public key with blake2_256 which will return a 32 byte hash.

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.