From f7397a5970819b2aaaf122a61901da499c65e582 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Mon, 4 Mar 2019 15:49:21 -0700 Subject: [PATCH] add xor def --- specs/core/0_beacon-chain.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index a0cbb063f..5f50b67ca 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -53,6 +53,7 @@ - [`Eth1DataVote`](#eth1datavote) - [Custom Types](#custom-types) - [Helper functions](#helper-functions) + - [`xor`](#xor) - [`hash`](#hash) - [`hash_tree_root`](#hash_tree_root) - [`signed_root`](#signed_root) @@ -652,6 +653,13 @@ We define the following Python custom types for type hinting and readability: Note: The definitions below are for specification purposes and are not necessarily optimal implementations. +### `xor` + +```python +def xor(bytes1: Bytes32, bytes2: Bytes32) -> Bytes32: + return bytes(a ^ b for a, b in zip(bytes1, bytes2)) +``` + ### `hash` The hash function is denoted by `hash`. In Phase 0 the beacon chain is deployed with the same hash function as Ethereum 1.0, i.e. Keccak-256 (also incorrectly known as SHA3).