See the Keys derivation section for more information about the algorithm that is used in mnemonic_derive_sign_keys.
Key pair generation without mnemonic
Sometimes there is no need for mnemonic.
For example, if you generate a key pair for a server that does not need a readable form. Then you can easily generate such a pair with generate_random_sign_keys function:
const simpleKeys = await client.crypto.generate_random_sign_keys();
console.log(`key pair not from mnemonic:`);
console.log(simpleKeys);
Result:
key pair not from mnemonic:
{
public: 'de996e3004e2bc73b47e8a4fce665847194e2245ddbfc30d9ec2014913249f50',
secret: 'a761156ff1ad497d4d52a32e32720cc3ef8b0d7c259f6d91b9f236d6288e12a3'
}
Great! Now you can use this key pair in methods of contracts module, such as abi.encode_message, abi.encode_message_body, etc.
Keys derivation
Master (root) key
To derive a key within a specified path, first, you need to generate a seed from the given mnemonic and then get the extended master private key that will be the root for all the derived keys.
Both these operations can be performed with hdkey_xprv_from_mnemonic method: