Create a Solana Keypair from DstackClient key response. DEPRECATED: Use to_keypair_secure instead. This method has security concerns. Current implementation uses raw key material without proper hashing. Args: get_key_response: Response from get_key() or get_tls_key() Retur
(get_key_response: GetKeyResponse | GetTlsKeyResponse)
| 18 | |
| 19 | |
| 20 | def to_keypair(get_key_response: GetKeyResponse | GetTlsKeyResponse) -> Keypair: |
| 21 | """Create a Solana Keypair from DstackClient key response. |
| 22 | |
| 23 | DEPRECATED: Use to_keypair_secure instead. This method has security concerns. |
| 24 | Current implementation uses raw key material without proper hashing. |
| 25 | |
| 26 | Args: |
| 27 | get_key_response: Response from get_key() or get_tls_key() |
| 28 | |
| 29 | Returns: |
| 30 | Keypair: Solana keypair object |
| 31 | |
| 32 | """ |
| 33 | if isinstance(get_key_response, GetTlsKeyResponse): |
| 34 | warnings.warn( |
| 35 | "to_keypair: Please don't use getTlsKey method to get key, use getKey instead.", |
| 36 | DeprecationWarning, |
| 37 | stacklevel=2, |
| 38 | ) |
| 39 | # Restored original behavior: using first 32 bytes directly |
| 40 | key_bytes = get_key_response.as_uint8array(32) |
| 41 | return Keypair.from_seed(key_bytes) |
| 42 | else: # GetKeyResponse |
| 43 | return Keypair.from_seed(get_key_response.decode_key()) |
| 44 | |
| 45 | |
| 46 | def to_keypair_secure(get_key_response: GetKeyResponse | GetTlsKeyResponse) -> Keypair: |