Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated dht_store method signatures #63

Open
ghost opened this issue Aug 26, 2015 · 2 comments
Open

updated dht_store method signatures #63

ghost opened this issue Aug 26, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 26, 2015

The patch has changed to use a different interface, but gittorrent depends against that branch directly, not a specific commit.

Now you've got to pass in a sign function: https://github.com/substack/bittorrent-dht/blob/dht-store/test/dht_store_mutable.js#L22 https://github.com/substack/bittorrent-dht/blob/dht-store/test/dht_store_mutable.js#L459
and pass in a verify function to the DHT constructor https://github.com/substack/bittorrent-dht/blob/dht-store/test/dht_store_mutable.js#L12

Using ed25519-supercop the signatures should finally be compatible with normal bittorrent clients.

@cjb
Copy link
Owner

cjb commented Aug 28, 2015

@substack Thanks, I'll take a look. I'm using ed25519 via the elliptic module, which provides utility functions such as creating a keypair object from text:

  var key = JSON.parse(fs.readFileSync(config.key).toString())
  return ed25519.keyPair({
    priv: key.priv,
    privEnc: 'hex',
    pub: key.pub,
    pubEnc: 'hex'
  })

Is that possible with ed25519-supercop too?

@ghost
Copy link
Author

ghost commented Aug 28, 2015

Instead of a keypair object, you get the buffers directly that you can pass to signing functions:

generate.js:

var ed = require('ed25519-supercop')
var kp = ed.createKeyPair(ed.createSeed())
console.log(JSON.stringify({
  secretKey: kp.secretKey.toString('hex'),
  publicKey: kp.publicKey.toString('hex')
}))

sign.js:

var ed = require('../')
var path = require('path')
var concat = require('concat-stream')
var kp = require(path.resolve(process.argv[2]))

process.stdin.pipe(concat(function (body) {
  var sig = ed.sign(body, kp.publicKey, kp.secretKey)
  console.log(sig.toString('hex'))
}))
$ node generate.js > keys.json
$ echo wow | node sign.js keys.json
d5b606ace3228afe5fbd63b03ce2f569999f32557b0c7cf5cad43195a43022d043de10c349c9dd7ba41f3ec1be6f205af629135566c711f933dce5937b677b0c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant