-
Notifications
You must be signed in to change notification settings - Fork 54
feat(swift-sdk): add full shielded pool (ZK) support for iOS #3348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
fb54790
feat(swift-sdk): add full shielded pool (ZK) support for iOS
QuantumExplorer a16eede
fix(rs-sdk-ffi): address quality review findings in crypto module
QuantumExplorer 16cfce5
fix(rs-sdk-ffi): address critical and high security audit findings
QuantumExplorer 10bbed3
refactor(swift-sdk): replace JSON bundle serialization with direct C …
QuantumExplorer 47b9587
security(rs-sdk-ffi): zeroize spending key bytes after derivation
QuantumExplorer c19a56e
fix(rs-sdk-ffi): address CodeRabbit review findings + fix CI compilation
QuantumExplorer 8104871
feat(swift-sdk): add ShieldedPoolClient with commitment tree management
QuantumExplorer 31b5c92
fix(swift-sdk): address CodeRabbit review findings (round 2)
QuantumExplorer b7de183
fix(swift-sdk): add Sendable conformance to types captured across iso…
QuantumExplorer 272d1a2
fix(swift-sdk): widen SendableSdkPtr access from private to internal
QuantumExplorer 49a53e2
fix(swift-sdk): widen shieldedExtractString/Void from private to inte…
QuantumExplorer fc38cc2
fix(swift-sdk): add Sendable to all public shielded value types
QuantumExplorer 7dc7969
fix(swift-sdk): use C header types instead of manual Swift struct defs
QuantumExplorer e494b40
fix(swift-sdk): wrap .count with UInt() for FFI usize parameters
QuantumExplorer 6ce0f79
fix(swift-sdk): fix Swift 6 concurrency and unused result warnings
QuantumExplorer e99d33e
fix(rs-sdk-ffi): address blocking review findings in pool_client
QuantumExplorer 93a5dd2
fix(swift-sdk): fix mutable var capture in syncNullifiersRaw closure
QuantumExplorer 187dc2a
fix: address remaining CodeRabbit review comments
QuantumExplorer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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,67 @@ | ||
| //! Orchard address derivation FFI function. | ||
|
|
||
| use std::ffi::CString; | ||
| use std::os::raw::c_void; | ||
|
|
||
| use dash_sdk::grovedb_commitment_tree::{FullViewingKey, Scope, SpendingKey}; | ||
| use zeroize::Zeroize; | ||
|
|
||
| use crate::{DashSDKError, DashSDKErrorCode, DashSDKResult, DashSDKResultDataType}; | ||
|
|
||
| /// Derive an Orchard payment address from a 32-byte spending key. | ||
| /// | ||
| /// # Parameters | ||
| /// - `spending_key_bytes`: Pointer to a 32-byte spending key. | ||
| /// - `diversifier_index`: Address diversifier index (usually 0). | ||
| /// | ||
| /// # Returns | ||
| /// `DashSDKResult` with a hex-encoded 43-byte Orchard raw address string on success. | ||
| /// The string is returned inside `DashSDKResult.data` and freed when the result is consumed. | ||
| /// | ||
| /// # Safety | ||
| /// - `spending_key_bytes` must point to exactly 32 valid bytes. | ||
| #[no_mangle] | ||
| pub unsafe extern "C" fn dash_sdk_shielded_derive_address( | ||
| spending_key_bytes: *const [u8; 32], | ||
| diversifier_index: u32, | ||
| ) -> DashSDKResult { | ||
| if spending_key_bytes.is_null() { | ||
| return DashSDKResult::error(DashSDKError::new( | ||
| DashSDKErrorCode::InvalidParameter, | ||
| "spending_key_bytes is null".to_string(), | ||
| )); | ||
| } | ||
|
|
||
| let mut key_copy = *spending_key_bytes; | ||
|
|
||
| let sk = match SpendingKey::from_bytes(key_copy).into_option() { | ||
| Some(sk) => { | ||
| key_copy.zeroize(); | ||
| sk | ||
| } | ||
| None => { | ||
| key_copy.zeroize(); | ||
| return DashSDKResult::error(DashSDKError::new( | ||
| DashSDKErrorCode::InvalidParameter, | ||
| "Invalid spending key bytes".to_string(), | ||
| )); | ||
| } | ||
| }; | ||
|
|
||
| let fvk = FullViewingKey::from(&sk); | ||
| let payment_address = fvk.address_at(diversifier_index, Scope::External); | ||
| let raw_bytes = payment_address.to_raw_address_bytes(); | ||
| let hex_str = hex::encode(raw_bytes); | ||
|
|
||
| match CString::new(hex_str) { | ||
| Ok(c_str) => DashSDKResult { | ||
| data_type: DashSDKResultDataType::String, | ||
| data: c_str.into_raw() as *mut c_void, | ||
| error: std::ptr::null_mut(), | ||
| }, | ||
| Err(e) => DashSDKResult::error(DashSDKError::new( | ||
| DashSDKErrorCode::InternalError, | ||
| format!("Failed to create CString: {}", e), | ||
| )), | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.