aionnetwork / aion_web3

Aion flavoured Web3 Javascript API
GNU General Public License v3.0
35 stars 30 forks source link

how to get v r s from signatures? #61

Open sultana-mnw opened 5 years ago

sultana-mnw commented 5 years ago

Description: I have follow the web3 methods in this link ( https://github.com/aionnetwork/aion_web3/wiki/web3-eth-accounts ) to get signature and v r s but i only get signature not v r s.

Web3 version: 1.0.3

Command(s) triggering the issue: web3.eth.accounts.sign(message,privatekey);

API output:

{ message: '0x2c80807145a8a3688266c415da8a02b30ae8864180dbf23a4a43c63369a1a82d', messageHash: '0x3ca080ec9581ed002b1a43216c211aab4a7093927f6f60ab29ab4ed4ed38db44', signature: '0x140b7b7027473c964344bb7837c13ee1650d5b8a1faae1ca14fe630d784586a7e85a90b2bb2a88f1ee699ae7b3b6471b99565d1b56d9fc0e49295493118f7eeb49f8ba3d115bc2f697ddaf1ecd5ab44db1a60f1fc57a6a07c3d41d84703e9302' }

aion-kelvin commented 5 years ago

Hi,

That is a mistake in the documentation... the signature is given not as (r, s), but simply as one hex string. We will update our docs.

sultana-mnw commented 5 years ago

Hello, Ok. But how could I get that (v r s) from that signature.

aion-kelvin commented 5 years ago

(v, r, s) is given by Ethereum's signing scheme. We use a different scheme (Ed25519 instead of ECDSA), which does not have (v, r, s). May I ask what how/why you want (v, r, s)?

Edit: typo in sig scheme name

sultana-mnw commented 5 years ago

Hello, For some specific task to validate the signature in contract using ecrecover keyword. For that i need a ( v r s )So how could i do that? Is it any other methods to validate signature in contract for aion.

Regards Sultana

On Thu, 29 Nov 2018, 9:27 pm aion-kelvin, notifications@github.com wrote:

(v, r, s) is given by Ethereum's signing scheme. We use a different scheme (EC25519 instead of ECDSA), which does not have (v, r, s). May I ask what how/why you want (v, r, s)?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aionnetwork/aion_web3/issues/61#issuecomment-442886455, or mute the thread https://github.com/notifications/unsubscribe-auth/Ai1eUUi3jibM3bcKZfs1q4D2pEV8MEVyks5u0APjgaJpZM4Y22-G .

aion-kelvin commented 5 years ago

Are you signing/recovering transactions? Or arbitrary messages?

sultana-mnw commented 5 years ago

Am signing the transaction and also orbitary messages.

On Thu, 29 Nov 2018, 9:55 pm aion-kelvin, notifications@github.com wrote:

Are you signing/recovering transactions? Or arbitrary messages?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aionnetwork/aion_web3/issues/61#issuecomment-442898029, or mute the thread https://github.com/notifications/unsubscribe-auth/Ai1eUQjGA1zYOC17r8rQySdcykM3SBX5ks5u0AqVgaJpZM4Y22-G .

aion-kelvin commented 5 years ago

web3.eth.accounts.recover can be used to recover the address of signatures created by web3.eth.accounts.sign. Unfortunately, we do not support recovering the address of signed transactions right now.

API References: https://docs.aion.network/docs/web3-eth-accounts#section-sign https://docs.aion.network/docs/web3-eth-accounts#section-recover

(Don't use web3.eth.accounts.recover to recover a signature created by eth.accounts.~sign~signTransaction, as it will not give the correct result)

edit: fixed typo (see strikethrough above)