You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! The readme specifically mentions that sodium signatures will not work with BEP44, however I've done some research for my rendezvous-point module and this is not true. ed25519-supercop is based on ref10 and so is sodium. The difference is in the private key encoding, but one can convert to supercop keys if need be: https://github.com/emilbayes/sodium2supercop
However, the secret key is not exposed or used beyond generating signatures and as such any implementation can be used, as long as they generate valid EdDSA signatures. I'm happy to make amends to the readme, I just want to make sure to what extent :) I have a verification script here if anyone is interested: https://gist.github.com/emilbayes/66c955cc49da387ee2ab9c3a76aa9238
The examples would look something like the following, using @mafintosh high-level sodium-signatures module. Straight up sodium-native/sodium-universal could also be used with a bit more boilerplate:
vareddsa=require('sodium-signatures')varkeypair=eddsa.keyPair()varvalue=Buffer.alloc(200).fill('whatever')// the payload you want to sendvaropts={k: keypair.publicKey,seq: 0,v: value,sign: function(buf){returneddsa.sign(buf,keypair.secretKey)}}varDHT=require('bittorrent-dht')vardht=newDHTdht.put(opts,function(err,hash){console.error('error=',err)console.log('hash=',hash)})
The text was updated successfully, but these errors were encountered:
constsodium=require('sodium-native')constDHT=require('bittorrent-dht')constdht=newDHT({verify: sodium.crypto_sign_verify_detached})constkeys=keygen()dht.put({v: Buffer.from('Hello world'),k: keys.pk,seq: 0,sign: (msg)=>{constsig=Buffer.alloc(sodium.crypto_sign_BYTES)sodium.crypto_sign_detached(sig,msg,keys.sk)returnsig}},function(err,hash){// ...})// Optionally pass an exisiting secret key and rederive the public keyfunctionkeygen(sk){constpk=Buffer.alloc(sodium.crypto_sign_PUBLICKEYBYTES)if(sk==null){sk=sodium.sodium_malloc(sodium.crypto_sign_SECRETKEYBYTES)sodium.crypto_sign_keypair(pk,sk)}else{sodium.crypto_sign_ed25519_sk_to_pk(pk,sk)}return{ pk, sk }}
One note is that the BEP44 test vectors cannot be implemented due to how private keys are encoded differently. In sodium private keys are a bytearray of publickey || random seed while the test vectors (and supercop) encode private keys as sha512(random seed). Since you cannot get back the original seed (preimage) of the hash function, the two private key formats are incompatible.
Hi! The readme specifically mentions that sodium signatures will not work with BEP44, however I've done some research for my
rendezvous-point
module and this is not true. ed25519-supercop is based onref10
and so is sodium. The difference is in the private key encoding, but one can convert to supercop keys if need be: https://github.com/emilbayes/sodium2supercopHowever, the secret key is not exposed or used beyond generating signatures and as such any implementation can be used, as long as they generate valid EdDSA signatures. I'm happy to make amends to the readme, I just want to make sure to what extent :) I have a verification script here if anyone is interested: https://gist.github.com/emilbayes/66c955cc49da387ee2ab9c3a76aa9238
The examples would look something like the following, using @mafintosh high-level
sodium-signatures
module. Straight upsodium-native
/sodium-universal
could also be used with a bit more boilerplate:The text was updated successfully, but these errors were encountered: