【问题标题】:Gdax-node b64secretGdax-node b64secret
【发布时间】:2017-08-24 13:20:40
【问题描述】:

由于https://github.com/coinbase/gdax-node#the-authenticated-api-client

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 提供的字符串吗?我应该生成它吗?

我承认对密码学了解不多。

感谢您的帮助或有用的链接。

【问题讨论】:

  • "b64" 大概只是代表base64,一种将二进制数据(例如加密密钥)编码为可打印 ASCII 字符的算法。我猜 GDAX 密码是用 base64 编码的,以便于复制和粘贴到您的代码中。

标签: authentication cryptography gdax-api


【解决方案1】:

来自GDAX Authentication:

在签署任何请求之前,您必须通过 GDAX 网站创建一个 API 密钥。 ... 创建密钥后,您将获得 3 条信息...:

密钥
秘密
密码

Key和Secret将由GDAX随机生成并提供;您将提供密码以进一步保护您的 API 访问。 GDAX 存储密码的加盐哈希以供验证……

秘密是b64secret 变量值。

【讨论】:

    【解决方案2】:

    您的 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()));
     }
    

    确保您的时间正确,因为请求使用时间敏感签名进行签名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多