From ea6a3b293c1457c5b9873f35813f9aefda3adacc Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Sat, 7 Sep 2019 14:03:32 -0400 Subject: [PATCH 1/3] add explicit comments for int_to_bytes and bytes_to_int --- specs/core/0_beacon-chain.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 96e76c9ce..8bee6072c 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -560,6 +560,8 @@ def xor(bytes_1: Bytes32, bytes_2: Bytes32) -> Bytes32: def int_to_bytes(n: uint64, length: uint64) -> bytes: """ Return the ``length``-byte serialization of ``n``. + ``n.to_bytes(length, endianness)`` returns ``n`` in endianness-endian bytes padded out to length bytes. + """ return n.to_bytes(length, ENDIANNESS) ``` @@ -570,6 +572,7 @@ def int_to_bytes(n: uint64, length: uint64) -> bytes: def bytes_to_int(data: bytes) -> uint64: """ Return the integer deserialization of ``data``. + ``n.to_bytes(data, endianness)`` returns ``data`` as in integer intepretted in endianness-endian. """ return int.from_bytes(data, ENDIANNESS) ``` From 9582814c62412c43261501ad1fc409613d291a9a Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 16 Sep 2019 09:58:09 -0500 Subject: [PATCH 2/3] clarify endianness --- specs/core/0_beacon-chain.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 8bee6072c..dfb7fbdb6 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -559,9 +559,7 @@ def xor(bytes_1: Bytes32, bytes_2: Bytes32) -> Bytes32: ```python def int_to_bytes(n: uint64, length: uint64) -> bytes: """ - Return the ``length``-byte serialization of ``n``. - ``n.to_bytes(length, endianness)`` returns ``n`` in endianness-endian bytes padded out to length bytes. - + Return the ``length``-byte serialization of ``n`` in ``ENDIANNESS``-endian. """ return n.to_bytes(length, ENDIANNESS) ``` @@ -571,8 +569,7 @@ def int_to_bytes(n: uint64, length: uint64) -> bytes: ```python def bytes_to_int(data: bytes) -> uint64: """ - Return the integer deserialization of ``data``. - ``n.to_bytes(data, endianness)`` returns ``data`` as in integer intepretted in endianness-endian. + Return the integer deserialization of ``data`` intepretted as ``ENDIANNESS``-endian. """ return int.from_bytes(data, ENDIANNESS) ``` From 257fcd9c7908ad8a6cdcbd1c318fe1d37748ae5a Mon Sep 17 00:00:00 2001 From: Diederik Loerakker Date: Mon, 28 Oct 2019 08:29:01 +0100 Subject: [PATCH 3/3] typo --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index dfb7fbdb6..655775d22 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -569,7 +569,7 @@ def int_to_bytes(n: uint64, length: uint64) -> bytes: ```python def bytes_to_int(data: bytes) -> uint64: """ - Return the integer deserialization of ``data`` intepretted as ``ENDIANNESS``-endian. + Return the integer deserialization of ``data`` intepreted as ``ENDIANNESS``-endian. """ return int.from_bytes(data, ENDIANNESS) ```