fastecdsa

fastecdsa.ecdsa

fastecdsa.eddsa

fastecdsa.encoding.der

fastecdsa.encoding.pem

fastecdsa.encoding.sec1

fastecdsa.keys

fastecdsa.util

class fastecdsa.util.RFC6979(msg: bytes, x: int, q: int, hashfunc: Callable[[...], HASH], prehashed: bool = False)

Bases: object

Generate a nonce per RFC6979.

In order to avoid reusing a nonce with the same key when signing two different messages (which leaks the private key) RFC6979 provides a deterministic method for generating nonces. This is based on using a pseudo-random function (HMAC) to derive a nonce from the message and private key. More info here: http://tools.ietf.org/html/rfc6979.

Attributes:
msg (bytes): A message being signed.
x (int): An ECDSA private key.
q (int): The order of the generator point of the curve being used to sign the message.
hashfunc Callable[…, HASH]: The hash function used to compress the message.
prehashed (bool): Whether the signature is on a pre-hashed message.
gen_nonce() → int

http://tools.ietf.org/html/rfc6979#section-3.2

fastecdsa.util.mod_sqrt(a: int, p: int) → tuple[int, int]

Compute the square root of \(a \pmod{p}\)

In other words, find a value \(x\) such that \(x^2 \equiv a \pmod{p}\).

Args:
a (int): The value whose root to take.
p (int): The prime whose field to perform the square root in.
Returns:

(int, int): the two values of \(x\) satisfying \(x^2 \equiv a \pmod{p}\).