joyboy icon indicating copy to clipboard operation
joyboy copied to clipboard

Feat improve bech32 perf

Open remybar opened this issue 6 months ago • 1 comments

Related to https://github.com/keep-starknet-strange/joyboy/issues/74.

This PR uses Cairo 2.7.0 so it depends on the PR https://github.com/keep-starknet-strange/joyboy/pull/296 (which is blocked until snfoundry has been updated to work with Cairo 2.7.0).

Proposed optimizations:

  • use a const fixed-size array for alphabet,
  • direct conversion from ByteArray to 5-bits chunks,
  • use for in loop in encode,
  • avoid creating temporary arrays,
  • hardcode generator loop in polymod,
  • avoid using shr in polymod,
  • call polymod directly, without intermediate arrays.

Note that all modifications have been done in bech32.cairo. The other modifications come from the PR https://github.com/keep-starknet-strange/joyboy/pull/296.

remybar avatar Aug 18 '24 13:08 remybar