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

Implement encoding.Binary{Marshaler, Unmarshaler} #41

Merged
merged 1 commit into from Aug 9, 2021

Conversation

adr1anh
Copy link
Contributor

@adr1anh adr1anh commented Aug 9, 2021

These functions are simple wrappers around Nat.SetBytes() and Nat.Bytes().

For Modulus, we additionally call precomputeValues() in UnmarshalBinary().

Int returns byte(i.sign) || i.nat.Bytes(), so that the result is always at least one byte long. Only the LSB of of the first byte is actually used.

Also includes test to check that MarshalBinary() -> UnmarshalBinary() returns the same result.

These functions are simple wrappers around `Nat.SetBytes()` and `Nat.Bytes()`.

For `Modulus`, we additionally call `precomputeValues()` in `UnmarshalBinary()`.

`Int` returns `byte(i.sign) || i.nat.Bytes()`, so that the result is always at least one byte long. Only the LSB of of the first byte is actually used.
Copy link
Owner

@cronokirby cronokirby left a comment

Choose a reason for hiding this comment

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

Perfect!

@cronokirby cronokirby merged commit 3520dfb into cronokirby:main Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants