2

Here I provide a snippet of the output generated by ethereum-bridge on startup:

[2017-10-13T07:25:55.920Z] INFO deploying the oraclize connector contract...
[2017-10-13T07:26:16.357Z] INFO connector deployed to: 0x3ae9795a5c4ef9f803d56437163b3abd39649525
[2017-10-13T07:26:16.482Z] INFO deploying the address resolver with a deterministic address...
[2017-10-13T07:26:47.730Z] INFO address resolver (OAR) deployed to: 0x6f485c8bf6fc43ea212e93bbf8ce046c7f1cb475

Indeed, the address of the OAR contract is always 0x6f485c8bf6fc43ea212e93bbf8ce046c7f1cb475, but as the contract's address is determined by hashing the sender's account + nonce, how can Oraclize (ethereum-bridge) always deploy to the same address?

1

The trick is very simple, they use the same account and only with nonce = 0. From their github repo

// used only to deploy a deterministic address resolver (OAR) (contract address = sha3(rlp.encode([normalize_address(sender), nonce]))[12:])
const OAR_ONLY_PRIV_KEY = Buffer.from('79a98ade62c92444178d73409fbce37a360b36a2483dda666d26270c8a50f5c7', 'hex')
const OAR_ONLY_ADDRESS = '0x935A0F8F4B8752C61f00D1f67b67685665ff8Cf6'

In the same file bridge-account.js they have the following functions

BridgeAccount.prototype.getTempAddress = function () {
  return OAR_ONLY_ADDRESS
}

BridgeAccount.prototype.getTempPrivKey = function () {
  return OAR_ONLY_PRIV_KEY
}

In the function deployOAR in bridge-core.js they have the following

BridgeTxManager().sendRawTx({
    'from': self.account, 
    'data': oraclizeAddressResolverBin, 
    'gas': 324702, 
    '$temporary_account': true}, function (err, contract) {

The important part is '$temporary_account': true

Now looking at sendRawTx in bridge-tx-manager.js we have

BlockchainInterface().inter.sendRawTransaction(
    this.buildLocalTx(txData), function (err, hash) {

In buildLocalTx we have

var broadcastAccount = this.account
var broadcastPrivateKey = this.privateKey()
if (typeof txData['$temporary_account'] !== 'undefined' && txData['$temporary_account'] === true) {
  broadcastAccount = BridgeAccount().getTempAddress()
  broadcastPrivateKey = BridgeAccount().getTempPrivKey()
}

When the parameter $temporary_account is set to true it will use the hardcoded values in bridge-account.

  • But how do they get their account? And how do they send from it? – Shuzheng Oct 16 '17 at 6:10
  • What is the OAR_ONLY_PRIVATE_KEY used for? – Shuzheng Oct 16 '17 at 6:18
  • @Shuzheng I've added how the values are used to generate the deterministic address. Now you have to convince yourself that all other possible configurations will not generate a deterministic address, or better check for yourself. – Ismael Oct 16 '17 at 9:31
  • Using a chosen private key, can one generate a public key? In other words, for each private (or public) key, there exists only one public (private) key? Of course it must be hard to generate the private key from the public key, but the other direction is easy? – Shuzheng Oct 16 '17 at 9:52
  • @Shuzheng That is a different matter, you should create a new question for it. I think you are right but I don't know enough about elliptic curves to answer trustfully. – Ismael Oct 16 '17 at 18:13

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.