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

Provide keypairs using the same type that the ucans library supports #62

Open
matheus23 opened this issue Nov 2, 2021 · 3 comments
Open

Comments

@matheus23
Copy link
Member

Previous discussion: ucan-wg/ts-ucan#2

If we want to be able to use the ucans library in webnative, we should provide keypair types as discussed in the issue above. The type is:

export interface Keypair {
  publicKey: Uint8Array
  keyType: KeyType
  sign: (msg: Uint8Array) => Promise<Uint8Array>
}

export type KeyType = 'rsa' | 'ed25519' | 'bls12-381'
@nichoth
Copy link

nichoth commented Mar 31, 2022

I wanted to let people know that I have made a patch to keystore-idb that includes support for ed25519 keypairs that are compatible with the ucans library. There is a method getKeypair -- https://github.com/nichoth/keystore-idb/blob/UCAN-compat-keypair/src/ecc/keystore.ts#L116 -- that returns a UCAN style keypair object.

The tests for compatibility are using a different test framework -- https://github.com/nichoth/keystore-idb/blob/UCAN-compat-keypair/package.json#L56 -- which is why I'm not submitting it as a PR. That script browserifies the test code and runs it in electron, so there is a browser environment for localforage.

Also there is an error logged during TS compilation, because I have only created the getKeypair method on ed25519 keys so far, not RSA, because supporting other key algorithms is not an immediate need for me.

The good news is that it doesn't add any dependencies in this module.

@nichoth
Copy link

nichoth commented Apr 1, 2022

A little update -- in order to install this as a dependency I noticed that the typescript has to compile without error. So I fixed the RSA typescript error that showed up during compilation, so now I'm able to use this forked repo as a dependency. I'm not sure if RSA actually works though; there are no tests for it. But typescript does compile.

@nichoth
Copy link

nichoth commented Apr 3, 2022

Another update -- this was totally broken the way I had implemented it here. I noticed that via more tests that compared the DID values from my version with the ucan.publicKeyBytesToDid method.

In the interest of progressing toward the end goal I've put this on the back burner so to speak, and I just added ucans as a dependency:

https://github.com/nichoth/keystore-idb/blob/b37912da698d8695166be7adf242ddda766a5a05/src/ecc/keystore.ts#L137

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