3

I have been trying to to implement a FIX Client in Go to interact with FTX. To send the initial logon message, FTX's API doc asks the client to include a signature in the message.

In the return message from the FTX, it says "Invalid signature".

Below is my implementation for generating the signature:

func signatureGenerator(msgType, msgSeqNum, senderCompID, targetCompID string) string {

    timeNow := time.Now().UTC().Format("20060102-15:04:05")

    message := [][]byte{[]byte(timeNow),
                        []byte(msgType),
                        []byte(msgSeqNum), 
                        []byte(senderCompID),
                        []byte(targetCompID)}
    SOH := []byte{0x01}
    signature := bytes.Join(message, SOH)

    signSha256 := hmac.New(sha256.New, []byte(userInfo.CLIENT_API_SECRET))
    signSha256.Write(signature)

    strSig := hex.EncodeToString(signSha256.Sum(nil))
    return strSig
}
Christoph John
  • 3,003
  • 2
  • 13
  • 23
Harry G
  • 31
  • 1
  • Does the result of your function match the result of the sample code in the documentation? You will need to stub out the current time to compare. It's possible that the code in the question is correct, but the code that constructs the overall message is incorrect. – Charlie Tumahai Oct 17 '21 at 21:45
  • Did you check the official Golang code for signing a request? https://github.com/ftexchange/ftx/blob/228dfd4e57e22e4c7b96b063094d40217209309e/go/ftx/ftx/authentication.go – Orian Zinger Mar 24 '22 at 06:45

0 Answers0