nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
2.02k stars 463 forks source link

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

Closed SimonLeiner closed 2 weeks ago

SimonLeiner commented 3 months ago

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:

cjdsellers commented 3 months ago

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?

SimonLeiner commented 2 months ago

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!

NextThread commented 1 month ago

Hi, can i work on this please?

cjdsellers commented 1 month ago

Hi @NextThread

Sure thing!