|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.data.RoutingKeyGenerator
net.i2p.data.router.RouterKeyGenerator
public class RouterKeyGenerator
Component to manage the munging of hashes into routing keys - given a hash, perform some consistent transformation against it and return the result. This transformation is fed by the current "mod data". Right now the mod data is the current date (GMT) as a string: "yyyyMMdd", and the transformation takes the original hash, appends the bytes of that mod data, then returns the SHA256 of that concatenation. Do we want this to simply do the XOR of the SHA256 of the current mod data and the key? does that provide the randomization we need? It'd save an SHA256 op. Bah, too much effort to think about for so little gain. Other algorithms may come into play layer on about making periodic updates to the routing key for data elements to mess with Sybil. This may be good enough though. Also - the method generateDateBasedModData() should be called after midnight GMT once per day to generate the correct routing keys!
Constructor Summary | |
---|---|
RouterKeyGenerator(I2PAppContext context)
|
Method Summary | |
---|---|
boolean |
generateDateBasedModData()
Update the current modifier data with some bytes derived from the current date (yyyyMMdd in GMT) |
long |
getLastChanged()
The version of the current (today's) mod data. |
byte[] |
getModData()
The current (today's) mod data. |
byte[] |
getNextModData()
Tomorrow's mod data. |
Hash |
getNextRoutingKey(Hash origKey)
Get the routing key using tomorrow's modData, not today's |
Hash |
getRoutingKey(Hash origKey)
Generate a modified (yet consistent) hash from the origKey by generating the SHA256 of the targetKey with the current modData appended to it This makes Sybil's job a lot harder, as she needs to essentially take over the whole keyspace. |
long |
getTimeTillMidnight()
How long until midnight (ms) |
Methods inherited from class net.i2p.data.RoutingKeyGenerator |
---|
getInstance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RouterKeyGenerator(I2PAppContext context)
Method Detail |
---|
public byte[] getModData()
public byte[] getNextModData()
public long getLastChanged()
RoutingKeyGenerator
getLastChanged
in class RoutingKeyGenerator
public long getTimeTillMidnight()
public boolean generateDateBasedModData()
public Hash getRoutingKey(Hash origKey)
getRoutingKey
in class RoutingKeyGenerator
IllegalArgumentException
- if origKey is nullpublic Hash getNextRoutingKey(Hash origKey)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |