I have generate the Ed25519 Key Pair for API request on Binance.
And here is a Python sample code to show how to sign the payload with an Ed25519 key.
#!/usr/bin/env python3 import base64 import requests import time from cryptography.hazmat.primitives.serialization import load_pem_private_key # Set up authentication API_KEY='put your own API Key here' PRIVATE_KEY_PATH='test-prv-key.pem' # Load the private key. # In this example the key is expected to be stored without encryption, # but we recommend using a strong password for improved security. with open(PRIVATE_KEY_PATH, 'rb') as f: private_key = load_pem_private_key(data=f.read(), password=None) # Set up the request parameters params = { 'symbol': 'BTCUSDT', 'side': 'SELL', 'type': 'LIMIT', 'timeInForce': 'GTC', 'quantity': '1.0000000', 'price': '0.20', } # Timestamp the request timestamp = int(time.time() * 1000) # UNIX timestamp in milliseconds params['timestamp'] = timestamp # Sign the request payload = '&'.join([f'{param}={value}' for param, value in params.items()]) signature = base64.b64encode(private_key.sign(payload.encode('ASCII'))) params['signature'] = signature # Send the request headers = { 'X-MBX-APIKEY': API_KEY, } response = requests.post( 'https://api.binance.com/api/v3/order', headers=headers, data=params, ) print(response.json())
But I don’t know how to play with it in julia, should I use a special library for Ed25519 key? Is there a such library?