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 = "";
const API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxx';
const PRIVATE_KEY = fs.readFileSync("./../private_key.pem", "utf-8");
const TIMESTAMP =;
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)), {
  padding: crypto.constants.RSA_PKCS1_PSS_PADDING,
  saltLength: crypto.constants.RSA_PSS_SALTLEN_DIGEST
const DATA = new URLSearchParams({ ...PARAMS, signature: SIGNATURE });
const RESPONSE = await axios({
  url: `/v3/order/test`,
  method: "post",
  data: DATA,
  headers: {

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.