Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c77594f
fix(dashpay): use DPNS homograph-safe normalization for profile search
lklimek Apr 1, 2026
134c534
Merge remote-tracking branch 'origin/v1.0-dev' into fix/dpns-search-n…
lklimek Apr 1, 2026
09cfd40
fix(dashpay): use homograph-safe normalization in contact username re…
lklimek Apr 1, 2026
0ea3a64
fix(dashpay): trim whitespace and strip .dash suffix in DPNS lookups
lklimek Apr 1, 2026
3ec57cd
fix(dashpay): add missing normalizedParentDomainName filter in userna…
lklimek Apr 1, 2026
51efd07
fix(dashpay): accept all key types when signing contact info documents
lklimek Apr 1, 2026
c5596b6
fix(dashpay): case-insensitive .dash suffix stripping in DPNS lookups
lklimek Apr 1, 2026
22939f3
fix(dashpay): case-insensitive .dash suffix detection in contact request
lklimek Apr 1, 2026
adaa917
refactor(model): extract DPNS normalization into model::dpns helper
lklimek Apr 1, 2026
64d7af6
fix(dashpay): pad contactInfo privateData to meet contract minimum
lklimek Apr 1, 2026
4ba8209
fix(dashpay): use random padding for contactInfo privateData minimum …
lklimek Apr 1, 2026
a9c0762
fix(dashpay): add 0x00 sentinel before random padding in privateData
lklimek Apr 1, 2026
cb4652e
fix: address PR #810 review comments
lklimek Apr 1, 2026
1e6b018
fix(model): use safe UTF-8 slicing in DPNS helpers, fix API asymmetry
lklimek Apr 1, 2026
d7fea39
Merge branch 'v1.0-dev' into fix/dpns-search-normalization
lklimek Apr 1, 2026
2a01faa
fix(dashpay): validate username format and contact info size before n…
lklimek Apr 8, 2026
142a042
fix(dashpay): use cached DPNS contract and records.identity in userna…
lklimek Apr 8, 2026
dfa1506
fix(dpns): centralize username input validation, fix case-sensitive .…
lklimek Apr 8, 2026
5cc5046
docs: add validation placement rule to CLAUDE.md
lklimek Apr 8, 2026
0e98779
fix(dashpay): reject self-contact request before broadcasting
lklimek Apr 8, 2026
cd90c21
fix(dashpay): guard u8 overflow in serialize and wire error variants
lklimek Apr 9, 2026
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
5 changes: 3 additions & 2 deletions src/backend_task/dashpay/contact_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ pub async fn create_or_update_contact_info(
let encrypted_private_data = encrypt_private_data(&private_data.serialize(), &private_data_key)
.map_err(|e| TaskError::EncryptionError { detail: e })?;

// Get signing key
// Get signing key — accept any key type (BLS, ECDSA, EDDSA) since
Comment thread
lklimek marked this conversation as resolved.
Resolved
// Platform accepts all for document state transitions.
let signing_key = identity
.identity
.get_first_public_key_matching(
Expand All @@ -397,7 +398,7 @@ pub async fn create_or_update_contact_info(
SecurityLevel::HIGH,
SecurityLevel::MEDIUM,
]),
HashSet::from([KeyType::ECDSA_SECP256K1]),
KeyType::all_key_types().into(),
false,
)
.ok_or_else(|| TaskError::DashPay(DashPayError::MissingAuthenticationKey))?;
Expand Down
20 changes: 14 additions & 6 deletions src/backend_task/dashpay/contact_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ pub async fn send_contact_request_with_proof(
qr_auto_accept: Option<AutoAcceptProofData>,
) -> Result<BackendTaskSuccessResult, TaskError> {
// Step 1: Resolve the recipient identity
let to_identity = if to_username_or_id.ends_with(".dash") {
let to_username_or_id = to_username_or_id.trim().to_string();
let to_identity = if to_username_or_id.to_lowercase().ends_with(".dash") {
// It's a complete username, resolve via DPNS
resolve_username_to_identity(sdk, &to_username_or_id).await?
} else {
Comment thread
lklimek marked this conversation as resolved.
Resolved
Expand Down Expand Up @@ -518,6 +519,7 @@ pub async fn send_contact_request_with_proof(
}

async fn resolve_username_to_identity(sdk: &Sdk, username: &str) -> Result<Identity, TaskError> {
let username = username.trim();
// Parse username (e.g., "alice.dash" -> "alice")
let name = username.split('.').next().ok_or_else(|| {
TaskError::DashPay(DashPayError::InvalidUsername {
Expand Down Expand Up @@ -545,11 +547,17 @@ async fn resolve_username_to_identity(sdk: &Sdk, username: &str) -> Result<Ident
}
})?;

query = query.with_where(WhereClause {
field: "normalizedLabel".to_string(),
operator: WhereOperator::Equal,
value: Value::Text(name.to_lowercase()),
});
query = query
.with_where(WhereClause {
field: "normalizedParentDomainName".to_string(),
operator: WhereOperator::Equal,
value: Value::Text("dash".to_string()),
})
.with_where(WhereClause {
field: "normalizedLabel".to_string(),
operator: WhereOperator::Equal,
value: Value::Text(dash_sdk::dpp::util::strings::convert_to_homograph_safe_chars(name)),
});
query.limit = 1;

let results = Document::fetch_many(sdk, query).await?;
Expand Down
12 changes: 10 additions & 2 deletions src/backend_task/dashpay/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,16 @@ pub async fn search_profiles(
));
}

// Normalize the search query (DPNS uses lowercase normalized labels)
let normalized_query = query_trimmed.to_lowercase();
// Normalize the search query using DPNS homograph-safe conversion
// (replaces o→0, i/l→1, then lowercases). Plain to_lowercase() won't
// match normalizedLabel on-chain which uses this conversion.
let query_without_suffix = if query_trimmed.to_lowercase().ends_with(".dash") {
&query_trimmed[..query_trimmed.len() - 5]
} else {
query_trimmed
};
let normalized_query =
dash_sdk::dpp::util::strings::convert_to_homograph_safe_chars(query_without_suffix);
Comment thread
lklimek marked this conversation as resolved.
Resolved

// Search DPNS for usernames starting with the query
let mut dpns_query =
Expand Down
11 changes: 9 additions & 2 deletions src/backend_task/identity/load_identity_by_dpns_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,15 @@ impl AppContext {
dpns_name: String,
selected_wallet_seed_hash: Option<WalletSeedHash>,
) -> Result<BackendTaskSuccessResult, TaskError> {
// Normalize the name (convert to lowercase and handle homoglyphs)
let normalized_name = convert_to_homograph_safe_chars(&dpns_name);
// Normalize the name (convert to lowercase and handle homoglyphs).
// Strip ".dash" suffix case-insensitively before normalization.
let trimmed = dpns_name.trim();
let label = if trimmed.to_lowercase().ends_with(".dash") {
&trimmed[..trimmed.len() - 5]
} else {
trimmed
};
Comment thread
lklimek marked this conversation as resolved.
Resolved
let normalized_name = convert_to_homograph_safe_chars(label);

// Query the DPNS contract for the domain document
let domain_query = DocumentQuery {
Expand Down
Loading