-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Coinbase SDK v1.31.0: Docs Typo and Key Parsing Issues for CDP_WALLET_SECRET and CDP_API_KEY_SECRET
Summary
The Coinbase Developer Platform documentation (https://docs.cdp.coinbase.com/server-wallets/v2/introduction/quickstart) contains a critical typo stating that CDP_WALLET_SECRET should be a "base64 Ed25519 key," but cdp-sdk v1.31.0 requires a base64 DER EC key (approximately 184 characters, ~138 bytes decoded). Additionally, CDP_API_KEY_SECRET fails with valid PEM EC keys, requiring a base64 DER EC key instead. These issues cause parsing errors, leading to significant debugging time for developers.
Details
-
Docs Typo for
CDP_WALLET_SECRET:- The quickstart guide specifies that
CDP_WALLET_SECRETshould be a "base64 Ed25519 key" (e.g., 44 chars, 32 bytes decoded, generated viapynacl). - However,
cdp-sdkv1.31.0’sgenerate_wallet_jwtfunction (cdp/auth/utils/jwt.py:244) usesserialization.load_der_private_keywithalgorithm='ES256', which only supports EC keys in base64 DER format (or PEM-wrapped EC keys). - Using an Ed25519 key results in errors like
ValueError: Could not create the EC key: Incorrect paddingorASN.1 parsing error: invalid length. - The portal’s 184-char EC key (e.g., starting with
MIGHAg...) works correctly when used asCDP_WALLET_SECRET.
- The quickstart guide specifies that
-
Parsing Issue for
CDP_API_KEY_SECRET:- The SDK’s
generate_jwtfunction (cdp/auth/utils/jwt.py:171) rejects valid PEM EC keys forCDP_API_KEY_SECRET, throwingValueError: Key must be either PEM EC key or base64 Ed25519 key. - Using the base64 DER EC key (stripped of PEM headers, e.g.,
MHcCAQEE...) resolves the issue, indicating a parsing bug or undocumented requirement.
- The SDK’s
Steps to Reproduce
For CDP_WALLET_SECRET:
- Set
CDP_WALLET_SECRETto a base64 Ed25519 key (e.g., generated viapynacl:WcJafZ9O+cVAXpTN6u4sL+SC0tuojyxZRar50uxXcAI=). - Run
CdpClient.evm.create_account()usingcdp-sdkv1.31.0. - Observe the error:
ValueError: Could not create the EC key: Incorrect padding. - Replace
CDP_WALLET_SECRETwith the portal’s 184-char EC key (base64 DER EC key, e.g.,MIGHAg...). - Rerun the function, which succeeds and creates an EVM EOA.
For CDP_API_KEY_SECRET:
- Set
CDP_API_KEY_SECRETto a PEM EC key (e.g.,-----BEGIN EC PRIVATE KEY-----MHcCAQEE...-----END EC PRIVATE KEY-----). - Run
CdpClient.evm.get_or_create_smart_account()incdp-sdkv1.31.0. - Observe the error:
ValueError: Key must be either PEM EC key or base64 Ed25519 key. - Use the base64 DER EC key (e.g.,
MHcCAQEE...), which succeeds.
Expected Behavior
- The SDK should either support Ed25519 keys for
CDP_WALLET_SECRETas stated in the docs or the docs should specify thatCDP_WALLET_SECRETmust be a base64 DER EC key. CDP_API_KEY_SECRETshould accept valid PEM EC keys without errors, or the docs should clarify that it requires a base64 DER EC key.
Actual Behavior
CDP_WALLET_SECRETonly accepts base64 DER EC keys (or PEM-wrapped EC keys), and Ed25519 keys fail with parsing errors.CDP_API_KEY_SECRETrejects valid PEM EC keys, requiring base64 DER EC keys.
Environment
- SDK:
cdp-sdkv1.31.0 - Python: 3.10
- OS: Ubuntu 22.04 (WSL2)
- Dependencies:
pynacl1.5.0,aiohttp,pyjwt
Suggested Fix
- Update the documentation (https://docs.cdp.coinbase.com/server-wallets/v2/introduction/quickstart) to clarify:
CDP_WALLET_SECRETmust be a “base64 DER EC key” (as provided by the portal).CDP_API_KEY_SECRETshould be a “base64 DER EC key” or confirm PEM EC key support.
- Alternatively, add Ed25519 support to
generate_wallet_jwtandgenerate_jwtfunctions in the SDK to align with the current docs.
Additional Notes
- Successfully created an EVM EOA (
0xd6ea...) and funded it on Base Sepolia (tx:0x8eb..., 0.0001 ETH) using the portal’s 184-char EC key forCDP_WALLET_SECRET. - Encountered issues with
CDP_API_KEY_SECRETwhen creating a smart account, resolved by using base64 DER EC key. - The docs’ typo and parsing issues led to significant debugging time, which could be avoided with clearer instructions or fixed SDK logic.
- Reported via Coinbase’s AI agent on the docs site, but posting here for visibility to the developer community.
Contact
- GitHub: @metatronyxAI
- Email: [email protected]
metatronyxAI
Metadata
Metadata
Assignees
Labels
No labels