You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function convertPackedBytesToString(uint256[] memorypackedBytes, uint256maxBytes, uint256packSize)
Similarly it seems that packSize is fixed here to 7 is that right? Since that's how circom does it's packing. https://github.com/zkemail/email-wallet/blob/461782c9f3a9cf9ef21fbd8628414692e45223a0/packages/contracts/src/utils/StringUtils.sol#L82
If I can suggest a different function signature could it look something like this: function convertPackedBytesToBytes(uint256[] memory packedBytes, uint256 signals) internal pure returns (string memory extractedString)
We can then treat the packSize as a constant --> PACK_SIZE and calculate maxBytes as follows: uint256 maxBytes = signals * PACK_SIZE
Not sure signals is the best name but this seems a bit cleaner. You also may be designing for different potential pack sizes. Lemme know what you think.
The text was updated successfully, but these errors were encountered:
Not necessarily. You might imagine you have some value that in the circuit is at most 10 characters, but is packed into 1 packed byte; so in this case, the maxBytes would be 10 characters. maxBytes is used to ensure that even with offsets, your string is only a certain length. We can default that to be the same as packedBytes * pack_size if unspecified, but in some cases might want to be less.
Correct, that is a bug. It's fixed to 7 arbitrarily on accident (it used to be 7 a long time ago), even though we changed the packed size in circom. We should edit the 7 in the body to be pack_size.
Not sure PACK_SIZE should be constant, people might want to pack things other than bytes. At the same time, we do hardcode packed signals to be bytes (i.e. at most 8 bits via >> 8), so perhaps both that 8 and PACK_SIZE should be either both arguments or both constants. If 8 is hardcoded, then PACK_SIZE should be 31, since that should be set as the max in any corresponding circuits for optimal performance.
Brian from zkp2p here! Just wanted to make sure I was understanding some logic in the
StringUtils
function.Am I right to assume that
maxBytes
needs to be a multiple ofpackSize
here?email-wallet/packages/contracts/src/utils/StringUtils.sol
Line 74 in 461782c
Similarly it seems that
packSize
is fixed here to7
is that right? Since that's how circom does it's packing.https://github.com/zkemail/email-wallet/blob/461782c9f3a9cf9ef21fbd8628414692e45223a0/packages/contracts/src/utils/StringUtils.sol#L82
If I can suggest a different function signature could it look something like this:
function convertPackedBytesToBytes(uint256[] memory packedBytes, uint256 signals) internal pure returns (string memory extractedString)
We can then treat the
packSize
as aconstant
-->PACK_SIZE
and calculatemaxBytes
as follows:uint256 maxBytes = signals * PACK_SIZE
Not sure
signals
is the best name but this seems a bit cleaner. You also may be designing for different potential pack sizes. Lemme know what you think.The text was updated successfully, but these errors were encountered: