Signing Method
Overview
This document outlines the API specification for signing parameters using the RSA "SHA256withRSA" algorithm. The key length for RSA is set to 2048 bits. Before utilizing RSA, merchants are required to generate their RSA public key through the Merchant Control Panel at http://merchant.airswift.io/ → Global Card → Merchant Key.
RSA Algorithm Rules
The following rules should be followed when signing parameters using RSA. Please note that all parameters submitted by merchants, except for the "sign" field, must be signed.
- Remove any empty strings or null values from the parameters.
- Sort the parameters in ascending order based on the field name.
- Concatenate the sorted field values (excluding the field names) to form a string.
- Use the RSA private key to sign the resulting string.
Example
Let's illustrate the process with a sample request data:
jsonCopy code{
"basicsType": "1",
"amount": "0.02",
"clientOrderSn": "1455242522111217",
"appKey": "197ku7dv-fa3e-18da-2pd3-1j28f22f6cfa",
"nonce": "421427",
"tradeType": "0",
"coinUnit": "USDT",
"remarks": "test",
"timestamp": "1658909065813",
}
Step 1: Sort the keys in ascending alphabetical order, eliminating any null strings or values, and subsequently concatenate the corresponding values:
- Sort all keys ascending alphabetical order, here is the result sample:
['amount', 'appKey', 'basicsType', 'clientOrderSn', 'coinUnit', 'nonce', 'remarks', 'timestamp', 'tradeType']
- Map the sorted keys and corresponding values
amount - 0.02
appKey - 197ku7dv-fa3e-18da-2pd3-1j28f22f6cfa
basicsType - 1
clientOrderSn - 1455242522111217
coinUnit - USDT
nonce - 421427
remarks - test
timestamp - 1658909065813
tradeType - 0
- Concatenate the values:
0.02197ku7dv-fa3e-18da-2pd3-1j28f22f6cfa114552425221112170USDT421427test16589090658130
Step 2: Then employ the RSA private key to sign the sorted string using the 'SHA256withRSA' algorithm, thereby generating the resulting signature string:
W3p/pDbtlpmg0wgJkUj8Wfw7TSilO5p9q9299WPjG0Ew2gMW5lnsSzncf8abWZgwtMZTgOB+TOBNpmSP1nDbfZfvBA0KBQy+OrfjWqCdCLCy+VaQGdNmj5TZFm2FSM1NDjwYFmfNKhcm3csOffp/iUYlr1yDBB24JIMTJ5Q9NkqfGFHfvxzR+3upZJ7RhqVwo8SFBPVyDSwa7meKMibhcEHIvlTIZ/yDHV0SSDp6+720lB63CK7fX6OIXEUaOkYSRWXcZh+Fj9EqrUcbCYKZKrBY0Rg5kTTRCIo5QH6BeqBgROjfZ2EYqQWWpsKhcgXA/0Y4bHOlCEIlUjG+y6UnBQ==
Please note that this is just a sample to demonstrate the process. Actual implementation may vary based on your specific requirements.