diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0548b67 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..aac95b1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/p256k1.mleku.dev.iml b/.idea/p256k1.mleku.dev.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/p256k1.mleku.dev.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ecdh.go b/ecdh.go index 245d72a..6143a60 100644 --- a/ecdh.go +++ b/ecdh.go @@ -204,9 +204,10 @@ func ECDH(output []byte, pubkey *PublicKey, seckey []byte, hashfp ECDHHashFuncti return errors.New("secret key cannot be zero") } - // Compute res = s * pt using constant-time multiplication + // Compute res = s * pt using optimized windowed multiplication (variable-time) + // ECDH doesn't require constant-time since the secret key is already known var res GroupElementJacobian - EcmultConst(&res, &pt, &s) + ecmultWindowedVar(&res, &pt, &s) // Convert to affine var resAff GroupElementAffine @@ -352,9 +353,10 @@ func ECDHXOnly(output []byte, pubkey *PublicKey, seckey []byte) error { return errors.New("secret key cannot be zero") } - // Compute res = s * pt + // Compute res = s * pt using optimized windowed multiplication (variable-time) + // ECDH doesn't require constant-time since the secret key is already known var res GroupElementJacobian - EcmultConst(&res, &pt, &s) + ecmultWindowedVar(&res, &pt, &s) // Convert to affine var resAff GroupElementAffine