2017-08-24 69 views
1

由於https://github.com/coinbase/gdax-node#the-authenticated-api-clientGdax節點b64secret

const key = 'your_api_key'; 
const b64secret = 'your_b64_secret'; 
const passphrase = 'your_passphrase'; 

const apiURI = 'https://api.gdax.com'; 
const sandboxURI = 'https://api-public.sandbox.gdax.com'; 

const authedClient = new Gdax.AuthenticatedClient(key, b64secret, passphrase, apiURI); 

什麼是b64secret?我在哪裏/如何得到它? gdax提供了字符串嗎?我應該生成它嗎?

我可以承認對密碼學知之甚少。

謝謝你的幫助或有用的鏈接。

+0

「b64」大概只代表[base64](https://en.wikipedia.org/wiki/Base64),一種用於將二進制數據(如加密密鑰)編碼爲可打印的ASCII字符的算法。我猜想GDAX的祕密是用base64編碼的,以便於複製和粘貼到你的代碼中。 –

回答

3

GDAX Authentication

,然後才能簽署任何要求,你必須創建通過GDAX網站的API密鑰。 ......在創建的關鍵,你將有3條信息...:

主要
祕密
口令

重點和祕密將GDAX隨機生成和提供;密碼將由您提供,以進一步保護您的API訪問權限。 GDAX存儲您的密碼的鹽漬散列以進行驗證...

該祕密是b64secret變量值。

0

你的b64祕訣就是你的祕密。對於它的價值...

您可以使用gdax-java庫來做到這一點(或其他語言中的任何變體已經從gdax API文檔中編寫和引用)。

如果你在寫自己的實現意圖,這裏是你可以用它來簽名郵件的方法:

private String signMessage(String timestamp, String method, String path) throws NoSuchAlgorithmException, InvalidKeyException { 
     String prehash = timestamp + method + path; 

     Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); 
     byte[] secretDecoded = Base64.getDecoder().decode(secret); 
     SecretKeySpec secret_key = new SecretKeySpec(secretDecoded, "HmacSHA256"); 
     sha256_HMAC.init(secret_key); 

     return Base64.getEncoder().encodeToString(sha256_HMAC.doFinal(prehash.getBytes())); 
} 

確保你的時間是正確的,因爲請求與時間敏感的簽名簽署。