Skip to content
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

fix(wallet)!: ensure burn shared keys and hashes match dan layer #5245

Merged

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Mar 14, 2023

Description

  • derives encryption key using DH shared spend key
  • use consensus hasher to ensure consistent hash preimages
  • recovered blinding factor is the shared key, so logic updated not to calculate another Diffie-Helman from the claim key

Motivation and Context

Mask and encrypted value key derivation currently should match confidential claims and transfers on the DAN layer.

shared_key = DH(claim_pubkey, spend_key) 
shared_mask = dan_mask_kdf(shared_key)
commitment = commit(shared_mask, value)
shared_value_encryption_key = dan_encrypted_value_kdf(shared_mask, commitment)
encrypted_value = encrypt(shared_value_encryption_key, value)

How Has This Been Tested?

Tested that claims work on the DAN

BREAKING CHANGE: Burn with claim mask and encrypted value key derivation has changed. Existing burnt funds are not claimable on the DAN.

@sdbondi sdbondi changed the title fix(wallet): ensure burn shared keys and hashes match dan layer fix(wallet)!: ensure burn shared keys and hashes match dan layer Mar 14, 2023
Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@sdbondi sdbondi merged commit 024ce64 into tari-project:development Mar 15, 2023
@sdbondi sdbondi deleted the wallet-claim-burn-shared-keys branch March 15, 2023 06:18
stringhandler pushed a commit to tari-project/tari-dan that referenced this pull request Mar 15, 2023
Description
---
- wallet SDK: fix KDFs for encrypted value and mask to exactly match
base layer
- wallet SDK: key manager does not implicitly set the last used key as
active
- wallet SDK: check that shared mask is correct before masking output as
Unspent
- wallet SDK: dont finalize outputs for dry-run
- walletd: fixes deadlock in account monitor

Motivation and Context
---
Relies on tari-project/tari#5245

This PR corrects a number of bugs, makes minor logging and cli
improvements and gets confidential transfers working.

How Has This Been Tested?
---
Manually, as per steps below

What process can a PR reviewer use to test or verify this change?
---
1. create 2 accounts named primary and alt

```shell
cargo run --bin tari_dan_wallet_cli --  accounts create --name primary
cargo run --bin tari_dan_wallet_cli --  accounts create --name alt
```

2. Use POSTman to burn using `primary`'s public key
3. Mine 4 blocks and claim the burn using the proofs returned in POSTman
```shell
cargo run --bin tari_dan_wallet_cli --  accounts claim-burn -n primary
```

4. Transfer from `primary` to `alt`
```shell
cargo run --bin tari_dan_wallet_cli --  transactions confidential-transfer -n1 primary 100 $ALT_ACCOUNT $ALT_ACCOUNT_PK
```

5. Check balance

```
$ cargo run --bin tari_dan_wallet_cli --  accounts get-balances --account-name primary
Account component_b0fb082aa0b63b6d3b26f374a5e3f442257899f99fcec96002a7281e77716c04 balances:

VaultId                                                                | Resource                                                                               | Balance                                 
---------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | --------------------------------------- 
vault_ac223920e139a33579e7497e5f2e1055e3100fb0e0600af686ba8f7ec768e9ff | resource_0101010101010101010101010101010101010101010101010101010101010101 Confidential | 0 revealed + 10000 blinded = 10000 tXTR 

1 row(s)

```

6. Check in `outputs` database table that appropriate outputs are marked
as `Spent`/`Unspent` and their unblinded value is included

Breaking Changes
---

- [ ] None
- [x] Requires data directory to be deleted (walletd)
- [ ] Other - Please specify
stringhandler pushed a commit that referenced this pull request Mar 15, 2023
### ⚠ BREAKING CHANGES

* **wallet:** ensure burn shared keys and hashes match dan layer (5245)
* add claim public key to OutputFeatures (5239)
* reset esmeralda (5247)

### Features

* add claim public key to OutputFeatures
([5239](#5239))
([3e7d82c](3e7d82c))
* reset esmeralda
([5247](#5247))
([aa2a3ad](aa2a3ad))


### Bug Fixes

* added transaction revalidation to the wallet startup sequence
[5227](#5227)
([5246](#5246))
([7b4e2d2](7b4e2d2))
* immediately fail to compile on 32-bit systems
([5237](#5237))
([76aeed7](76aeed7))
* **wallet:** correct change checks in transaction builder
([5235](#5235))
([768a0cf](768a0cf))
* **wallet:** ensure burn shared keys and hashes match dan layer
([5245](#5245))
([024ce64](024ce64))
* windows path format in log4rs files
([5234](#5234))
([acfecfb](acfecfb))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants