Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c5325c9
feat(wasm-dpp2,js-sdk): add shielded pool WASM bindings and JS SDK me…
QuantumExplorer Mar 12, 2026
65c02a6
revert: remove js-dash-sdk and wasm-dpp changes from shielded PR
QuantumExplorer Mar 12, 2026
8b71f68
feat(wasm-sdk): add shielded pool query methods
QuantumExplorer Mar 12, 2026
3256346
feat(wasm-dpp2): implement shielded proof result wrappers
QuantumExplorer Mar 12, 2026
d08e087
fix(wasm-sdk): correct computePlatformSighash doc for extraData format
QuantumExplorer Mar 12, 2026
98a20b6
fix(wasm-sdk): remove needless borrow in computePlatformSighash
QuantumExplorer Mar 12, 2026
5d4ee20
fix(wasm): address PR review feedback for shielded bindings
QuantumExplorer Mar 13, 2026
35b7ba4
fix(wasm-sdk): reject nullifiers that are not exactly 32 bytes
QuantumExplorer Mar 13, 2026
a87c6ad
Merge branch 'v3.1-dev' into feat/zk-wasm-js-bindings
QuantumExplorer Mar 13, 2026
0b48cd3
Merge branch 'v3.1-dev' into feat/zk-wasm-js-bindings
QuantumExplorer Mar 16, 2026
74e9290
feat(wasm): address all review feedback on shielded WASM bindings
QuantumExplorer Mar 16, 2026
7f216ec
feat(wasm): improve TypeScript interface definitions per shumkov review
QuantumExplorer Mar 16, 2026
c6a73b7
fix(wasm): use base64 string for all byte fields in OrchardActionJSON
QuantumExplorer Mar 16, 2026
4e29ccd
fix(wasm): use number | string for BigInt fields in JSON interfaces
QuantumExplorer Mar 16, 2026
fd850e1
fix(wasm): use typed parameters in shielded transition constructors
QuantumExplorer Mar 16, 2026
2db3796
fix(wasm): correct TS types to match actual serde output
QuantumExplorer Mar 16, 2026
c55a943
Merge branch 'v3.1-dev' into feat/zk-wasm-js-bindings
QuantumExplorer Mar 17, 2026
c6a2b3f
fix(wasm): change $version to $formatVersion, add Options constructor
QuantumExplorer Mar 17, 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
26 changes: 26 additions & 0 deletions packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import type { DPPModule } from '@dashevo/wasm-dpp';
import crypto from 'crypto';

import Client from '../Client';

Check warning on line 5 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Using exported name 'Client' as identifier for default export

Check warning on line 5 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle via "./Platform:10"
import { IStateTransitionResult } from './IStateTransitionResult';

import createAssetLockTransaction from './createAssetLockTransaction';

Check warning on line 8 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Using exported name 'createAssetLockTransaction' as identifier for default export

Check warning on line 8 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected

import broadcastDocument from './methods/documents/broadcast';

Check warning on line 10 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected
import createDocument from './methods/documents/create';

Check warning on line 11 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected
import getDocument from './methods/documents/get';

Check warning on line 12 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected

import publishContract from './methods/contracts/publish';

Check warning on line 14 in packages/js-dash-sdk/src/SDK/Client/Platform/Platform.ts

View workflow job for this annotation

GitHub Actions / JS packages (dash) / Linting

Dependency cycle detected
import updateContract from './methods/contracts/update';
import createContract from './methods/contracts/create';
import getContract from './methods/contracts/get';
Expand All @@ -34,6 +34,12 @@
import searchName from './methods/names/search';
import broadcastStateTransition from './broadcastStateTransition';

import shieldMethod from './methods/shielded/shield';
import shieldedTransferMethod from './methods/shielded/shieldedTransfer';
import unshieldMethod from './methods/shielded/unshield';
import shieldFromAssetLockMethod from './methods/shielded/shieldFromAssetLock';
import shieldedWithdrawalMethod from './methods/shielded/shieldedWithdrawal';
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

import logger, { ConfigurableLogger } from '../../../logger';
import Fetcher from './Fetcher';
import NonceManager from './NonceManager/NonceManager';
Expand Down Expand Up @@ -98,6 +104,14 @@
history: Function,
}

interface Shielded {
shield: Function,
shieldedTransfer: Function,
unshield: Function,
shieldFromAssetLock: Function,
shieldedWithdrawal: Function,
}

/**
* Class for Dash Platform
*
Expand All @@ -117,6 +131,11 @@

public documents: Records;

/**
* Shielded pool operations (shield, transfer, unshield)
*/
public shielded: Shielded;

/**
* @param {Function} get - get identities from the platform
* @param {Function} register - register identities on the platform
Expand Down Expand Up @@ -180,6 +199,13 @@
resolveByRecord: resolveNameByRecord.bind(this),
search: searchName.bind(this),
};
this.shielded = {
shield: shieldMethod.bind(this),
shieldedTransfer: shieldedTransferMethod.bind(this),
unshield: unshieldMethod.bind(this),
shieldFromAssetLock: shieldFromAssetLockMethod.bind(this),
shieldedWithdrawal: shieldedWithdrawalMethod.bind(this),
};
this.identities = {
register: registerIdentity.bind(this),
get: getIdentity.bind(this),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import broadcastStateTransition from '../../broadcastStateTransition';
import { Platform } from '../../Platform';
import { IStateTransitionResult } from '../../IStateTransitionResult';

/**
* Broadcast a shield transition (transparent platform addresses -> shielded pool).
*
* The Orchard bundle, platform address witnesses, and full state transition
* must be built externally (e.g., via rs-sdk's `shield_funds()` or a native
* wallet library) and serialized to platform binary format.
*
* @param serializedTransition - Platform-serialized ShieldTransition bytes
* @returns Broadcast result
*/
export async function shield(
this: Platform,
serializedTransition: Uint8Array,
): Promise<IStateTransitionResult> {
this.logger.debug('[Shielded#shield] Broadcasting shield transition');
await this.initialize();

const { dpp } = this;

const transition = dpp.stateTransition.createFromBuffer(
serializedTransition,
{},
);

const result = await broadcastStateTransition(this, await transition, {
skipValidation: true,
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

this.logger.silly('[Shielded#shield] Broadcasted ShieldTransition');

return result;
}

export default shield;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import broadcastStateTransition from '../../broadcastStateTransition';
import { Platform } from '../../Platform';
import { IStateTransitionResult } from '../../IStateTransitionResult';

/**
* Broadcast a shield-from-asset-lock transition (core asset lock -> shielded pool).
*
* The Orchard bundle, asset lock proof, ECDSA signature, and full state
* transition must be built externally (e.g., via rs-sdk's
* `shield_from_asset_lock()` or a native wallet library) and serialized
* to platform binary format.
*
* @param serializedTransition - Platform-serialized ShieldFromAssetLockTransition bytes
* @returns Broadcast result
*/
export async function shieldFromAssetLock(
this: Platform,
serializedTransition: Uint8Array,
): Promise<IStateTransitionResult> {
this.logger.debug('[Shielded#shieldFromAssetLock] Broadcasting shield from asset lock');
await this.initialize();

const { dpp } = this;

const transition = dpp.stateTransition.createFromBuffer(
serializedTransition,
{},
);

const result = await broadcastStateTransition(this, await transition, {
skipValidation: true,
});

this.logger.silly('[Shielded#shieldFromAssetLock] Broadcasted ShieldFromAssetLockTransition');

return result;
}

export default shieldFromAssetLock;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import broadcastStateTransition from '../../broadcastStateTransition';
import { Platform } from '../../Platform';
import { IStateTransitionResult } from '../../IStateTransitionResult';

/**
* Broadcast a shielded transfer (shielded-to-shielded) transition.
*
* The Orchard bundle and full state transition must be built externally
* (e.g., via rs-sdk's `transfer_shielded()` or a native wallet library)
* and serialized to platform binary format before passing here.
*
* Authentication is provided entirely by Orchard spend authorization
* signatures within the bundle — no identity signing needed.
*
* @param serializedTransition - Platform-serialized ShieldedTransferTransition bytes
* @returns Broadcast result
*/
export async function shieldedTransfer(
this: Platform,
serializedTransition: Uint8Array,
): Promise<IStateTransitionResult> {
this.logger.debug('[Shielded#shieldedTransfer] Broadcasting shielded transfer');
await this.initialize();

const { dpp } = this;

const transition = dpp.stateTransition.createFromBuffer(
serializedTransition,
{},
);

const result = await broadcastStateTransition(this, await transition, {
skipValidation: true,
});

this.logger.silly('[Shielded#shieldedTransfer] Broadcasted ShieldedTransferTransition');

return result;
}

export default shieldedTransfer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import broadcastStateTransition from '../../broadcastStateTransition';
import { Platform } from '../../Platform';
import { IStateTransitionResult } from '../../IStateTransitionResult';

/**
* Broadcast a shielded withdrawal transition (shielded pool -> core L1 address).
*
* The Orchard bundle and full state transition must be built externally
* (e.g., via rs-sdk's `withdraw_shielded()` or a native wallet library)
* and serialized to platform binary format.
*
* The platform sighash binds `outputScript || amount` to prevent
* an attacker from substituting a different L1 destination or amount.
*
* @param serializedTransition - Platform-serialized ShieldedWithdrawalTransition bytes
* @returns Broadcast result
*/
export async function shieldedWithdrawal(
this: Platform,
serializedTransition: Uint8Array,
): Promise<IStateTransitionResult> {
this.logger.debug('[Shielded#shieldedWithdrawal] Broadcasting shielded withdrawal');
await this.initialize();

const { dpp } = this;

const transition = dpp.stateTransition.createFromBuffer(
serializedTransition,
{},
);

const result = await broadcastStateTransition(this, await transition, {
skipValidation: true,
});

this.logger.silly('[Shielded#shieldedWithdrawal] Broadcasted ShieldedWithdrawalTransition');

return result;
}

export default shieldedWithdrawal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import broadcastStateTransition from '../../broadcastStateTransition';
import { Platform } from '../../Platform';
import { IStateTransitionResult } from '../../IStateTransitionResult';

/**
* Broadcast an unshield transition (shielded pool -> platform address).
*
* The Orchard bundle and full state transition must be built externally
* (e.g., via rs-sdk's `unshield_funds()` or a native wallet library)
* and serialized to platform binary format.
*
* The platform sighash binds `outputAddress || amount` to prevent
* an attacker from substituting a different destination or amount.
*
* @param serializedTransition - Platform-serialized UnshieldTransition bytes
* @returns Broadcast result
*/
export async function unshield(
this: Platform,
serializedTransition: Uint8Array,
): Promise<IStateTransitionResult> {
this.logger.debug('[Shielded#unshield] Broadcasting unshield transition');
await this.initialize();

const { dpp } = this;

const transition = dpp.stateTransition.createFromBuffer(
serializedTransition,
{},
);

const result = await broadcastStateTransition(this, await transition, {
skipValidation: true,
});

this.logger.silly('[Shielded#unshield] Broadcasted UnshieldTransition');

return result;
}

export default unshield;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ pub enum StateTransitionTypeWasm {
AddressFundsTransfer = 12,
AddressFundingFromAssetLock = 13,
AddressCreditWithdrawal = 14,
Shield = 15,
ShieldedTransfer = 16,
Unshield = 17,
ShieldFromAssetLock = 18,
ShieldedWithdrawal = 19,
}

impl From<StateTransitionType> for StateTransitionTypeWasm {
Expand Down Expand Up @@ -55,7 +60,13 @@ impl From<StateTransitionType> for StateTransitionTypeWasm {
StateTransitionType::AddressCreditWithdrawal => {
StateTransitionTypeWasm::AddressCreditWithdrawal
}
_ => todo!("shielded state transition types not yet implemented in wasm"),
StateTransitionType::Shield => StateTransitionTypeWasm::Shield,
StateTransitionType::ShieldedTransfer => StateTransitionTypeWasm::ShieldedTransfer,
StateTransitionType::Unshield => StateTransitionTypeWasm::Unshield,
StateTransitionType::ShieldFromAssetLock => {
StateTransitionTypeWasm::ShieldFromAssetLock
}
StateTransitionType::ShieldedWithdrawal => StateTransitionTypeWasm::ShieldedWithdrawal,
}
}
}
20 changes: 14 additions & 6 deletions packages/wasm-dpp/src/state_transition/state_transition_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,20 @@ impl StateTransitionFactoryWasm {
StateTransition::AddressCreditWithdrawal(st) => {
serde_wasm_bindgen::to_value(&st).map_err(|e| JsValue::from(e.to_string()))
}
StateTransition::Shield(_)
| StateTransition::ShieldedTransfer(_)
| StateTransition::Unshield(_)
| StateTransition::ShieldFromAssetLock(_)
| StateTransition::ShieldedWithdrawal(_) => {
todo!("shielded transitions not yet implemented in state_transition_factory")
StateTransition::Shield(st) => {
serde_wasm_bindgen::to_value(&st).map_err(|e| JsValue::from(e.to_string()))
}
StateTransition::ShieldedTransfer(st) => {
serde_wasm_bindgen::to_value(&st).map_err(|e| JsValue::from(e.to_string()))
}
StateTransition::Unshield(st) => {
serde_wasm_bindgen::to_value(&st).map_err(|e| JsValue::from(e.to_string()))
}
StateTransition::ShieldFromAssetLock(st) => {
serde_wasm_bindgen::to_value(&st).map_err(|e| JsValue::from(e.to_string()))
}
StateTransition::ShieldedWithdrawal(st) => {
serde_wasm_bindgen::to_value(&st).map_err(|e| JsValue::from(e.to_string()))
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
},
Err(dpp::ProtocolError::StateTransitionError(e)) => match e {
Expand Down
5 changes: 5 additions & 0 deletions packages/wasm-dpp2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub mod mock_bls;
pub mod platform_address;
pub mod public_key;
pub mod serialization;
pub mod shielded;
pub mod state_transitions;
pub mod tokens;
pub mod utils;
Expand Down Expand Up @@ -66,6 +67,10 @@ pub use platform_address::{
PlatformAddressWasm, default_fee_strategy, fee_strategy_from_steps,
fee_strategy_from_steps_or_default, outputs_to_btree_map, outputs_to_optional_btree_map,
};
pub use shielded::{
ShieldFromAssetLockTransitionWasm, ShieldTransitionWasm, ShieldedTransferTransitionWasm,
ShieldedWithdrawalTransitionWasm, UnshieldTransitionWasm,
};
pub use state_transitions::base::{GroupStateTransitionInfoWasm, StateTransitionWasm};
pub use state_transitions::proof_result::{StateTransitionProofResultTypeJs, convert_proof_result};
pub use tokens::*;
Expand Down
37 changes: 37 additions & 0 deletions packages/wasm-dpp2/src/shielded/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
pub mod shield_from_asset_lock_transition;
pub mod shield_transition;
pub mod shielded_transfer_transition;
pub mod shielded_withdrawal_transition;
pub mod unshield_transition;

pub use shield_from_asset_lock_transition::ShieldFromAssetLockTransitionWasm;
pub use shield_transition::ShieldTransitionWasm;
pub use shielded_transfer_transition::ShieldedTransferTransitionWasm;
pub use shielded_withdrawal_transition::ShieldedWithdrawalTransitionWasm;
pub use unshield_transition::UnshieldTransitionWasm;

use crate::error::WasmDppResult;
use wasm_bindgen::prelude::wasm_bindgen;

/// Compute the platform sighash from an Orchard bundle commitment and extra data.
///
/// `sighash = SHA-256("DashPlatformSighash" || bundleCommitment || extraData)`
///
/// - For shield and shielded_transfer transitions, `extraData` should be empty.
/// - For unshield transitions, `extraData` = `outputAddress || amount (LE u64)`.
/// - For shielded withdrawal transitions, `extraData` = `outputScript || amount (LE u64)`.
#[wasm_bindgen(js_name = computePlatformSighash)]
pub fn compute_platform_sighash_wasm(
bundle_commitment: &[u8],
extra_data: &[u8],
) -> WasmDppResult<Vec<u8>> {
if bundle_commitment.len() != 32 {
return Err(crate::error::WasmDppError::invalid_argument(&format!(
"bundleCommitment must be exactly 32 bytes, got {}",
bundle_commitment.len()
)));

Check failure on line 32 in packages/wasm-dpp2/src/shielded/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (wasm-dpp2) / Linting

the borrowed expression implements the required traits

error: the borrowed expression implements the required traits --> packages/wasm-dpp2/src/shielded/mod.rs:29:65 | 29 | return Err(crate::error::WasmDppError::invalid_argument(&format!( | _________________________________________________________________^ 30 | | "bundleCommitment must be exactly 32 bytes, got {}", 31 | | bundle_commitment.len() 32 | | ))); | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_borrows_for_generic_args = note: `-D clippy::needless-borrows-for-generic-args` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::needless_borrows_for_generic_args)]` help: change this to | 29 ~ return Err(crate::error::WasmDppError::invalid_argument(format!( 30 + "bundleCommitment must be exactly 32 bytes, got {}", 31 + bundle_commitment.len() 32 ~ ))); |
}
let commitment: &[u8; 32] = bundle_commitment.try_into().expect("checked length above");
let result = dpp::shielded::compute_platform_sighash(commitment, extra_data);
Ok(result.to_vec())
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Loading
Loading