From fbd0be941a140a75976d789b58418b4196423e50 Mon Sep 17 00:00:00 2001
From: zzz <zzz@i2pmail.org>
Date: Fri, 21 Feb 2025 09:05:55 -0500
Subject: [PATCH] Client: Deprecate getters for unused encryption private key

---
 core/java/src/net/i2p/client/I2PSession.java          | 3 ++-
 core/java/src/net/i2p/client/impl/I2PSessionImpl.java | 4 +++-
 core/java/src/net/i2p/client/impl/SubSession.java     | 4 ++--
 core/java/src/net/i2p/data/PrivateKeyFile.java        | 2 ++
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/core/java/src/net/i2p/client/I2PSession.java b/core/java/src/net/i2p/client/I2PSession.java
index 981d2dc333..1982563ba6 100644
--- a/core/java/src/net/i2p/client/I2PSession.java
+++ b/core/java/src/net/i2p/client/I2PSession.java
@@ -298,8 +298,9 @@ public interface I2PSession {
 
     /**
      * Retrieve the decryption PrivateKey associated with the Destination
-     *
+     * @deprecated this key is unused
      */
+    @Deprecated
     public PrivateKey getDecryptionKey();
 
     /**
diff --git a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java
index d5a9c2d128..ec334fdb77 100644
--- a/core/java/src/net/i2p/client/impl/I2PSessionImpl.java
+++ b/core/java/src/net/i2p/client/impl/I2PSessionImpl.java
@@ -370,7 +370,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
                 throw new I2PSessionException("Subsession request already pending");
             sub = new SubSession(this, privateKeyStream, opts);
             for (SubSession ss : _subsessions) {
-                 if (ss.getDecryptionKey().equals(sub.getDecryptionKey()) &&
+                 if (/*  ss.getDecryptionKey().equals(sub.getDecryptionKey()) && */
                      ss.getPrivateKey().equals(sub.getPrivateKey())) {
                     throw new I2PSessionException("Dup subsession");
                 }
@@ -1145,7 +1145,9 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
 
     /**
      * Retrieve the decryption PrivateKey 
+     * @deprecated this key is unused
      */
+    @Deprecated
     public PrivateKey getDecryptionKey() { return _privateKey; }
 
     /**
diff --git a/core/java/src/net/i2p/client/impl/SubSession.java b/core/java/src/net/i2p/client/impl/SubSession.java
index 057c64cc4d..1474e57a69 100644
--- a/core/java/src/net/i2p/client/impl/SubSession.java
+++ b/core/java/src/net/i2p/client/impl/SubSession.java
@@ -47,8 +47,8 @@ class SubSession extends I2PSessionMuxedImpl {
     public SubSession(I2PSession primary, InputStream destKeyStream, Properties options) throws I2PSessionException {
         super((I2PSessionMuxedImpl)primary, destKeyStream, options);
         _primary = (I2PSessionMuxedImpl) primary;
-        if (!getDecryptionKey().equals(_primary.getDecryptionKey()))
-            throw new I2PSessionException("encryption key mismatch");
+        //if (!getDecryptionKey().equals(_primary.getDecryptionKey()))
+        //    throw new I2PSessionException("encryption key mismatch");
         if (getPrivateKey().equals(_primary.getPrivateKey()))
             throw new I2PSessionException("signing key must differ");
         // state management
diff --git a/core/java/src/net/i2p/data/PrivateKeyFile.java b/core/java/src/net/i2p/data/PrivateKeyFile.java
index d5c7aeef23..a03cca1ebc 100644
--- a/core/java/src/net/i2p/data/PrivateKeyFile.java
+++ b/core/java/src/net/i2p/data/PrivateKeyFile.java
@@ -824,7 +824,9 @@ public class PrivateKeyFile {
      *  Private key may be random data or all zeros for Destinations as of 0.9.57
      *
      *  @return null on error or if not initialized
+     *  @deprecated this key is unused
      */
+    @Deprecated
     public PrivateKey getPrivKey() {
         try {
             // call this to force initialization
-- 
GitLab