Also missed this one, oops, hopefully you've figured out a solution for what you're trying to do. I don't think there was a reason to exclude returning the key in generation.
I have a vague recollection that there might have been some weird behavior in what the keyring was returning for public keys and it just bubbled up this way by not returning the key. It would be great if you have found a solution to submit it as a pull request. If you haven't you should also take a look at the devel branch https://github.com/openpgpjs/openpgpjs/tree/devel which has a slightly different front-facing API for things like this. On Wed, May 15, 2013 at 8:51 AM, emma sculateur <[email protected]>wrote: > Hi Sean, > > Thanks for answering. > There would be a way to map a private key to a public key using the keys > IDs if *openpgp.generateKeyPair(...)* returned {*privateKey: > [openpgp_msg_privatekey],* > *privateKeyArmored: [string],* > *publicKey: [openpgp_msg_privatekey], > * > *publicKeyArmored: [string]}* > * > * > Thus, when I generate my key pair, I can store a couple of key IDs, and I > know which public key goes with which private key. > var myKeyPair = generate_key_pair(1, 2048, userId); > var myObj = { > privKeyId: myKeyPair.privateKey.getKeyId(), > pubKeyId: myKeyPair.publicKey.getKeyId(), > ... > } > chrome.storageArea.set(myObj,function(){...}); > > Unfortunately, at the moment *openpgp.generateKeyPair(...)* returns only > {*privateKey: [openpgp_msg_privatekey],* > *privateKeyArmored: [string],* > *publicKeyArmored: [string]}* > > Would it be possible ? Or is there a good reason for generateKeyPair not > returning the public key ? > > Regards > > > 2013/5/13 Sean Colyer <[email protected]> > >> Yes, this could be an issue. >> >> If you knew what id you wanted to use you could call >> the getPublicKeysForKeyId()/getPrivateKeyForKeyId() functions. Looking up >> by address is pretty common in most openpgp.js implementations, because we >> don't know the key ID we're looking for but do know the email address. >> >> Sean >> >> >> On Sun, May 12, 2013 at 12:13 PM, emma sculateur >> <[email protected]>wrote: >> >>> Hi all, >>> >>> First of all, thanks for openpgpjs :) >>> >>> I have a question : >>> >>> If [email protected] generates a 2 or more key pairs. I can get the keys >>> with : >>> var privateKeys = getPrivateKeyForAddress([email protected]); >>> var publicKeys = getPublicKeyForAddress([email protected]); >>> >>> But am I sure sur privateKeys[i] is associated with publicKeys[i] ? >>> How do you handle the cases where there are several pair associated to >>> the same email address ? >>> >>> Thank you in advance. >>> >>> _______________________________________________ >>> >>> http://openpgpjs.org >>> >>> >> >> _______________________________________________ >> >> http://openpgpjs.org >> >> > > _______________________________________________ > > http://openpgpjs.org > >
_______________________________________________ http://openpgpjs.org

