Sure ethereum signature is 65, but secp256k1 is 64
RangeError: signature length is invalid Web3 = require("web3") var web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546'); const secp256k1 = require('secp256k1') // or require('secp256k1/elliptic') // if you want to use pure js implementation in node //ethereum test https://github.com/ethereum/go-ethereum/blob/461291882edce0ac4a28f64c4e8725b7f57cbeae/crypto/signature_test.go msg = web3.utils.hexToBytes("0xd301ce462d3e639518f482c7f03821fec1e602018630ce621e1e7851c12343a6") signature = web3.utils.hexToBytes("0x638a54215d80a6713c8d523a6adc4e6e73652d859103a36b700851cb0e61b66b8ebfc1a610c57d732ec6e0a8f06a9a7a28df5051ece514702ff9cdff0b11f454") pubkey = web3.utils.hexToBytes("0x03ca634cae0d49acb401d8a4c6b6fe8c55b70d115bf400769cc1400f3258cd3138") console.log(secp256k1.verify(msg, signature, pubKey))
呼叫web3的部份,都需要使用ethereum geth,這部份有點麻煩
Call web3 must use ethereum, this mean need to run ganache or geth. No ok.
jsrsasign is offline to compute
ECDSA 相關的是 https://kjur.github.io/jsrsasign/sample/sample-ecdsa.html
=====
https://medium.com/@angellopozo/ethereum-signing-and-validating-13a2d7cb0ee3
https://dzone.com/articles/signing-and-verifying-ethereum-signatures
public address 只是 verify後拿來驗證是否相同
另一句話 verify後會產生public address,主要是拿sign後的值產生 r s v ,然後再用 合約的功能 ecrecover 處理
public address only for after verify product check
Other way to explain is
After verify get public address. Take signatures to make r s v, then use r s v with contract ecrecover().
https://github.com/miguelmota/ethereum-development-with-go-book
https://goethereumbook.org/zh/
https://github.com/gobitfly/etherchain-light
https://github.com/gobitfly/erc20-explorer
https://github.com/carsenk/explorer
https://github.com/Capgemini-AIE/ethereum-docker/tree/master/monitored-geth-client
https://github.com/cubedro/eth-net-intelligence-api
https://github.com/cubedro/eth-netstats
Browse blocks and transactions
It’s nice to have some simple analogue of Etherscan for your local chain browsing. It will be useful to examine transactions, balances, blocks and etc. It appeared that it is quite difficult to find an open-source good solution for geth. After several tries I found an acceptable solution called ETHExplorer V2. Clone it into explorer-v2 folder. To Dockerize it I had to make 2 changes.
https://github.com/ethereum/go-ethereum/issues/18405
That’s generally fine. The way clique works is that the in-turn sealer who should ideally sign next tries to sign and propagate the block immediately when the timer ticks. If no in-turn block appears within 500ms, the other signers start potentially creating alternative blocks (with random delays), this ensures that even if a signer is missing, the chain progresses more or less properly.
Now, if the original in-turn signer does come around and publish its block with some delay, that might reorg out alternative blocks signer by out-of-turn signers.
Use keythereum, web3
npm install keythereum npm install web3 .datadir need to correct.
UTC/keystore/UTC–2019-03-25T09-10-35.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.address need correct “0xooooooooooooooooooooooooo”
.password need correct, this example is empty.
.web3 localhost is fake, don’t need have geth.
var keythereum = require("keythereum"); var datadir = "UTC"; var address= "0xooooooooooooooooooooooooo"; const password = ""; var keyObject = keythereum.importFromFile(address, datadir); var privateKey = keythereum.recover(password, keyObject); console.log(privateKey.toString('hex')); Web3 = require('web3') web3 = new Web3(new Web3.providers.HttpProvider("localhost")); var address = web3.
https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html#example
https://github.com/ethereum/solidity/blob/develop/Changelog.md