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

feat: review padding and type conversions in rollup #10148

Open
Tracked by #7820
MirandaWood opened this issue Nov 22, 2024 · 0 comments
Open
Tracked by #7820

feat: review padding and type conversions in rollup #10148

MirandaWood opened this issue Nov 22, 2024 · 0 comments

Comments

@MirandaWood
Copy link
Contributor

MirandaWood commented Nov 22, 2024

Now that we have blobs, we also have some root public inputs in the form of BigNums. The numbers are too big to fit into a field, and we don't yet hash all public inputs, so for now we convert bytes32 to and from these numbers:

  function _bytes32ToBigNum(bytes32 _input)
    internal
    pure
    returns (bytes32 firstLimb, bytes32 secondLimb, bytes32 thirdLimb)
  {
    firstLimb = bytes32(uint256(uint120(bytes15(_input << 136))));
    secondLimb = bytes32(uint256(uint120(bytes15(_input << 16))));
    thirdLimb = bytes32(uint256(uint16(bytes2(_input))));
  }

Another public input is a 48-byte compressed point, which (to fit into 2 fields) is encoded as a 31 byte and 17 byte pair:

          // To fit into 2 fields, the commitment is split into 31 and 17 byte numbers
          // TODO: The below left pads, possibly inefficiently
          // c[0]
          publicInputs[offset++] = bytes32(
            uint256(uint248(bytes31(_submitArgs.blobPublicInputs[blobOffset:blobOffset += 31])))
          );
          // c[1]
          publicInputs[offset++] = bytes32(
            uint256(uint136(bytes17(_submitArgs.blobPublicInputs[blobOffset:blobOffset += 17])))
          );

The padding/conversions may be ineffecient and should be reviewed.

This was referenced Nov 22, 2024
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

No branches or pull requests

1 participant