package main
import (
"fmt"
"math/rand"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Javascript Node CircleCI 2.0 configuration file | |
# | |
# Check https://circleci.com/docs/2.0/language-javascript/ for more details | |
# | |
# | |
version: 2 | |
jobs: | |
build: | |
docker: | |
# specify the version you desire here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ECRECOVER implemented as a native contract. | |
type ecrecover struct{} | |
func (c *ecrecover) RequiredGas(input []byte) uint64 { | |
return params.EcrecoverGas | |
} | |
func (c *ecrecover) Run(input []byte) ([]byte, error) { | |
const ecRecoverInputLength = 128 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EC.prototype.sign = function sign(msg, key, enc, options) { | |
if (typeof enc === 'object') { | |
options = enc; | |
enc = null; | |
} | |
if (!options) | |
options = {}; | |
key = this.keyFromPrivate(key, enc); | |
msg = this._truncateToN(new BN(msg, 16)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For eth_sign, we need to sign arbitrary data: | |
signMessage (withAccount, data) { | |
const wallet = this._getWalletForAccount(withAccount) | |
const message = ethUtil.stripHexPrefix(data) | |
var privKey = wallet.getPrivateKey() | |
var msgSig = ethUtil.ecsign(new Buffer(message, 'hex'), privKey) | |
var rawMsgSig = ethUtil.bufferToHex(sigUtil.concatSig(msgSig.v, msgSig.r, msgSig.s)) | |
return Promise.resolve(rawMsgSig) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getOriginAddress(bytes32 signedMessage, uint8 v, bytes32 r, bytes32 s) constant returns(address) { | |
bytes memory prefix = "\x19Ethereum Signed Message:\n32"; | |
bytes32 prefixedHash = keccak256(prefix, signedMessage); | |
return ecrecover(prefixedHash, v, r, s); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const message = web3.sha3('Hello World'); | |
const signature = await web3.eth.sign(account, message); | |
const { v, r, s } = ethUtil.fromRpcSig(signature); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"compress/gzip" | |
"fmt" | |
"io" | |
"log" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// The new assembly support in Solidity makes writing helpers easy. | |
// Many have complained how complex it is to use `ecrecover`, especially in conjunction | |
// with the `eth_sign` RPC call. Here is a helper, which makes that a matter of a single call. | |
// | |
// Sample input parameters: | |
// (with v=0) | |
// "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad", | |
// "0xaca7da997ad177f040240cdccf6905b71ab16b74434388c3a72f34fd25d6439346b2bac274ff29b48b3ea6e2d04c1336eaceafda3c53ab483fc3ff12fac3ebf200", | |
// "0x0e5cb767cce09a7f3ca594df118aa519be5e2b5a" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"reflect" | |
) | |
type Foo struct { | |
FirstName string `tag_name:"tag 1"` | |
LastName string `tag_name:"tag 2"` |
NewerOlder