ECDSA Signature

The gcEVM employs the ECDSA signature scheme to acquire the user AES key utilized for data encryption and decryption.

The SDK provides a signing functionality to facilitate this process.

Below are the function signatures for signing, provided in Python, JavaScript, and Go languages:

def sign(message, key)

The function signs the message using the given ECDSA private key.

Input parameters:

  • message: The message to sign

  • key: ECDSA private key

Output:

  • The generated signature

Example usage - Onboard user

As described in the previous page, when executing the onboard_user script, the user AES key is obtained. During this process, it's necessary to apply a signature to the RSA public key.

Below are examples demonstrating the usage of the sign function in both Python and JavaScript languages:

# Generate new RSA key pair
private_key, public_key = generate_rsa_keypair()
# Sign the RSA public key using ECDSA private key
signedEK = sign(public_key, bytes.fromhex(signing_key[2:]))

# Call the getUserKey function to get the encrypted AES key
receipt = soda_helper.call_contract_transaction("onboard_user", "getUserKey", func_args=[public_key, signedEK])
if receipt is None:
    print("Failed to call the transaction function")
    return
encryptedKey = contract.functions.getSavedUserKey().call()

# Decrypt the aes key using the RSA private key
decrypted_aes_key = decrypt_rsa(private_key, encryptedKey)

Last updated