nautilus_trader icon indicating copy to clipboard operation
nautilus_trader copied to clipboard

Add support for additional Binance API key types like Ed25519, RSA

Open SimonLeiner opened this issue 1 year ago • 3 comments

Feature Request

Instead of the typical HMAC Keys, Binance also Supports Ed25519 and RSA Keys.

"It is highly recommended to use Ed25519 API keys as it should provide the best performance and security out of all supported key types."

(Definitely not the most urgent enhancement, but a nice feature)

References:

  • https://developers.binance.com/docs/binance-spot-api-docs/faqs/api_key_types

SimonLeiner avatar Jul 02 '24 16:07 SimonLeiner

Hi @SimonLeiner

All of these algorithms still produce strings which can be used just like the typical HMAC keys. Did you experience any blockers to using Nautilus with these other key types?

cjdsellers avatar Jul 05 '24 01:07 cjdsellers

Hey @cjdsellers !

I couldn't make it work with RSA or Ed25519 Keys. I looked a bit into it and in https://github.com/nautechsystems/nautilus_trader/blob/develop/nautilus_trader/adapters/binance/http/client.py

def _get_sign(self, data: str) -> str:
        m = hmac.new(self._secret.encode(), data.encode(), hashlib.sha256)
        return m.hexdigest()

it handles the hmac accordingly. However there is no function that Handles for E.g RSA Keys like

def _rsa_signature(self, query_string: str):
        assert self.PRIVATE_KEY
        h = SHA256.new(query_string.encode("utf-8"))
        signature = pkcs1_15.new(self.PRIVATE_KEY).sign(h)
        return b64encode(signature).decode()

taken from: https://github.com/sammchardy/python-binance/blob/master/binance/client.py

Thanks!

SimonLeiner avatar Jul 05 '24 21:07 SimonLeiner

Hi, can i work on this please?

NextThread avatar Aug 30 '24 18:08 NextThread

Hi @NextThread

Sure thing!

cjdsellers avatar Aug 31 '24 02:08 cjdsellers