...
1secp256k1
2=========
3
4[](https://github.com/decred/dcrd/actions)
5[](http://copyfree.org)
6[](https://pkg.go.dev/github.com/decred/dcrd/dcrec/secp256k1/v4)
7
8Package secp256k1 implements optimized secp256k1 elliptic curve operations.
9
10This package provides an optimized pure Go implementation of elliptic curve
11cryptography operations over the secp256k1 curve as well as data structures and
12functions for working with public and private secp256k1 keys. See
13https://www.secg.org/sec2-v2.pdf for details on the standard.
14
15In addition, sub packages are provided to produce, verify, parse, and serialize
16ECDSA signatures and EC-Schnorr-DCRv0 (a custom Schnorr-based signature scheme
17specific to Decred) signatures. See the README.md files in the relevant sub
18packages for more details about those aspects.
19
20An overview of the features provided by this package are as follows:
21
22- Private key generation, serialization, and parsing
23- Public key generation, serialization and parsing per ANSI X9.62-1998
24 - Parses uncompressed, compressed, and hybrid public keys
25 - Serializes uncompressed and compressed public keys
26- Specialized types for performing optimized and constant time field operations
27 - `FieldVal` type for working modulo the secp256k1 field prime
28 - `ModNScalar` type for working modulo the secp256k1 group order
29- Elliptic curve operations in Jacobian projective coordinates
30 - Point addition
31 - Point doubling
32 - Scalar multiplication with an arbitrary point
33 - Scalar multiplication with the base point (group generator)
34- Point decompression from a given x coordinate
35- Nonce generation via RFC6979 with support for extra data and version
36 information that can be used to prevent nonce reuse between signing algorithms
37
38It also provides an implementation of the Go standard library `crypto/elliptic`
39`Curve` interface via the `S256` function so that it may be used with other
40packages in the standard library such as `crypto/tls`, `crypto/x509`, and
41`crypto/ecdsa`. However, in the case of ECDSA, it is highly recommended to use
42the `ecdsa` sub package of this package instead since it is optimized
43specifically for secp256k1 and is significantly faster as a result.
44
45Although this package was primarily written for dcrd, it has intentionally been
46designed so it can be used as a standalone package for any projects needing to
47use optimized secp256k1 elliptic curve cryptography.
48
49Finally, a comprehensive suite of tests is provided to provide a high level of
50quality assurance.
51
52## secp256k1 use in Decred
53
54At the time of this writing, the primary public key cryptography in widespread
55use on the Decred network used to secure coins is based on elliptic curves
56defined by the secp256k1 domain parameters.
57
58## Installation and Updating
59
60This package is part of the `github.com/decred/dcrd/dcrec/secp256k1/v4` module.
61Use the standard go tooling for working with modules to incorporate it.
62
63## Examples
64
65* [Encryption](https://pkg.go.dev/github.com/decred/dcrd/dcrec/secp256k1/v4#example-package-EncryptDecryptMessage)
66 Demonstrates encrypting and decrypting a message using a shared key derived
67 through ECDHE.
68
69## License
70
71Package secp256k1 is licensed under the [copyfree](http://copyfree.org) ISC
72License.
View as plain text