net.i2p.data
Class RoutingKeyGenerator
java.lang.Object
net.i2p.data.RoutingKeyGenerator
public class RoutingKeyGenerator
- extends java.lang.Object
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!
Method Summary |
void |
generateDateBasedModData()
Update the current modifier data with some bytes derived from the current
date (yyyyMMdd in GMT) |
static RoutingKeyGenerator |
getInstance()
|
byte[] |
getModData()
|
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, *then*
This makes Sybil's job a lot harder, as she needs to essentially take over the
whole keyspace. |
static void |
main(java.lang.String[] args)
|
void |
setModData(byte[] modData)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RoutingKeyGenerator
public RoutingKeyGenerator(I2PAppContext context)
getInstance
public static RoutingKeyGenerator getInstance()
getModData
public byte[] getModData()
setModData
public void setModData(byte[] modData)
generateDateBasedModData
public void generateDateBasedModData()
- Update the current modifier data with some bytes derived from the current
date (yyyyMMdd in GMT)
getRoutingKey
public 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, *then*
This makes Sybil's job a lot harder, as she needs to essentially take over the
whole keyspace.
- Throws:
java.lang.IllegalArgumentException
- if origKey is null
main
public static void main(java.lang.String[] args)