capitalone / fpe

A format-preserving encryption implementation in Go
Apache License 2.0
201 stars 40 forks source link

Performance Tweaks #5

Closed anitgandhi closed 6 years ago

anitgandhi commented 7 years ago

Description of Enhancement

  1. Use byte slices and utf8 instead of strings
  2. Reduce extraneous allocations, a la #3
anitgandhi commented 7 years ago

ciph and prf should have a signature closer to

func (f *Cipher) ciph(output, input []byte) error

to reduce escapes to the heap for the return value.

anitgandhi commented 7 years ago

Majority of allocations are coming from the fact that everything in this library operates on strings. In theory, the operations can be changed to using utf8 package backed by byte slices.

anitgandhi commented 7 years ago

8 partially completes this, however I'm leaving this open as there are opportunities for more improvement with regards to strings and big integers.