I generated the secretKey and publicKey using the steps in https://polkadot.js.org/docs/keyring/start/create/.
After I get the secretKey and publicKey, I want to sign a tx using only the secretKey. How do I do that?
I have tried to use keyring, but what is the addFrom...
method that I use for secretKey? I have tried using the addFromSeed
, but it produces error Bad seed size
This is the gist of the code I use
import { Keyring } from '@polkadot/api'
import {
mnemonicGenerate,
mnemonicToMiniSecret,
ed25519PairFromSeed,
} from '@polkadot/util-crypto'
async function main() {
// Create mnemonic string for Alice using BIP39
const mnemonicAlice = mnemonicGenerate()
// Create valid Substrate-compatible seed from mnemonic
const seedAlice = mnemonicToMiniSecret(mnemonicAlice)
// Generate new public/secret keypair for Alice from the supplied seed
const { publicKey, secretKey } = ed25519PairFromSeed(seedAlice)
const keyring = new Keyring()
const pair = keyring.addFromSeed(secretKey, { name: 'first pair' }, 'ed25519') // this results in error
}
main()