1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-06 14:52:33 +00:00
trezor-firmware/core/mocks/generated/trezorcrypto/nist256p1.py
matejcik 482b4569f5 build: fix and auto-generate mock files
Squashed commit of the following:

commit 84d3486f59bda063f06521c8b695ea4b07781ec6
Author: matejcik <ja@matejcik.cz>
Date:   Fri May 17 14:17:15 2019 +0200

    mocks: complete

commit d538133a6d0fb4af06c7c81f80b8675869fb5908
Author: matejcik <ja@matejcik.cz>
Date:   Fri May 17 14:12:26 2019 +0200

    mocks part 3

commit 9f0b868d41dafaf487df6fc844db7f3368eabe1b
Author: matejcik <ja@matejcik.cz>
Date:   Fri May 17 14:09:20 2019 +0200

    mocks: update generated mocks

commit 5d80c18a7824ed16fc11cde4cdb8ebca7ed33400
Author: matejcik <ja@matejcik.cz>
Date:   Thu May 16 15:49:40 2019 +0200

    mocks wip 2

commit 4b576eb796136a61eb88cb0d281fa4e21eadada8
Author: matejcik <ja@matejcik.cz>
Date:   Tue May 7 17:02:51 2019 +0200

    WIP mocks part 1

commit cf3f0d4471ab74b478d2970b0bb178feae7c86a3
Author: matejcik <ja@matejcik.cz>
Date:   Fri May 3 17:07:53 2019 +0200

    core: add package to secp256k1_zkp for mocking

commit 8a12f26c8c0d99363c8df96012426abbbb3ff6cb
Author: matejcik <ja@matejcik.cz>
Date:   Fri May 3 17:04:05 2019 +0200

    core: blackify extmod docstring quotes

commit b6f239676dde8b60b001fcae4e5de80a71dbacf2
Author: matejcik <ja@matejcik.cz>
Date:   Fri May 3 16:52:27 2019 +0200

    core: make build_mocks directory agnostic

mocks: detect bad packages

mocks: revert noqa in favor of setup.cfg

mocks: fix broken comment formatting
2019-05-17 15:45:47 +02:00

49 lines
1.3 KiB
Python

from typing import *
# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
def generate_secret() -> bytes:
"""
Generate secret key.
"""
# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
def publickey(secret_key: bytes, compressed: bool = True) -> bytes:
"""
Computes public key from secret key.
"""
# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
def sign(
secret_key: bytes, digest: bytes, compressed: bool = True
) -> bytes:
"""
Uses secret key to produce the signature of the digest.
"""
# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
def verify(public_key: bytes, signature: bytes, digest: bytes) -> bool:
"""
Uses public key to verify the signature of the digest.
Returns True on success.
"""
# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
def verify_recover(signature: bytes, digest: bytes) -> bytes:
"""
Uses signature of the digest to verify the digest and recover the public
key. Returns public key on success, None if the signature is invalid.
"""
# extmod/modtrezorcrypto/modtrezorcrypto-nist256p1.h
def multiply(secret_key: bytes, public_key: bytes) -> bytes:
"""
Multiplies point defined by public_key with scalar defined by
secret_key. Useful for ECDH.
"""