mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Changed the message format to store the author and group inline - this
doesn't take a huge amount of space and allows every message to be self-certifying.
This commit is contained in:
12
api/net/sf/briar/api/protocol/Author.java
Normal file
12
api/net/sf/briar/api/protocol/Author.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import net.sf.briar.api.serial.Writable;
|
||||
|
||||
public interface Author extends Writable {
|
||||
|
||||
AuthorId getId();
|
||||
|
||||
String getName();
|
||||
|
||||
byte[] getPublicKey();
|
||||
}
|
||||
10
api/net/sf/briar/api/protocol/AuthorFactory.java
Normal file
10
api/net/sf/briar/api/protocol/AuthorFactory.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface AuthorFactory {
|
||||
|
||||
Author createAuthor(String name, byte[] publicKey) throws IOException;
|
||||
|
||||
Author createAuthor(AuthorId id, String name, byte[] publicKey);
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import net.sf.briar.api.serial.Writer;
|
||||
/** Type-safe wrapper for a byte array that uniquely identifies an author. */
|
||||
public class AuthorId extends UniqueId {
|
||||
|
||||
/** Used to indicate that a message is anonymous. */
|
||||
public static final AuthorId NONE = new AuthorId(new byte[UniqueId.LENGTH]);
|
||||
|
||||
public AuthorId(byte[] id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package net.sf.briar.api.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface GroupFactory {
|
||||
|
||||
Group createGroup(String name, byte[] publicKey) throws IOException;
|
||||
|
||||
Group createGroup(GroupId id, String name, byte[] publicKey);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@ package net.sf.briar.api.protocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.security.KeyPair;
|
||||
import java.security.PrivateKey;
|
||||
|
||||
public interface MessageEncoder {
|
||||
|
||||
Message encodeMessage(MessageId parent, GroupId group, String nick,
|
||||
KeyPair keyPair, byte[] body) throws IOException,
|
||||
Message encodeMessage(MessageId parent, Group group, byte[] body)
|
||||
throws IOException;
|
||||
|
||||
Message encodeMessage(MessageId parent, Group group, Author author,
|
||||
PrivateKey privateKey, byte[] body) throws IOException,
|
||||
GeneralSecurityException;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@ import net.sf.briar.api.serial.Writer;
|
||||
public class MessageId extends UniqueId {
|
||||
|
||||
/** Used to indicate that the first message in a thread has no parent. */
|
||||
public static final MessageId NONE = new MessageId(new byte[] {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
});
|
||||
public static final MessageId NONE =
|
||||
new MessageId(new byte[UniqueId.LENGTH]);
|
||||
|
||||
public MessageId(byte[] id) {
|
||||
super(id);
|
||||
|
||||
@@ -8,13 +8,14 @@ package net.sf.briar.api.protocol;
|
||||
public interface Tags {
|
||||
|
||||
static final int ACK = 0;
|
||||
static final int AUTHOR_ID = 1;
|
||||
static final int BATCH = 2;
|
||||
static final int BATCH_ID = 3;
|
||||
static final int GROUP = 4;
|
||||
static final int GROUP_ID = 5;
|
||||
static final int MESSAGE = 6;
|
||||
static final int MESSAGE_ID = 7;
|
||||
static final int SUBSCRIPTIONS = 8;
|
||||
static final int TRANSPORTS = 9;
|
||||
static final int AUTHOR = 1;
|
||||
static final int AUTHOR_ID = 2;
|
||||
static final int BATCH = 3;
|
||||
static final int BATCH_ID = 4;
|
||||
static final int GROUP = 5;
|
||||
static final int GROUP_ID = 6;
|
||||
static final int MESSAGE = 7;
|
||||
static final int MESSAGE_ID = 8;
|
||||
static final int SUBSCRIPTIONS = 9;
|
||||
static final int TRANSPORTS = 10;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user