Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/btclib/obfuscation.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def obfuscate(data: Octets, key: Octets, offset: int = 0) -> bytes:
if not is_integer(offset):
raise BTClibTypeError(f"non-integer offset: {_message_text(offset)}")
if offset < 0:
raise BTClibValueError(f"negative offset: {offset}")
raise BTClibValueError(f"negative offset: {_message_text(offset)}")

shift = offset % KEY_SIZE
rotated = key[shift:] + key[:shift]
Expand Down
7 changes: 6 additions & 1 deletion tests/huge_int_message_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import pytest
from ecc.ecc import dsa

from btclib import base58, var_int
from btclib import base58, obfuscation, var_int
from btclib.alias import TaprootScriptTree
from btclib.b32 import bytes_from_witness_program, power_of_2_base_conversion
from btclib.block import Block, BlockHeader
Expand Down Expand Up @@ -146,6 +146,11 @@ def _reconstruct(index: int) -> object:
_HUGE,
lambda v: base58.decode(base58.encode(b"\x00" * 20), v),
),
(
"obfuscation offset",
-_HUGE,
lambda v: obfuscation.obfuscate(b"\x00", bytes(8), v),
),
(
"addrv2 network id without an ip",
_HUGE,
Expand Down
Loading