keypair: fix `hex` import and export
curve: reuse values when doubling multiple times