vechain / vechain-sdk-js

The official JavaScript SDK for VeChain.
24 stars 9 forks source link

💡 [REQUEST] - Ability to sign transactions and messages using KMS #1295

Closed victhorbi closed 3 weeks ago

victhorbi commented 1 month ago

Summary

Current status is that to use KMS you should pass the private key to the SDK making KMS useless.

Basic Example

I would like to give to KMS the message to sign, get it back signed, and send it using the VeChain-SDK

Description

victhorbi commented 1 month ago

from Miguel:

I think we should be able to have something like this but in our project => https://besu.hyperledger.org/private-networks/reference/plugin-api-interfaces (see SecurityModuleService, it allows you to implement your own signer as part of a plugin - since it is java, a jar)
maybe nowadays by extending the VeChainAbstractSigner  [https://github.com/vechain/vechain-sdk-js/blob/2e927619f137d311585d7d065c7bac7b4a0[…]gner/signers/vechain-abstract-signer/vechain-abstract-signer.ts](https://github.com/vechain/vechain-sdk-js/blob/2e927619f137d311585d7d065c7bac7b4a0479df/packages/network/src/signer/signers/vechain-abstract-signer/vechain-abstract-signer.ts) we could have a working version for KMS
victhorbi commented 1 month ago

@freemanzMrojo the solution was found and there's the working feature in evearn code. @odaidayoub1994 was working on the same task of making it a signer for the SDK. Please, @freemanzMrojo, can you take it from where it is now?

cc @Valazan

freemanzMrojo commented 1 month ago

@victhorbi I already implemented what is there + in the current format it cannot be shipped as part of the SDK since it is using several independent components rather than the current abstract classes. I am also refactoring some staff that is not exactly as it should be, like getSignatureHash here when it is not the signature but the transaction body what is being hashed.

I think we could finalise what I am doing so users could get the same without the need of using independent components (like the calculation of addresses which requires a hashing operation of the public key to obtain the recovery ID).

It wont have breaking changes for evearn other than the renaming of some of the methods. Or the other way around, I can implement in evearn this refactor.

victhorbi commented 1 month ago

Thanks @freemanzMrojo, I agree. Will ask Odai to stop working on this as well.

freemanzMrojo commented 1 month ago

Created this issue since it looks like we cannot import custom material using localstack and SECP256k1 (hopefully I am wrong): https://github.com/localstack/localstack/issues/11678