From 20e6eefe0ebf13c530939d84f34b2775e97f8662 Mon Sep 17 00:00:00 2001 From: ofek Date: Mon, 27 Mar 2017 22:39:25 -0400 Subject: [PATCH] update docs --- .travis/install.sh | 1 + README.md | 38 ++++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.travis/install.sh b/.travis/install.sh index f2b104e..5511385 100644 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -70,6 +70,7 @@ if [[ $TRAVIS_OS_NAME == "osx" ]]; then builtin popd fi + # https://bugs.python.org/issue28150 if [[ "${NEED_SSL_FIX}" == "true" ]]; then "/Applications/Python ${TRAVIS_PYTHON_VERSION}/Install Certificates.command" fi diff --git a/README.md b/README.md index 4b93306..623a7a4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ -# Fork of [https://github.com/ludbb/secp256k1-py](https://github.com/ludbb/secp256k1-py) +# Coincurve +Python CFFI bindings for [libsecp256k1](https://github.com/bitcoin/secp256k1) +(an experimental and optimized C library for EC operations on curve secp256k1). +This is a fork of [https://github.com/ludbb/secp256k1-py](https://github.com/ludbb/secp256k1-py). -Python FFI bindings for [libsecp256k1](https://github.com/bitcoin/secp256k1) -(an experimental and optimized C library for EC operations on curve secp256k1). +New features: + +- Implements a fix for [https://bugs.python.org/issue28150](https://bugs.python.org/issue28150) + to support Python 3.6 +- Supports Windows (soon) ## Installation @@ -18,7 +24,7 @@ Precompiled binary wheels is available for Python 2.7, 3.3, 3.4, and 3.5 on Linu ## API -#### class `coincurve.PrivateKey(privkey, raw, flags)` +#### class `secp256k1.PrivateKey(privkey, raw, flags)` The `PrivateKey` class loads or creates a private key by obtaining 32 bytes from urandom and operates over it. @@ -26,11 +32,11 @@ The `PrivateKey` class loads or creates a private key by obtaining 32 bytes from - `privkey=None` - generate a new private key if None, otherwise load a private key. - `raw=True` - if `True`, it is assumed that `privkey` is just a sequence of bytes, otherwise it is assumed that it is in the DER format. This is not used when `privkey` is not specified. -- `flags=coincurve.ALL_FLAGS` - see Constants. +- `flags=secp256k1.ALL_FLAGS` - see Constants. ##### Methods and instance attributes -- `pubkey`: an instance of `coincurve.PublicKey`. +- `pubkey`: an instance of `secp256k1.PublicKey`. - `private_key`: raw bytes for the private key. - `set_raw_privkey(privkey)`
@@ -71,7 +77,7 @@ To combine pubnonces, use `PublicKey.combine`.

Do not pass the pubnonce produced for the respective privnonce; combine the pubnonces from other signers and pass that instead. -#### class `coincurve.PublicKey(pubkey, raw, flags)` +#### class `secp256k1.PublicKey(pubkey, raw, flags)` The `PublicKey` class loads an existing public key and operates over it. @@ -79,7 +85,7 @@ The `PublicKey` class loads an existing public key and operates over it. - `pubkey=None` - do not load a public key if None, otherwise do. - `raw=False` - if `False`, it is assumed that `pubkey` has gone through `PublicKey.deserialize` already, otherwise it must be specified as bytes. -- `flags=coincurve.FLAG_VERIFY` - see Constants. +- `flags=secp256k1.FLAG_VERIFY` - see Constants. ##### Methods and instance attributes @@ -112,9 +118,9 @@ compute an EC Diffie-Hellman secret in constant time. The instance `public_key` > NOTE: `ecdh` can only be used if the `secp256k1` C library is compiled with support for it. If there is no support, an Exception will be raised when calling it. -#### class `coincurve.ECDSA` +#### class `secp256k1.ECDSA` -The `ECDSA` class is intended to be used as a mix in. Its methods can be accessed from any `coincurve.PrivateKey` or `coincurve.PublicKey` instances. +The `ECDSA` class is intended to be used as a mix in. Its methods can be accessed from any `secp256k1.PrivateKey` or `secp256k1.PublicKey` instances. ##### Methods @@ -136,7 +142,7 @@ This function always return a tuple containing a boolean (True if not previously - `ecdsa_recover(msg, recover_sig, raw=False, digest=hashlib.sha256)` -> internal object
recover an ECDSA public key from a signature generated by `ecdsa_sign_recoverable`. `recover_sig` is expected to be an object returned from `ecdsa_sign_recoverable` (or if it was serialized using `ecdsa_recoverable_serialize`, then first run it through `ecdsa_recoverable_deserialize`). `msg`, `raw`, and `digest` are used as described in `ecdsa_sign`.

-In order to call `ecdsa_recover` from a `PublicKey` instance, it's necessary to create the instance by settings `flags` to `ALL_FLAGS`: `coincurve.PublicKey(..., flags=coincurve.ALL_FLAGS)`. +In order to call `ecdsa_recover` from a `PublicKey` instance, it's necessary to create the instance by settings `flags` to `ALL_FLAGS`: `secp256k1.PublicKey(..., flags=secp256k1.ALL_FLAGS)`. - `ecdsa_recoverable_serialize(recover_sig)` -> (bytes, int)
convert the result from `ecdsa_sign_recoverable` to a tuple composed of 65 bytesand an integer denominated as recovery id. @@ -150,9 +156,9 @@ convert a recoverable signature to a normal signature, i.e. one that can be used > NOTE: `ecdsa_recover*` can only be used if the `secp256k1` C library is compiled with support for it. If there is no support, an Exception will be raised when calling any of them. -#### class `coincurve.Schnorr` +#### class `secp256k1.Schnorr` -The `Schnorr` class is intended to be used as a mix in. Its methods can be accessed from any `coincurve.PrivateKey` or `coincurve.PublicKey` instances. +The `Schnorr` class is intended to be used as a mix in. Its methods can be accessed from any `secp256k1.PrivateKey` or `secp256k1.PublicKey` instances. ##### Methods @@ -167,9 +173,9 @@ combine multiple Schnorr partial signatures. `raw_sigs` is expected to be a list #### Constants -##### `coincurve.FLAG_SIGN` -##### `coincurve.FLAG_VERIFY` -##### `coincurve.ALL_FLAGS` +##### `secp256k1.FLAG_SIGN` +##### `secp256k1.FLAG_VERIFY` +##### `secp256k1.ALL_FLAGS` `ALL_FLAGS` combines `FLAG_SIGN` and `FLAG_VERIFY` using bitwise OR.