-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- feature: galxe add desktop validation (#301)
* WIP * - feature: added galxe validation page * - refactor: installation validation workflow * - fix: backend url * - fix: toast error
- Loading branch information
1 parent
55cf3ce
commit a58a258
Showing
11 changed files
with
464 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::galxe; | ||
|
||
#[tauri::command] | ||
pub fn galxe_generate_desktop_installation_proof() -> Result<(String, String), String> { | ||
galxe::generate_desktop_installation_proof() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod shinkai_node_manager_commands; | ||
pub mod hardware; | ||
pub mod hardware; | ||
pub mod galxe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use blake3::Hasher; | ||
use ed25519_dalek::{Signer, SigningKey, VerifyingKey}; | ||
|
||
pub fn unsafe_deterministic_signature_keypair(n: u32) -> (SigningKey, VerifyingKey) { | ||
let mut hasher = blake3::Hasher::new(); | ||
hasher.update(&n.to_le_bytes()); | ||
let hash = hasher.finalize(); | ||
|
||
let secret_key = SigningKey::from_bytes(hash.as_bytes()); | ||
let public_key = VerifyingKey::from(&secret_key); | ||
(secret_key, public_key) | ||
} | ||
|
||
pub fn generate_desktop_installation_proof() -> Result<(String, String), String> { | ||
let secret_desktop_key: &str = option_env!("SECRET_DESKTOP_INSTALLATION_PROOF_KEY").unwrap_or("Dc9{3R9JmXe7£w9Fs](7"); | ||
let (secret_key, public_key) = unsafe_deterministic_signature_keypair(42); | ||
// Convert the public key to hex | ||
let public_key_hex = hex::encode(public_key.to_bytes()); | ||
|
||
// Combine the public key hex and the secret desktop key | ||
let combined = format!("{}{}", public_key_hex, secret_desktop_key); | ||
|
||
// Hash the combined value and take the last 4 characters | ||
let mut hasher = Hasher::new(); | ||
hasher.update(combined.as_bytes()); | ||
let hash_result = hasher.finalize(); | ||
let hash_str = hex::encode(hash_result.as_bytes()); | ||
let last_8_chars = &hash_str[hash_str.len() - 8..]; | ||
|
||
// Concatenate the public key hex with the last 4 characters using ::: | ||
let concatenated = format!("{}:::{}", public_key_hex, last_8_chars); | ||
|
||
// Hash the concatenated string | ||
let mut hasher = Hasher::new(); | ||
hasher.update(concatenated.as_bytes()); | ||
let final_hash_result = hasher.finalize(); | ||
let final_hash_bytes = final_hash_result.as_bytes(); | ||
|
||
// Sign the final hash | ||
let signature = secret_key.sign(final_hash_bytes); | ||
|
||
// Return the signature as a hexadecimal string and the concatenated string | ||
Ok((hex::encode(signature.to_bytes()), concatenated)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.