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

element.SetBytesCanonical, element.BigEndian and element.LittleEndian #286

Merged
merged 3 commits into from
Dec 16, 2022

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Dec 15, 2022

This PR introduces SetBytesCanonical

// SetBytesCanonical interprets e as the bytes of a big-endian X-byte integer.
// If e is not a X-byte slice or encodes a value higher than q,
// SetBytesCanonical returns an error.
func (z *Element) SetBytesCanonical(e []byte) error {

element.BigEndian and element.LittleEndian implements a encoding/binary inspired interface:

// A ByteOrder specifies how to convert byte slices into a Element
type ByteOrder interface {
	Element(*[Bytes]byte) (Element, error)
	PutElement(*[Bytes]byte, Element)
	String() string
}

@gbotrel gbotrel merged commit 34193b4 into develop Dec 16, 2022
@gbotrel gbotrel deleted the clean/setbytes branch December 16, 2022 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants