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

Add support for Bls12381G2 keys in kms-local #894

Open
pcibraro opened this issue May 24, 2022 · 5 comments
Open

Add support for Bls12381G2 keys in kms-local #894

pcibraro opened this issue May 24, 2022 · 5 comments
Labels
enhancement New feature or request pinned don't close this just for being stale

Comments

@pcibraro
Copy link

The kms-local implementation only supports a fixed set of key types. It is not possible to extend the current implementation as it is today to include a new key type like 'Bls12381G2'.

The asManagedKeyInfoInner method where the key types are checked is private. If you derive the base class to add new key types, you basically need to copy/clone that private method for supporting the existing key types (Ed25519, Secp256k1 and X25519) + new ones (Bls12381G2). Also that method expects 'RequireOnly<ManagedPrivateKey, 'privateKeyHex' | 'type'>)' as input. That assumes the public key can actually be derived from the private key all the time. I haven't found any implementation for Bls12381G2 keys that derive the public key from the private one, so I was expecting to also pass the public key as optional if it can not be derived.

This is for generating a new DID key for Bls12381G2 keys.

I've implemented something that works, but as I said, it is not ideal as I had to duplicate code from your implementation.

https://github.com/pcibraro/veramo/blob/next/packages/kms-bbs/src/key-management-system.ts

@pcibraro pcibraro added the enhancement New feature or request label May 24, 2022
@mirceanis
Copy link
Member

Perhaps we can use this to generate public keys from private: https://github.com/paulmillr/noble-bls12-381#getpublickeyprivatekey

@mirceanis
Copy link
Member

ah, no, that library uses G1 for public keys and G2 for signatures

@mirceanis
Copy link
Member

see my other comment about KMS too: #895 (comment)

@mirceanis mirceanis added the pinned don't close this just for being stale label Jun 3, 2022
@pcibraro
Copy link
Author

@mirceanis I came up with a simple implementation that works fine server-side for issuing VCs signed with BLS key in case you want to take a look. There are some workarounds commented out in the code.

https://github.com/pcibraro/veramo-bls-issuer

@mirceanis
Copy link
Member

relates to #605

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned don't close this just for being stale
Projects
None yet
Development

No branches or pull requests

2 participants