2017-08-24 25 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())); 
} 

确保你的时间是正确的,因为请求与时间敏感的签名签署。