This modifies the core logic for decompressing a y coordinate from an x coordinate, which is primarily used when parsing public keys, but can also be used when recovering public keys from compact signatures in the future, to make use of field vals and their recently-added optimized modular square root calculation capability and also adds comprehensive tests to ensure the decompression works properly independent of public key parsing. Since the public key type is still defined in terms of big ints, the parsing function still relies on them and so the existing decompressPoint function was updated to make use of the new function and perform the necessary conversion to and from big ints. Ultimately, the goal is make that unnecessary. This is work towards eventually using the new more efficient mod n scalar throughout. The following benchmark shows a before and after comparison of decompressing a public key: benchmark old ns/op new ns/op delta ------------------------------------------------------------- BenchmarkPubKeyDecompress 43574 10961 -74.85% benchmark old allocs new allocs delta ------------------------------------------------------------- BenchmarkPubKeyDecompress 28 0 -100.00% benchmark old bytes new bytes delta ------------------------------------------------------------- BenchmarkPubKeyDecompress 2586 0 -100.00% |
||
|---|---|---|
| .. | ||
| edwards | ||
| secp256k1 | ||
| common.go | ||
| go.mod | ||