Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Started forking the moonlight protocol leveraging Solana's ed25519 ke…
…ypairs by mapping them to x25519 keypairs and using them to encrypt the PIN and transmit it directly at pair http request.

Waiting to have the Solana Shaga Program & Session PDAs ready to start testing the connection.

Then, we'll implement a MapUI if everything works fine.
  • Loading branch information
chat-grp committed Sep 29, 2023
commit ff610baf13683423aa154632aac18cff471098cf
7 changes: 7 additions & 0 deletions app/src/main/java/com/limelight/nvstream/http/NvHTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,13 @@ public LinkedList<NvApp> getAppList() throws HostHttpResponseException, IOExcept
}
}

//Shaga
String executeShagaPairingCommand(String additionalArguments, boolean enableReadTimeout) throws HostHttpResponseException, IOException {
return openHttpConnectionToString(enableReadTimeout ? httpClientLongConnectTimeout : httpClientLongConnectNoReadTimeout,
baseUrlHttp, "pairShaga", "devicename=roth&updateState=1&" + additionalArguments);
}


String executePairingCommand(String additionalArguments, boolean enableReadTimeout) throws HostHttpResponseException, IOException {
return openHttpConnectionToString(enableReadTimeout ? httpClientLongConnectTimeout : httpClientLongConnectNoReadTimeout,
baseUrlHttp, "pair", "devicename=roth&updateState=1&" + additionalArguments);
Expand Down
16 changes: 11 additions & 5 deletions app/src/main/java/com/limelight/nvstream/http/PairingManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.limelight.nvstream.http;

import org.bitcoinj.core.Base58;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.engines.AESLightEngine;
import org.bouncycastle.crypto.params.KeyParameter;
Expand All @@ -17,6 +18,7 @@

import com.limelight.solanaWallet.EncryptionHelper;
import com.limelight.solanaWallet.SolanaPreferenceManager;
import com.solana.core.PublicKey;

public class PairingManager {

Expand Down Expand Up @@ -181,12 +183,11 @@ public PairState pairShaga(String serverInfo, String pin, byte[] x25519PublicKey
PairingHashAlgorithm hashAlgo;

int serverMajorVersion = http.getServerMajorVersion(serverInfo);
LimeLog.info("Pairing with server generation: "+serverMajorVersion);
LimeLog.info("Pairing with server generation: " + serverMajorVersion);
if (serverMajorVersion >= 7) {
// Gen 7+ uses SHA-256 hashing
hashAlgo = new Sha256PairingHash();
}
else {
} else {
// Prior to Gen 7, SHA-1 is used
hashAlgo = new Sha1PairingHash();
}
Expand All @@ -197,6 +198,7 @@ public PairState pairShaga(String serverInfo, String pin, byte[] x25519PublicKey
// Handle the error. Maybe log it or show a user message.
return PairState.FAILED;
}

// Convert Ed25519 private key to X25519 private key
byte[] x25519PrivateKey = EncryptionHelper.mapSecretEd25519ToX25519(ed25519PrivateKey);
// Generate a salt for hashing the PIN
Expand All @@ -208,9 +210,13 @@ public PairState pairShaga(String serverInfo, String pin, byte[] x25519PublicKey
// Convert encrypted PIN to hex
String hexEncryptedPin = bytesToHex(encryptedPin);
// Make the HTTP request to pair with the server, sending the salt and the encrypted PIN
String getCert = http.executePairingCommand("phrase=getservercert&salt=" +
PublicKey publicKey = SolanaPreferenceManager.getStoredPublicKey();
assert publicKey != null;
String publicKeyBase58 = publicKey.toBase58();

String getCert = http.executeShagaPairingCommand("phrase=getservercert&salt=" +
bytesToHex(salt) + "&clientcert=" + bytesToHex(pemCertBytes) +
"&encryptedPin=" + hexEncryptedPin,
"&encryptedPin=" + hexEncryptedPin + "&publicKey=" + publicKeyBase58,
false);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,35 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_pc_view);
}
}

/*
Step 4: Fetch Available Sessions
Use the RPC call getProgramAccounts to fetch the list of active sessions from the Sunshine server. The Program ID is essential here to filter out accounts owned by your Sunshine program.

javascript
Copy code
const connection = new solanaWeb3.Connection(
solanaWeb3.clusterApiUrl("devnet") // or testnet or mainnet
);

const PROGRAM_ID = new solanaWeb3.PublicKey("YourShagaProgramIDHere");

const fetchedSessions = await connection.getProgramAccounts(PROGRAM_ID, {
filters: [
// Your filters here
]
});
Step 5: Filter and Display Sessions
Once you receive the list of available sessions, you can filter and display them based on your needs (e.g., by IP Address, CPU Name, etc.).

Step 6: Join a Session
To join a session, you will likely send a transaction to the Solana blockchain, interacting with your Sunshine program. This transaction will contain the necessary instructions and accounts to process the session joining logic.

Here's a high-level outline:

Define Program ID: Know the Program ID of your deployed smart contract.
Solana SDK: Integrate Solana SDK into the Moonlight client.
Initialize Connection: Connect to Solana's network and specify the Program ID.
Fetch Sessions: Use getProgramAccounts to fetch active sessions.
Display Sessions: Show the
*/