api icon indicating copy to clipboard operation
api copied to clipboard

signRaw problem

Open gith-u-b opened this issue 2 years ago • 1 comments

  server.post<{ Body: { message: string, signature: string, address: string } }>("/worker/signMessage", async (request, reply) => {
    const keyring = new Keyring({ type: 'sr25519' });
    const alice = keyring.addFromUri('//Bob', { name: 'Alice default' });
    console.log(`${alice.meta.name}: has address ${alice.address} with publicKey [${alice.publicKey}]`);
    const message = stringToHex('I\'m verifying my DOT address');
    const signature = alice.sign(message);
    return { signature: u8aToHex(signature) }
  });
const injector = await web3FromSource(targetDotAddress.meta.source)
      const signRaw = injector?.signer?.signRaw
      const { signature } = await signRaw({
        address: targetDotAddress.address,
        data: stringToHex('I\'m verifying my DOT address'),
        type: 'bytes'
 })

hi, what's the difference between this(1) and that(2)? I want to get the result of the first, in the second way

or polkadot api interface curl example

thanks.

gith-u-b avatar Sep 06 '22 07:09 gith-u-b

From a brief look, they should be equivalent. (Obviously sr25519 signatures are non-deterministic and will differ on each run, so you cannot compare the outputs)

jacogr avatar Sep 06 '22 08:09 jacogr

This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.

polkadot-js-bot avatar Sep 27 '22 11:09 polkadot-js-bot

Closing.

jacogr avatar Oct 04 '22 05:10 jacogr

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue if you think you have a related problem or query.

polkadot-js-bot avatar Oct 11 '22 05:10 polkadot-js-bot