This is not true. I generated two hallmarks with different dates and both are valid
Is there such possibility CfB?
Only if there is a bug in software. Let's check together:
boolean analyzeHallmark(String realHost, String hallmark) {
if (hallmark == null) {
return true;
}
try {
byte[] hallmarkBytes = convert(hallmark);
ByteBuffer buffer = ByteBuffer.wrap(hallmarkBytes);
buffer.order(ByteOrder.LITTLE_ENDIAN);
byte[] publicKey = new byte[32];
buffer.get(publicKey);
int hostLength = buffer.getShort();
byte[] hostBytes = new byte[hostLength];
buffer.get(hostBytes);
String host = new String(hostBytes, "UTF-8");
if (host.length() > 100 || !host.equals(realHost)) {
return false;
}
int weight = buffer.getInt();
if (weight <= 0 || weight > 1000000000) {
return false;
}
int date = buffer.getInt();
buffer.get();
byte[] signature = new byte[64];
buffer.get(signature);
byte[] data = new byte[hallmarkBytes.length - 64];
System.arraycopy(hallmarkBytes, 0, data, 0, data.length);
if (Crypto.verify(signature, data, publicKey)) {
this.hallmark = hallmark;
long accountId = Account.getId(publicKey);
Account account = accounts.get(accountId);
if (account == null) {
return false;
}
LinkedList
groupedPeers = new LinkedList<>();
int validDate = 0;
synchronized (peers) {
this.accountId = accountId;
this.weight = weight;
this.date = date;
for (Peer peer : peers.values()) {
if (peer.accountId == accountId) {
groupedPeers.add(peer);
if (peer.date > validDate) {
validDate = peer.date;
}
}
}
long totalWeight = 0;
for (Peer peer : groupedPeers) {
if (peer.date == validDate) {
totalWeight += peer.weight;
} else {
peer.adjustedWeight = 0;
peer.updateWeight();
}
}
for (Peer peer : groupedPeers) {
peer.adjustedWeight = 1000000000L * peer.weight / totalWeight;
peer.updateWeight();
}
}
return true;
}
} catch (Exception e) { }
return false;
}