py_ecc.secp256k1 package

Submodules

py_ecc.secp256k1.secp256k1 module

py_ecc.secp256k1.secp256k1.add(a: PlainPoint2D, b: PlainPoint2D) PlainPoint2D

Add two 2D points a and b using elliptic curve point addition, and return the resulting 2D point in plain coordinates.

Parameters:
  • a (PlainPoint2D) – a 2D point on the elliptic curve

  • b (PlainPoint2D) – another 2D point on the elliptic curve

Returns:

the resulting 2D point in plain coordinates

Return type:

PlainPoint2D

py_ecc.secp256k1.secp256k1.bytes_to_int(x: bytes) int
py_ecc.secp256k1.secp256k1.deterministic_generate_k(msghash: bytes, priv: bytes) int

Generate a deterministic value k for use in ECDSA signature generation, as described in RFC 6979. The generated k value is intended to provide protection against weak random number generation. https://datatracker.ietf.org/doc/html/rfc6979

Parameters:
  • msghash (bytes) – The hash of the message to be signed.

  • priv (bytes) – The private key to be used in the signature.

Returns:

A deterministic value k (as an int) that can be used as the ephemeral private key in the signature generation process.

Return type:

int

py_ecc.secp256k1.secp256k1.ecdsa_raw_recover(msghash: bytes, vrs: Tuple[int, int, int]) PlainPoint2D

Recover the public key from the signature and message hash.

Parameters:
  • msghash (bytes) – the hash of the message to be signed

  • vrs (Tuple[int, int, int]) – the signature generated by the ecdsa_raw_sign function

Returns:

the recovered public key

Return type:

PlainPoint2D

py_ecc.secp256k1.secp256k1.ecdsa_raw_sign(msghash: bytes, priv: bytes) Tuple[int, int, int]

Return a raw ECDSA signature of the provided data, using the provided private_key.

Parameters:
  • msghash (bytes) – the data to sign

  • priv (bytes) – the private key to use for signing

Returns:

a tuple of integers (v, r, s), representing the raw ECDSA signature

Return type:

Tuple[int, int, int]

py_ecc.secp256k1.secp256k1.from_jacobian(p: PlainPoint3D) PlainPoint2D

Convert a Jacobian point back to its corresponding 2D point representation.

Parameters:

p (PlainPoint3D) – the point to convert

Returns:

the 2D point representation

Return type:

PlainPoint2D

py_ecc.secp256k1.secp256k1.inv(a: int, n: int) int
py_ecc.secp256k1.secp256k1.jacobian_add(p: PlainPoint3D, q: PlainPoint3D) PlainPoint3D

Add two points in Jacobian coordinates and return the result.

Parameters:
  • p (PlainPoint3D) – the first point to add

  • q (PlainPoint3D) – the second point to add

Returns:

the resulting Jacobian point

Return type:

PlainPoint3D

py_ecc.secp256k1.secp256k1.jacobian_double(p: PlainPoint3D) PlainPoint3D

Double a point in Jacobian coordinates and return the result.

Parameters:

p (PlainPoint3D) – the point to double

Returns:

the resulting Jacobian point

Return type:

PlainPoint3D

py_ecc.secp256k1.secp256k1.jacobian_multiply(a: PlainPoint3D, n: int) PlainPoint3D

Multiply a point in Jacobian coordinates by an integer and return the result.

Parameters:
  • a (PlainPoint3D) – the point to multiply

  • n (int) – the integer to multiply the point by

Returns:

the resulting Jacobian point

Return type:

PlainPoint3D

py_ecc.secp256k1.secp256k1.multiply(a: PlainPoint2D, n: int) PlainPoint2D

Multiply a 2D point a by an integer n using elliptic curve point multiplication, and return the resulting 2D point in plain coordinates.

Parameters:
  • a (PlainPoint2D) – a 2D point on the elliptic curve

  • n (int) – an integer used for point multiplication

Returns:

the resulting 2D point in plain coordinates

Return type:

PlainPoint2D

py_ecc.secp256k1.secp256k1.privtopub(privkey: bytes) PlainPoint2D
py_ecc.secp256k1.secp256k1.safe_ord(value: Any) int
py_ecc.secp256k1.secp256k1.to_jacobian(p: PlainPoint2D) PlainPoint3D

Convert a 2D point to its corresponding Jacobian point representation.

Parameters:

p (PlainPoint2D) – the point to convert

Returns:

the Jacobian point representation

Return type:

PlainPoint3D

Module contents