Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX: Keyreg bytes #521

Closed
wants to merge 26 commits into from
Closed

DX: Keyreg bytes #521

wants to merge 26 commits into from

Conversation

jannotti
Copy link
Contributor

@jannotti jannotti commented Dec 4, 2023

Allow the various key-ish fields of a keyreg txn to be bytes

Previously, these fields were required to be base64 encoded, which
seems like a strange requirement.

Added a few doc string cleanups.

@jannotti jannotti self-assigned this Dec 4, 2023
@jannotti jannotti requested a review from jasonpaulos December 4, 2023 17:36
@jannotti jannotti changed the title Keyreg bytes DX: Keyreg bytes Dec 4, 2023
votefst (int)
votelst (int)
votekd (int)
type (str)
lease (byte[32])
rekey_to (str)
nonpart (bool)
sprfkey (str)
sprfkey (byte[64])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanding the input types to support bytes is a no-brainer, but I'm reluctant to change the attribute types as I view that as a breaking change.

The reality is this SDK uses base64 encoded strings to shuttle bytes around in a lot of places (e.g. public/private keys as well), and it's really in need of an upgrade to bytes across the board.

votefst (int)
votelst (int)
votekd (int)
type (str)
lease (byte[32])
rekey_to (str)
nonpart (bool)
sprfkey (str)
sprfkey (byte[64])
"""

def __init__(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: it'd be nice to annotate the args with Union[bytes, bytearray, str] so it's clearer what types are accepted (though I realize this class does not do any type annotating)

if key is None:
return None
if isinstance(key, (bytes, bytearray)) and len(key) == size:
return key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd want to see bytearray coerced to bytes here if we were keeping the return value of this function in an attribute (for consistency and immutability). Though this isn't applicable if we don't change the attributes

Previously, these fields were required to be base64 encoded, which
seems like a strange requirement.  Now they may be bytes or b64
strings. Either way, they are stored in the python object as b64
strings to maintain compatibility with our original decision,
regardless of how strange it was.

Added a few doc string cleanups.
@jannotti
Copy link
Contributor Author

going to close this an re-open with a different strategy

@jannotti jannotti closed this Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants