Create signature for TRADE using ed25519

In rest api I’m using ed25519 encryption to create the signature but I get “Signature for this request is not valid”.

This is the code:

import * as fs from "fs";
import crypto from "crypto";
import axios from "axios";

const BASE_ENDPOINT = "https://api.binance.com/api";
const API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
const PRIVATE_KEY = fs.readFileSync("./../private_key.pem", "utf-8");
const TIMESTAMP = Date.now();
const PARAMS = {
  symbol: "BTCUSDT",
  side: "buy",
  type: "LIMIT",
  quantity: 0.1,
  price: 26000,
  timestamp: TIMESTAMP,
};
const SIGNATURE = crypto.sign(null, Buffer.from(JSON.stringify(PARAMS)), {
  key: PRIVATE_KEY,
  padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
  saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
}).toString("base64");
const DATA = new URLSearchParams({ ...PARAMS, signature: SIGNATURE });
const RESPONSE = await axios({
  url: `/v3/order/test`,
  method: "post",
  baseURL: BASE_ENDPOINT,
  data: DATA,
  headers: {
    "X-MBX-APIKEY": API_KEY,
  }
});

The way we handle the ed25519 type of key in our node.js connector can be seen here:

It might help you understand where the issue is in your code example.