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

Reduce message sizes #47

Merged
merged 4 commits into from
Nov 11, 2023
Merged

Reduce message sizes #47

merged 4 commits into from
Nov 11, 2023

Conversation

fjarri
Copy link
Member

@fjarri fjarri commented Nov 11, 2023

  • Use Bincode instead of MessagePack for internal serialization. MessagePack results in an inefficient encoding of Uint values (see serdect: safer bytes handling RustCrypto/formats#1112, it is currently merged but will take some time to propagate); also Bincode is already used by entropy-core.
  • Pack Signed values before serializing. They are bounded, and the bound is often much smaller than the full size of the integer, so we now serialize only the actual significant bytes.
  • The change above leads to a slight variation in message sizes because Signed::random_bounded_bits_scaled() could produce numbers with a slightly different bound (because the scale is the RSA modulus, which can be either PRIME_BITS * 2 or PRIME_BITS * 2 - 1 in size, depending on the value of the RSA primes). This PR changes it to always produce a number with a fixed bound.

For reference, the message sizes after this PR are:

  • Keygen & Aux: 80b, 42kb, 65kb
  • Presigning + Signing: 1kb/2kb, 11kb, 2kb, 40b

The reduction is 1.5x-2x compared to the base of the PR (mainly due to replacing MessagePack with Bincode; the packing is much less impactful since most of the size is taken by unbounded integers).

The built-in serialization of Uints has problems with MessagePack,
producing variable-sized serialization.
Helps with keeping the message sizes constant.
Copy link

vercel bot commented Nov 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
synedrion ✅ Ready (Inspect) Visit Preview Nov 11, 2023 8:25pm

@fjarri fjarri merged commit 1e30507 into master Nov 11, 2023
6 checks passed
@fjarri fjarri deleted the message-size branch November 11, 2023 20:31
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.

1 participant