community: the soulseek link proof, one message to yourself links the account and one question links anyone who answers

This commit is contained in:
KeelrLeek committed 2026-09-02 14:27:54 -05:00
1 parent cf9558cf26
commit 6ed6f5b8f8
10 files changed
+1156 -593

No files matched your search

+9 -2
View File
@@ -15,6 +15,8 @@
use ed25519_dalek::{Signature, Verifier, VerifyingKey};
use serde::{Deserialize, Serialize};
pub mod slsk_link;
pub const SCHEMA_VERSION: u32 = 1;
pub const SIGN_DOMAIN: &str = "soulstream.profile/v1";
@@ -76,7 +78,7 @@ pub fn profile_sign_payload(p: &ProfileState) -> Vec<u8> {
.expect("serializes")
}
fn signable(domain: &str, payload: &[u8]) -> Vec<u8> {
pub(crate) fn signable(domain: &str, payload: &[u8]) -> Vec<u8> {
let mut msg = Vec::new();
msg.extend_from_slice(b"soulstream.sig.v1");
msg.push(0);
@@ -87,9 +89,14 @@ fn signable(domain: &str, payload: &[u8]) -> Vec<u8> {
}
pub fn verify_sig(public: &[u8; 32], payload: &[u8], sig: &[u8]) -> bool {
verify_sig_in(SIGN_DOMAIN, public, payload, sig)
}
/// The same check under an explicit domain — the link and friend families.
pub fn verify_sig_in(domain: &str, public: &[u8; 32], payload: &[u8], sig: &[u8]) -> bool {
let Ok(vk) = VerifyingKey::from_bytes(public) else { return false };
let Ok(sig) = Signature::from_slice(sig) else { return false };
vk.verify(&signable(SIGN_DOMAIN, payload), &sig).is_ok()
vk.verify(&signable(domain, payload), &sig).is_ok()
}
pub fn make_profile_params(owner: &[u8; 32]) -> Vec<u8> {