Skip to content

Commit 9025e76

Browse files
committed
type-hint
1 parent 3ad1234 commit 9025e76

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Examples/runtimes/python/DynamoDBEncryption/src/keyring/raw_ecdh_keyring_example.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
- Sort key is named "sort_key" with type (S)
1717
"""
1818
import pathlib
19-
2019
import boto3
2120
from aws_cryptographic_material_providers.mpl import AwsCryptographicMaterialProviders
2221
from aws_cryptographic_material_providers.mpl.config import MaterialProvidersConfig
@@ -29,6 +28,7 @@
2928
RawEcdhStaticConfigurationsRawPrivateKeyToStaticPublicKey,
3029
RawPrivateKeyToStaticPublicKeyInput,
3130
)
31+
from aws_cryptography_primitives.smithygenerated.aws_cryptography_primitives.models import ECDHCurveSpec
3232
from aws_cryptographic_material_providers.mpl.references import IKeyring
3333
from aws_dbesdk_dynamodb.encrypted.client import EncryptedClient
3434
from aws_dbesdk_dynamodb.structures.dynamodb import (
@@ -46,7 +46,7 @@
4646
EXAMPLE_ECC_PUBLIC_KEY_FILENAME_RECIPIENT = "RawEcdhKeyringExamplePublicKeyRecipient.pem"
4747

4848

49-
def raw_ecdh_keyring_get_item_put_item(ddb_table_name: str, curve_spec: str):
49+
def raw_ecdh_keyring_get_item_put_item(ddb_table_name: str, curve_spec: ECDHCurveSpec):
5050
"""
5151
Demonstrate using a raw ECDH keyring with static keys.
5252
@@ -106,7 +106,7 @@ def raw_ecdh_keyring_get_item_put_item(ddb_table_name: str, curve_spec: str):
106106
mat_prov = AwsCryptographicMaterialProviders(config=MaterialProvidersConfig())
107107

108108
keyring_input = CreateRawEcdhKeyringInput(
109-
curve_spec=curve_spec,
109+
curve_spec=str(curve_spec),
110110
key_agreement_scheme=RawEcdhStaticConfigurationsRawPrivateKeyToStaticPublicKey(
111111
RawPrivateKeyToStaticPublicKeyInput(
112112
# Must be a UTF8 PEM-encoded private key
@@ -122,7 +122,7 @@ def raw_ecdh_keyring_get_item_put_item(ddb_table_name: str, curve_spec: str):
122122
put_get_example_with_keyring(raw_ecdh_keyring, ddb_table_name)
123123

124124

125-
def ephemeral_raw_ecdh_keyring_put_item(ddb_table_name: str, curve_spec: str):
125+
def ephemeral_raw_ecdh_keyring_put_item(ddb_table_name: str, curve_spec: ECDHCurveSpec):
126126
"""
127127
Demonstrate using a raw ECDH keyring with ephemeral keys.
128128
@@ -159,9 +159,8 @@ def ephemeral_raw_ecdh_keyring_put_item(ddb_table_name: str, curve_spec: str):
159159
# encrypt data and CANNOT decrypt messages.
160160
# The DynamoDb encryption client uses this to encrypt items.
161161
mat_prov = AwsCryptographicMaterialProviders(config=MaterialProvidersConfig())
162-
163162
keyring_input = CreateRawEcdhKeyringInput(
164-
curve_spec=curve_spec,
163+
curve_spec=str(curve_spec),
165164
key_agreement_scheme=RawEcdhStaticConfigurationsEphemeralPrivateKeyToStaticPublicKey(
166165
EphemeralPrivateKeyToStaticPublicKeyInput(recipient_public_key=public_key_bytes)
167166
),
@@ -175,7 +174,7 @@ def ephemeral_raw_ecdh_keyring_put_item(ddb_table_name: str, curve_spec: str):
175174
put_example_with_keyring(raw_ecdh_keyring, ddb_table_name)
176175

177176

178-
def discovery_raw_ecdh_keyring_get_item(ddb_table_name: str, curve_spec: str):
177+
def discovery_raw_ecdh_keyring_get_item(ddb_table_name: str, curve_spec: ECDHCurveSpec):
179178
"""
180179
Demonstrate using a raw ECDH keyring with discovery.
181180
@@ -210,7 +209,7 @@ def discovery_raw_ecdh_keyring_get_item(ddb_table_name: str, curve_spec: str):
210209
mat_prov = AwsCryptographicMaterialProviders(config=MaterialProvidersConfig())
211210

212211
keyring_input = CreateRawEcdhKeyringInput(
213-
curve_spec=curve_spec,
212+
curve_spec=str(curve_spec),
214213
key_agreement_scheme=RawEcdhStaticConfigurationsPublicKeyDiscovery(
215214
PublicKeyDiscoveryInput(recipient_static_private_key=private_key_utf8_encoded)
216215
),

0 commit comments

Comments
 (0)