net.i2p.router.networkdb.kademlia

## Class BlindCache

- java.lang.Object
- - net.i2p.router.networkdb.kademlia.BlindCache

-     class BlindCache
      extends Object

  Cache for blinding data as specified in I2P proposal 123.

  Manages blinded and unblinded key mappings with persistent storage and automatic rollover at midnight UTC. Provides lookup operations for both blinded destinations and their corresponding unblinded hashes.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BlindCache(RouterContext ctx)` Caller MUST call startup() to load persistent cache from disk

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addToCache(BlindData bd)` Persists immediately if secret or privkey is non-null
    `Hash` | `getBlindedHash(Destination dest)` The hash to lookup for a dest.
    `Hash` | `getBlindedHash(SigningPublicKey spk)` The hash to lookup for a SPK known to be blinded.
    `List<BlindData>` | `getData()` For console ConfigKeyringHelper
    `BlindData` | `getData(Destination dest)` The cached data or null
    `BlindData` | `getData(SigningPublicKey spk)` The cached data or null
    `Hash` | `getHash(Destination dest)` The hash to lookup for a dest.
    `Hash` | `getHash(Hash h)` The hash to lookup for a dest hash.
    `BlindData` | `getReverseData(SigningPublicKey spk)` The cached data or null
    `boolean` | `removeBlindData(SigningPublicKey spk)` For console ConfigKeyringHelper.
    `void` | `rollover()` Refresh all the data at midnight
    `void` | `setBlinded(Destination dest)` Add the destination to the cache entry.
    `void` | `setBlinded(Destination dest, SigType blindedType, String secret)` Mark a destination as known to be blinded
    `void` | `shutdown()` May be restarted by calling startup() again.
    `void` | `startup()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### BlindCache

          public BlindCache(RouterContext ctx)

      Caller MUST call startup() to load persistent cache from disk

  - ### Method Detail

    - #### addToCache

          public void addToCache(BlindData bd)

      Persists immediately if secret or privkey is non-null

    - #### getBlindedHash

          public Hash getBlindedHash(Destination dest)

      The hash to lookup for a dest. If known to be blinded, returns the current blinded hash. If not known to be blinded, returns null.
      Parameters:
        `dest` - may or may not be blinded
      Returns:
        the blinded hash or null if not blinded

    - #### getBlindedHash

          public Hash getBlindedHash(SigningPublicKey spk)

      The hash to lookup for a SPK known to be blinded. Default blinded type assumed. Secret assumed null.
      Parameters:
        `spk` - known to be blinded
      Returns:
        the blinded hash
      Throws:
        `IllegalArgumentException` - on various errors

    - #### getData

          public List<BlindData> getData()

      For console ConfigKeyringHelper
      Returns:
        list is copied

    - #### getData

          public BlindData getData(Destination dest)

      The cached data or null

    - #### getData

          public BlindData getData(SigningPublicKey spk)

      The cached data or null
      Parameters:
        `spk` - the unblinded public key

    - #### getHash

          public Hash getHash(Destination dest)

      The hash to lookup for a dest. If known to be blinded, returns the current blinded hash. If not known to be blinded, returns the standard dest hash.
      Parameters:
        `dest` - may or may not be blinded
      Returns:
        the unblinded or blinded hash

    - #### getHash

          public Hash getHash(Hash h)

      The hash to lookup for a dest hash. If known to be blinded, returns the current blinded hash. If not known to be blinded, returns h.
      Parameters:
        `h` - may or may not be blinded
      Returns:
        the blinded hash or h

    - #### getReverseData

          public BlindData getReverseData(SigningPublicKey spk)

      The cached data or null
      Parameters:
        `spk` - the blinded public key

    - #### removeBlindData

          public boolean removeBlindData(SigningPublicKey spk)

      For console ConfigKeyringHelper. Persists immediately if removed.
      Parameters:
        `spk` - the unblinded public key
      Returns:
        true if removed

    - #### rollover

          public void rollover()

      Refresh all the data at midnight

    - #### setBlinded

          public void setBlinded(Destination dest)

      Add the destination to the cache entry. Must previously be in cache.
      Parameters:
        `dest` - known to be blinded
      Throws:
        `IllegalArgumentException` - on various errors

    - #### setBlinded

          public void setBlinded(Destination dest,
                                 SigType blindedType,
                                 String secret)

      Mark a destination as known to be blinded
      Parameters:
        `dest` - known to be blinded
        `blindedType` - null for default
        `secret` - may be null
      Throws:
        `IllegalArgumentException` - on various errors

    - #### shutdown

          public void shutdown()

      May be restarted by calling startup() again.

    - #### startup

          public void startup()