Skip to content

Signature

Meheret Tesfaye edited this page Jul 15, 2020 · 12 revisions

Sign message

sign() - Sign message by private key.

Parameter

private_key (str) - Bytom private key. [required]
message (str) - Message data. [required]

Return

signature (str) - Signed message data.

>>> from pybytom.signature import sign
>>> private_key = "e07af52746e7cccd0a7d1fba6651a6f474bada481f34b1c5bab5e2d71e36ee515803ee0a6682fb19e279d8f4f7acebee8abd0fc74771c71565f9a9643fd77141"
>>> message = "1246b84985e1ab5f83f4ec2bdf271114666fd3d9e24d12981a3c861b9ed523c6"
>>> sign(private_key=private_key, message=message)
"f6624fea84fadccbc1bc72dc384f662468e271c4e32d846bc0a1524470549992c8ffcc3ca43891a30de4235392b0868c506ed254f0f77cc1f2b9c1a2385ddb05"

Verify signature

verify() - Verify signed message (signature) by public key.

Parameter

public_key (str) - Bytom public key. [required]
message (str) - Message data. [required]
signature (str) - Signed message data. [required]

Return

verified (bool) - Verified True/False.

>>> from pybytom.signature import verify
>>> public_key = "91ff7f525ff40874c4f47f0cab42e46e3bf53adad59adef9558ad1b6448f22e2"
>>> message = "1246b84985e1ab5f83f4ec2bdf271114666fd3d9e24d12981a3c861b9ed523c6"
>>> signature = "f6624fea84fadccbc1bc72dc384f662468e271c4e32d846bc0a1524470549992c8ffcc3ca43891a30de4235392b0868c506ed254f0f77cc1f2b9c1a2385ddb05"
>>> verify(public_key=public_key, message=message, signature=signature)
True