0

I have a js client, web API

Js client send some data in JSON format, API prepare a transaction to be send to a smart contract, than it returns transaction raw to client to be signed locally,

and finally the client sign the transaction (using crypto) and post it again to API which send it to blockchain.

So how to sign transaction with standart crypto library (client will not use web3) ?
Sequence diagram

  • You might have to define "standard crypto library". (What libraries would meet that definition, and why is web3.js not one of them? Would copy/pasting code from web3.js be acceptable? If not, why specifically?) – smarx Mar 7 at 12:14
  • I meant something general, because client isnot supposed to have an idea about web3, so I need a way to make him sign a transaction as any crypto sign using elliptic curve – maroodb Mar 7 at 14:27
  • I am asking if it faisable to implement this or not, I am not looking for an implementation – maroodb Mar 7 at 14:34
  • Yes, this is feasible. – smarx Mar 7 at 16:05
1

The main point, I think, is that you have to use the right elliptic curve for Ethereum. That is secp256k1. I'm not sure they have implemented other curves yet, although there was talk of supporting Curve25519 (see here)

You could also take a look at this post and this for a tutorial on signatures in Solidity.

The other thing you have to be careful about is the format of the signature. If you use Zeppelin to verify, it will expect the plain message to be prefixed with this string: "\x19Ethereum Signed Message:\n", where \x19 is actually the length of the prefix (25 characters).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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