From 9379990480894a8f3c83edc7552e362711593d3c Mon Sep 17 00:00:00 2001 From: akwizgran <michael@briarproject.org> Date: Thu, 19 Apr 2018 13:13:31 +0100 Subject: [PATCH] Use block label for root hash of single-block messages. --- .../java/org/briarproject/bramble/api/sync/MessageId.java | 6 +++--- .../org/briarproject/bramble/sync/MessageFactoryImpl.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bramble-api/src/main/java/org/briarproject/bramble/api/sync/MessageId.java b/bramble-api/src/main/java/org/briarproject/bramble/api/sync/MessageId.java index 49523ffdaa..907b6e2d08 100644 --- a/bramble-api/src/main/java/org/briarproject/bramble/api/sync/MessageId.java +++ b/bramble-api/src/main/java/org/briarproject/bramble/api/sync/MessageId.java @@ -19,10 +19,10 @@ public class MessageId extends UniqueId { public static final String ID_LABEL = "org.briarproject.bramble/MESSAGE_ID"; /** - * Label for hashing the root blocks of messages. + * Label for hashing blocks of messages. */ - public static final String ROOT_LABEL = - "org.briarproject.bramble/MESSAGE_ROOT"; + public static final String BLOCK_LABEL = + "org.briarproject.bramble/MESSAGE_BLOCK"; public MessageId(byte[] id) { super(id); diff --git a/bramble-core/src/main/java/org/briarproject/bramble/sync/MessageFactoryImpl.java b/bramble-core/src/main/java/org/briarproject/bramble/sync/MessageFactoryImpl.java index 12814a45ed..7f92045fcb 100644 --- a/bramble-core/src/main/java/org/briarproject/bramble/sync/MessageFactoryImpl.java +++ b/bramble-core/src/main/java/org/briarproject/bramble/sync/MessageFactoryImpl.java @@ -13,8 +13,8 @@ import javax.annotation.concurrent.Immutable; import javax.inject.Inject; import static org.briarproject.bramble.api.sync.Message.FORMAT_VERSION; +import static org.briarproject.bramble.api.sync.MessageId.BLOCK_LABEL; import static org.briarproject.bramble.api.sync.MessageId.ID_LABEL; -import static org.briarproject.bramble.api.sync.MessageId.ROOT_LABEL; import static org.briarproject.bramble.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH; import static org.briarproject.bramble.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH; import static org.briarproject.bramble.util.ByteUtils.INT_64_BYTES; @@ -36,7 +36,7 @@ class MessageFactoryImpl implements MessageFactory { throw new IllegalArgumentException(); byte[] versionBytes = new byte[] {FORMAT_VERSION}; // There's only one block, so the root hash is the hash of the block - byte[] rootHash = crypto.hash(ROOT_LABEL, versionBytes, body); + byte[] rootHash = crypto.hash(BLOCK_LABEL, versionBytes, body); byte[] timeBytes = new byte[INT_64_BYTES]; ByteUtils.writeUint64(timestamp, timeBytes, 0); byte[] idHash = crypto.hash(ID_LABEL, versionBytes, g.getBytes(), -- GitLab