MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / to_keypair

Function to_keypair

sdk/python/src/dstack_sdk/solana.py:20–43  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

18
19
20def 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
46def to_keypair_secure(get_key_response: GetKeyResponse | GetTlsKeyResponse) -> Keypair:

Callers 4

mainFunction · 0.90
test_async_to_keypairFunction · 0.90
test_sync_to_keypairFunction · 0.90

Calls 2

as_uint8arrayMethod · 0.80
decode_keyMethod · 0.45

Tested by 4

mainFunction · 0.72
test_async_to_keypairFunction · 0.72
test_sync_to_keypairFunction · 0.72