Skip to content

Conversation

Kubuxu
Copy link
Contributor

@Kubuxu Kubuxu commented Dec 20, 2022

No description provided.

@Kubuxu Kubuxu marked this pull request as draft December 20, 2022 11:33
)

// Pad pads a general byte array in to FP32 chunks of bytes where the topmost bits of the most significant byte are 0
func Pad(unpaddedData *[]byte) ([]types.FP32, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

You don't need to take the pointer here. The slice is a tuple of (*array, len, capacity) and is usually passed by value.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the clarification, that is a very nice detail to know about arrays in Go!

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in 9872fe3

"github.com/filecoin-project/go-data-segment/types"
)

// Pad pads a general byte array in to FP32 chunks of bytes where the topmost bits of the most significant byte are 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit: it isn't FP32 but Fr32, it gets its name from the r of BLS-12-381: https://github.com/filecoin-project/paired/tree/master/src/bls12_381#bls12-381-instantiation.
It is a padding scheme compatible with Field over r.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in commit cea535e

@@ -2,103 +2,103 @@ package parsing

import (
"errors"
"github.com/filecoin-project/go-data-segment/types"
"github.com/filecoin-project/go-data-segment/fr32"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think types previously was fine, we can have more types there and now we have a repetition of the fr32.Fr32 which is a bit ugly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I see why you did it, so the Bits* are nicer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works as well, I would say.

}

// Return a slice containing the next segment of unpadded data (without copying data), it will be a slice of either 32 or 33 bytes
func getChunk(bitIdx int, unpaddedData *[]byte) []byte {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The pointer to slice snuck through.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! Fixed in d2c13c6

@jot2re jot2re marked this pull request as ready for review December 20, 2022 14:24
@jot2re
Copy link
Contributor

jot2re commented Dec 20, 2022

@Kubuxu I implemented the fixes suggested. I can unfortunately not set you explicitly as the reviewer as you created the PR

@Kubuxu Kubuxu merged commit 4474486 into master Jan 2, 2023
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.

2 participants