Open MicrowaveDev opened 5 years ago
var RSA = require("seededrsa"); const cryptoKeys = require('libp2p-crypto/src/keys') const PeerId = require('peer-id') var pem2jwk = require('pem-jwk').pem2jwk const fromJwk = cryptoKeys.supportedKeys.rsa.fromJwk; function rsaToPeerID(key, callback) { fromJwk(pem2jwk(key.privateKey()), function(err, priv) { if(err) { callback(err) } else { PeerId.createFromPrivKey(cryptoKeys.marshalPrivateKey(priv), function(err, peerid) { if(err) { callback(err); } else { callback(null, peerid.toJSON()); } }) } }) } var phrase = 'praise you muffin lion enable neck grocery crumble super myself license ghost' var rsa = new RSA(phrase); rsa.generate(2048); console.log("private", rsa.privateKey()) console.log("public", rsa.publicKey()) rsaToPeerID(rsa, function(err, peerid) { console.log("peerid", peerid) }) /* private -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQB/fhIBfKuQa003rOXNK+HbIqlegfGYRWepNmDTIbQ2wEdpaJ0i TyksL7yYyLvTUvmLUnyJgvZgf1GwF1UD0274NfJgExeCmv5F93SC8XJcvSE9VJTf fliszefAgJuoCYaCZiFeZAaYJbiYXvj1W1gj58HAY8OPD1QrqiI+hl3WXvlWkRqo oKMJb0PolCGdufBIwR9iW4rv662WmTk4IBi9x40ydRBB+3LMiwLgLr0ErDoOrWna AGAF2euohD4PQ1MYfw7GSgIUmLBIHxSGFDOmewytIo5MIeBbKDdjFOhTrqSlyYfN wXwa0ZrnjYCe+6oQugFLdqCLMCL2v2mmiNYjAgMGVTcCggEAUyzm8+/yCWgU7ySf 15nGq3xeQ2V5m7OhQDk8LFtbxaJikhYrUm0oYxaBLKkefMqVfTQpSOU5pSARC7tS WeVZYaErfMq11ECbvHMCTt/uhJSQ4b8U6zQBZatCjivfaljQu0qNFrdHtS2l76eQ TcA+ibe9EsekfnUP5nuLUQ3Myx31YmaEqjhXmWM96K817Qefofout98bgE2EmhIW Em6D7Q/TpUeGH2iUig24BFF9LcT4cWbA/EQwlh23R0TySsQsQerO3FilEysV3hFT Mym9P7DBPZsw8r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6gJhoJmIV5kBpgluJhe+PVbWCPnwcBjw48PVCuqIj6GXdZe+VaRGqigowlvQ+iUIZ258EjBH2Jbiu/rrZaZOTggGL3HjTJ1EEH7csyLAuAuvQSsOg6tadoAYAXZ66iEPg9DUxh/DsZKAhSYsEgfFIYUM6Z7DK0ijkwh4FsoN2MU6FOupKXJh83BfBrRmueNgJ77qhC6AUt2oIswIva/aaaI1iMCAwZVNw==' } (env) */
https://github.com/nomadcrypto/seededrsa
Could you elaborate a bit on this?
https://github.com/nomadcrypto/seededrsa