mirror of
https://github.com/btcsuite/btcd.git
synced 2025-03-10 17:26:07 +01:00
In this commit, we turn the package into a new Go module (version 2), and then port over the current set of types and functions to mainly alias to the more optimized and maintained dcrec variant. Taking a look at the benchmarks, most operations other than normalization (which IIRC is a bit slower now due to constant time fixes) enjoy some nice speeds up: ``` benchcmp is deprecated in favor of benchstat: https://pkg.go.dev/golang.org/x/perf/cmd/benchstat benchmark old ns/op new ns/op delta BenchmarkAddJacobian-8 464 328 -29.20% BenchmarkAddJacobianNotZOne-8 1138 372 -67.27% BenchmarkScalarBaseMult-8 47336 31531 -33.39% BenchmarkScalarBaseMultLarge-8 42465 32057 -24.51% BenchmarkScalarMult-8 123355 117579 -4.68% BenchmarkNAF-8 582 168 -71.12% BenchmarkSigVerify-8 175414 120794 -31.14% BenchmarkFieldNormalize-8 23.8 24.4 +2.39% BenchmarkParseCompressedPubKey-8 24282 10907 -55.08% ```
40 lines
1.8 KiB
Markdown
40 lines
1.8 KiB
Markdown
btcec
|
|
=====
|
|
|
|
[](https://github.com/btcsuite/btcd/actions)
|
|
[](http://copyfree.org)
|
|
[](https://pkg.go.dev/github.com/btcsuite/btcd/btcec/v2)
|
|
|
|
Package btcec implements elliptic curve cryptography needed for working with
|
|
Bitcoin (secp256k1 only for now). It is designed so that it may be used with the
|
|
standard crypto/ecdsa packages provided with go. A comprehensive suite of test
|
|
is provided to ensure proper functionality. Package btcec was originally based
|
|
on work from ThePiachu which is licensed under the same terms as Go, but it has
|
|
signficantly diverged since then. The btcsuite developers original is licensed
|
|
under the liberal ISC license.
|
|
|
|
Although this package was primarily written for btcd, it has intentionally been
|
|
designed so it can be used as a standalone package for any projects needing to
|
|
use secp256k1 elliptic curve cryptography.
|
|
|
|
## Installation and Updating
|
|
|
|
```bash
|
|
$ go install -u -v github.com/btcsuite/btcd/btcec/v2
|
|
```
|
|
|
|
## Examples
|
|
|
|
* [Sign Message](https://pkg.go.dev/github.com/btcsuite/btcd/btcec/v2#example-package--SignMessage)
|
|
Demonstrates signing a message with a secp256k1 private key that is first
|
|
parsed form raw bytes and serializing the generated signature.
|
|
|
|
* [Verify Signature](https://pkg.go.dev/github.com/btcsuite/btcd/btcec/v2#example-package--VerifySignature)
|
|
Demonstrates verifying a secp256k1 signature against a public key that is
|
|
first parsed from raw bytes. The signature is also parsed from raw bytes.
|
|
|
|
## License
|
|
|
|
Package btcec is licensed under the [copyfree](http://copyfree.org) ISC License
|
|
except for btcec.go and btcec_test.go which is under the same license as Go.
|
|
|