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

methodFor helper function no longer accessing public / private key pair #63

Open
wip-abramson opened this issue Jul 18, 2023 · 3 comments

Comments

@wip-abramson
Copy link

Previously when I used this library the methodFor function would act as a

convenience function that returns the public/private key pair instance for a given purpose (authentication, assertionMethod, keyAgreement, etc). - See current code comment here

It no longer appears to do this.

Is there now a different way to use this library to get the requisite private keys (with id and controller) required for the vc.js library?

@dmitrizagidulin
Copy link
Contributor

@wip-abramson Can you say more about "it no longer appears to do this"? Looking at the current code, it's still returning the keypair (this line here https://github.com/digitalbazaar/did-method-key/blob/main/lib/DidKeyDriver.js#L70C7-L70C36 )

What behavior are you encountering? (Give us reproduce steps.)

@wip-abramson
Copy link
Author

Apologies. I did misread the code, although i still am not getting expected results.

Here is my code

const didKeyDriver2018 = driver();

didKeyDriver2018.use({
  multibaseMultikeyHeader: 'z6Mk',
  fromMultibase: createFromMultibase(Ed25519VerificationKey2018)
});

const edKeyPair = await Ed25519VerificationKey2018.generate();
const {didDocument, keyPairs, methodFor} = await didKeyDriver2018.fromKeyPair({
  verificationKeyPair: edKeyPair
});

let methodKeyPair = methodFor({purpose: 'authentication', privateKey:true});
console.log("method privkey", methodKeyPair.privateKeyBase58); // is null
console.log("keypair privkey", edKeyPair.privateKeyBase58); // is a private key

Probably I am just doing something wrong.

@dmitrizagidulin
Copy link
Contributor

@wip-abramson Thanks. Yeah, this seems to be a bug in the newer code.
The _keyPairToDidDocument method here only converts the public key, but not the private key.

/cc @davidlehn

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

2 participants