Пример #1
0
async def sign_message(ctx, msg):
    await require_confirm_sign_message(ctx, msg.message)

    address_n = msg.address_n or ()
    node = await seed.derive_node(ctx, address_n)

    signature = secp256k1.sign(node.private_key(), message_digest(msg.message),
                               False)

    sig = EthereumMessageSignature()
    sig.address = node.ethereum_pubkeyhash()
    sig.signature = signature[1:] + bytearray([signature[0]])
    return sig
Пример #2
0
async def ethereum_sign_message(ctx, msg):
    from trezor.messages.EthereumMessageSignature import EthereumMessageSignature
    from trezor.crypto.curve import secp256k1
    from ..common import seed

    address_n = msg.address_n or ()
    node = await seed.derive_node(ctx, address_n)

    signature = secp256k1.sign(node.private_key(), message_digest(msg.message), False)

    sig = EthereumMessageSignature()
    sig.address = node.ethereum_pubkeyhash()
    sig.signature = signature[1:] + bytearray([signature[0]])
    return sig
Пример #3
0
async def sign_message(ctx, msg, keychain):
    await paths.validate_path(ctx, keychain, msg.address_n)
    await require_confirm_sign_message(ctx, "ETH", msg.message)

    node = keychain.derive(msg.address_n)
    signature = secp256k1.sign(
        node.private_key(),
        message_digest(msg.message),
        False,
        secp256k1.CANONICAL_SIG_ETHEREUM,
    )

    sig = EthereumMessageSignature()
    sig.address = address.address_from_bytes(node.ethereum_pubkeyhash())
    sig.signature = signature[1:] + bytearray([signature[0]])
    return sig
Пример #4
0
async def sign_message(ctx, msg):
    await paths.validate_path(ctx, validate_full_path, path=msg.address_n)
    await require_confirm_sign_message(ctx, msg.message)

    node = await seed.derive_node(ctx, msg.address_n)

    signature = secp256k1.sign(
        node.private_key(),
        message_digest(msg.message),
        False,
        secp256k1.CANONICAL_SIG_ETHEREUM,
    )

    sig = EthereumMessageSignature()
    sig.address = node.ethereum_pubkeyhash()
    sig.signature = signature[1:] + bytearray([signature[0]])
    return sig