sodium-friends / sodium-native

Low level bindings for libsodium
MIT License
300 stars 64 forks source link

`crypto_tweak_ed25519_sign_detached` accepts precomputed public key #161

Closed chm-diederichs closed 1 year ago

chm-diederichs commented 2 years ago

This PR allows an optional public key to be passed to crypto_tweak_ed25519_sign_detached. When provided, the signature is computed ~2x faster.

Motivation:

crypto_sign secret keys are 64 bytes in length, because they include the precomputed public key. Without this information, the public key would have to be computed from the derived scalar, which is roughly as expensive as computing the signature itself.

Since the crypto_tweak takes the scalars directly, we cannot use the same format, so instead we accept the precomputed public key as an optional argument.

mafintosh commented 2 years ago

@chm-diederichs there is a conflict here now