Optimize ECDH functions to use windowed multiplication for improved performance
This commit updates the ECDH and ECDHXOnly functions to utilize optimized windowed multiplication instead of constant-time multiplication. This change is justified as the secret key is already known, allowing for variable-time operations. Additionally, new .idea configuration files are added, including .gitignore, misc.xml, modules.xml, p256k1.mleku.dev.iml, and vcs.xml, to enhance project management and version control settings.
This commit is contained in:
5
.idea/.gitignore
generated
vendored
Normal file
5
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
10
.idea/misc.xml
generated
Normal file
10
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MaterialThemeProjectNewConfig">
|
||||||
|
<option name="metadata">
|
||||||
|
<MTProjectMetadataState>
|
||||||
|
<option name="userId" value="-62fe7e2d:19874553008:-7ffa" />
|
||||||
|
</MTProjectMetadataState>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/p256k1.mleku.dev.iml" filepath="$PROJECT_DIR$/.idea/p256k1.mleku.dev.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
12
.idea/p256k1.mleku.dev.iml
generated
Normal file
12
.idea/p256k1.mleku.dev.iml
generated
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
10
ecdh.go
10
ecdh.go
@@ -204,9 +204,10 @@ func ECDH(output []byte, pubkey *PublicKey, seckey []byte, hashfp ECDHHashFuncti
|
|||||||
return errors.New("secret key cannot be zero")
|
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
|
var res GroupElementJacobian
|
||||||
EcmultConst(&res, &pt, &s)
|
ecmultWindowedVar(&res, &pt, &s)
|
||||||
|
|
||||||
// Convert to affine
|
// Convert to affine
|
||||||
var resAff GroupElementAffine
|
var resAff GroupElementAffine
|
||||||
@@ -352,9 +353,10 @@ func ECDHXOnly(output []byte, pubkey *PublicKey, seckey []byte) error {
|
|||||||
return errors.New("secret key cannot be zero")
|
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
|
var res GroupElementJacobian
|
||||||
EcmultConst(&res, &pt, &s)
|
ecmultWindowedVar(&res, &pt, &s)
|
||||||
|
|
||||||
// Convert to affine
|
// Convert to affine
|
||||||
var resAff GroupElementAffine
|
var resAff GroupElementAffine
|
||||||
|
|||||||
Reference in New Issue
Block a user