Package net.i2p.data

Class EncryptedLeaseSet

  • All Implemented Interfaces:
    Serializable, DataStructure

    public class EncryptedLeaseSet
    extends LeaseSet2
    Use getSigningKey() / setSigningKey() (revocation key in super) for the blinded key. PRELIMINARY - Subject to change - see proposal 123
    Since:
    0.9.38
    See Also:
    Serialized Form
    • Constructor Detail

      • EncryptedLeaseSet

        public EncryptedLeaseSet()
    • Method Detail

      • getDecryptedLeaseSet

        public LeaseSet2 getDecryptedLeaseSet()
        Returns:
        leaseset or null if not decrypted.
        Since:
        0.9.39
      • setSecret

        public void setSecret​(String secret)
        Must be set before sign or verify. Must be called before setDestination() or setSigningKey(), or alpha will be wrong.
        Parameters:
        secret - null or "" for none (default)
        Since:
        0.9.39
      • setClientPrivateKey

        public void setClientPrivateKey​(PrivateKey privKey)
        Must be set before verify for per-client auth.
        Parameters:
        privKey - non-null
        Since:
        0.9.41
      • getType

        public int getType()
        Description copied from class: DatabaseEntry
        Get the type of the data structure. This should be faster than instanceof.
        Overrides:
        getType in class LeaseSet2
        Returns:
        KEY_TYPE_ROUTERINFO or KEY_TYPE_LEASESET or LS2 types
      • getLeaseCount

        public int getLeaseCount()
        Overrides:
        getLeaseCount in class LeaseSet
        Returns:
        0-16, or 0 if not decrypted.
      • getLease

        public Lease getLease​(int index)
        Overrides:
        getLease in class LeaseSet
        Returns:
        null if not decrypted.
      • getEncryptionKeys

        public List<PublicKey> getEncryptionKeys()
        Description copied from class: LeaseSet2
        This returns all the keys. getEncryptionKey() returns the first one. Encryption keys should be in order of server preference, most-preferred first. Client behavior should be to select the first key with a supported encryption type. Clients may use other selection algorithms based on encryption support, relative performance, and other factors.
        Overrides:
        getEncryptionKeys in class LeaseSet2
        Returns:
        null if not decrypted.
        Since:
        0.9.39
      • getEncryptionKey

        public PublicKey getEncryptionKey​(Set<EncType> supported)
        If more than one key, return the first supported one. If none supported, return null.
        Overrides:
        getEncryptionKey in class LeaseSet2
        Parameters:
        supported - what return types are allowed
        Returns:
        first supported key or null
        Since:
        0.9.44
      • setDestination

        public void setDestination​(Destination dest)
        Overridden to set the blinded key. setSecret() MUST be called before this for non-null secret, or alpha will be wrong.
        Overrides:
        setDestination in class LeaseSet
        Parameters:
        dest - non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
        Throws:
        IllegalStateException - if already signed
        IllegalArgumentException - if not EdDSA
      • setSigningKey

        public void setSigningKey​(SigningPublicKey spk)
        Overridden to set the blinded key. setSecret() MUST be called before this for non-null secret, or alpha will be wrong.
        Overrides:
        setSigningKey in class LeaseSet2
        Parameters:
        spk - unblinded key non-null, must be EdDSA_SHA512_Ed25519 or RedDSA_SHA512_Ed25519
        Throws:
        IllegalStateException - if already signed
        IllegalArgumentException - if not EdDSA
        Since:
        0.9.40
      • verifyOfflineSignature

        public boolean verifyOfflineSignature()
        Overridden because we have a blinded key, not a dest
        Overrides:
        verifyOfflineSignature in class LeaseSet2
      • size

        public int size()
        Number of bytes, NOT including signature
        Overrides:
        size in class LeaseSet2
      • getHash

        public Hash getHash()
        This must be used instead of getDestination().getHash(). Overridden because we have a blinded key, not a dest. This is the hash of the signing public key type and the signing public key. Throws IllegalStateException if not initialized.
        Overrides:
        getHash in class DatabaseEntry
        Returns:
        Hash or null
        Throws:
        IllegalStateException
      • encrypt

        public void encrypt​(int authType,
                            List<? extends SimpleDataStructure> clientKeys)
        Throws IllegalStateException if not initialized. Ref: proposal 123
        Parameters:
        authType - 0, 1, or 3, see BlindData
        clientKeys - The client's X25519 public or private keys, null if unused
        Throws:
        IllegalStateException
      • verifySignature

        public boolean verifySignature()
        Overridden to decrypt if possible, and verify inner sig also. Must call setDestination() prior to this if attempting decryption. Must call setClientKey() prior to this if attempting decryption.
        Overrides:
        verifySignature in class LeaseSet2
        Returns:
        valid
      • verifySignature

        public boolean verifySignature​(PrivateKey clientKey)
        Decrypt if possible, and verify inner sig also. Must call setDestination() prior to this if attempting decryption.
        Parameters:
        clientKey - PrivateKey for DH or PSK, or null if none
        Returns:
        valid
        Since:
        0.9.41
      • hashCode

        public int hashCode()
        the destination has enough randomness in it to use it by itself for speed
        Overrides:
        hashCode in class LeaseSet2