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

writer: split embedded data into chunks #13

Merged
merged 1 commit into from
Mar 2, 2023
Merged

writer: split embedded data into chunks #13

merged 1 commit into from
Mar 2, 2023

Conversation

tuxcanfly
Copy link
Collaborator

@tuxcanfly tuxcanfly commented Mar 2, 2023

Fixes #5

TODO:

  • Update Read to re-group chunks
  • Test that >520B data is chunked
  • Test that data is re-grouped back in Read

@tuxcanfly tuxcanfly requested a review from Ferret-san March 2, 2023 21:45
@tuxcanfly tuxcanfly force-pushed the write-chunks branch 2 times, most recently from 238ab55 to 099c0d3 Compare March 2, 2023 22:02
@tuxcanfly tuxcanfly merged commit ecae5cb into main Mar 2, 2023
@tuxcanfly
Copy link
Collaborator Author

Just realized this will fail if canonical size is >2 because we're using a fixed size:

			// script template:
			//                                           < ---------          35 bytes        --------->
			// OP_FALSE OP_IF + "roll" marker +  <data> + canonical int + 32 bytes pubkey + OP_CHECKSIG
			//                   ^                      ^
			// start ------------                       ^
			// end -------------------------------------

We'll be slicing off a byte from the last. @Ferret-san I think we should just use a end marker, like "kit" or something. I can then just do end := bytes.Index(witness, END_MARKER)

@tuxcanfly
Copy link
Collaborator Author

Just realized this will fail if canonical size is >2 because we're using a fixed size:

			// script template:
			//                                           < ---------          35 bytes        --------->
			// OP_FALSE OP_IF + "roll" marker +  <data> + canonical int + 32 bytes pubkey + OP_CHECKSIG
			//                   ^                      ^
			// start ------------                       ^
			// end -------------------------------------

We'll be slicing off a byte from the last. @Ferret-san I think we should just use a end marker, like "kit" or something. I can then just do end := bytes.Index(witness, END_MARKER)

Nevermind, this works. Because the last canonical int is size of pubkey which is fixed.

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.

writer: break into 520B chunks
1 participant