Skip to content

Commit 09a2ad7

Browse files
fix(dpp): bind unshielding_amount to sighash in client builders
The server-side proof verification (shielded_proof.rs) binds both the destination and unshielding_amount to the Orchard sighash, but the client-side builders only bound the destination. This mismatch caused every Unshield and ShieldedWithdrawal transition built with rs-dpp or rs-sdk-ffi to fail proof verification on the platform. Fixed in 4 locations: - rs-dpp builder: unshield.rs, shielded_withdrawal.rs - rs-sdk-ffi FFI: bundle_build.rs (unshield + withdrawal paths) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 95bdf2c commit 09a2ad7

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

packages/rs-dpp/src/shielded/builder/shielded_withdrawal.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ pub fn build_shielded_withdrawal_transition<P: OrchardProver>(
8888

8989
let change_amount = total_spent - required;
9090

91-
// ShieldedWithdrawal extra_data = output_script.as_bytes()
92-
let extra_sighash_data = output_script.as_bytes().to_vec();
91+
// ShieldedWithdrawal extra_data = output_script || unshielding_amount (le bytes)
92+
// Must match server-side sighash in shielded_proof.rs
93+
let mut extra_sighash_data = output_script.as_bytes().to_vec();
94+
extra_sighash_data.extend_from_slice(&required.to_le_bytes());
9395

9496
let bundle = build_spend_bundle(
9597
spends,

packages/rs-dpp/src/shielded/builder/unshield.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ pub fn build_unshield_transition<P: OrchardProver>(
8080

8181
let change_amount = total_spent - required;
8282

83-
// Unshield extra_data = output_address.to_bytes()
84-
let extra_sighash_data = output_address.to_bytes();
83+
// Unshield extra_data = output_address || unshielding_amount (le bytes)
84+
// Must match server-side sighash in shielded_proof.rs
85+
let mut extra_sighash_data = output_address.to_bytes();
86+
extra_sighash_data.extend_from_slice(&required.to_le_bytes());
8587

8688
let bundle = build_spend_bundle(
8789
spends,

packages/rs-sdk-ffi/src/shielded/crypto/bundle_build.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,10 @@ pub unsafe extern "C" fn dash_sdk_shielded_build_unshield_bundle(
844844

845845
let change_amount = total_spent - required;
846846

847-
// Unshield extra_data = output_address.to_bytes()
848-
let extra_sighash_data = output_address.to_bytes();
847+
// Unshield extra_data = output_address || unshielding_amount (le bytes)
848+
// Must match server-side sighash in shielded_proof.rs
849+
let mut extra_sighash_data = output_address.to_bytes();
850+
extra_sighash_data.extend_from_slice(&required.to_le_bytes());
849851

850852
let sb = match build_spend_bundle_local(
851853
spends,
@@ -1017,8 +1019,10 @@ pub unsafe extern "C" fn dash_sdk_shielded_build_withdrawal_bundle(
10171019

10181020
let change_amount = total_spent - required;
10191021

1020-
// ShieldedWithdrawal extra_data = output_script.as_bytes()
1021-
let extra_sighash_data = core_script.as_bytes().to_vec();
1022+
// ShieldedWithdrawal extra_data = output_script || unshielding_amount (le bytes)
1023+
// Must match server-side sighash in shielded_proof.rs
1024+
let mut extra_sighash_data = core_script.as_bytes().to_vec();
1025+
extra_sighash_data.extend_from_slice(&required.to_le_bytes());
10221026

10231027
let sb = match build_spend_bundle_local(
10241028
spends,

0 commit comments

Comments
 (0)