Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.i2p.data
Class RoutingKeyGenerator

    java.lang.Object
      net.i2p.data.RoutingKeyGenerator

    public class RoutingKeyGenerator

extends 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!

Constructor Summary
`RoutingKeyGenerator(I2PAppContext context)`

Method Summary
`void` | `generateDateBasedModData()` Update the current modifier data with some bytes derived from the current date (yyyyMMdd in GMT)
`static RoutingKeyGenerator` | `getInstance()`
`long` | `getLastChanged()`
`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(String[] args)`
`void` | `setModData(byte[] modData)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RoutingKeyGenerator

    public RoutingKeyGenerator(I2PAppContext context)

Method Detail

### getInstance

    public static RoutingKeyGenerator getInstance()

### getModData

    public byte[] getModData()

### getLastChanged

    public long getLastChanged()

### 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:
    `IllegalArgumentException` - if origKey is null

### main

    public static void main(String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD