Skip to content

Add BIP0322 Proof of Funds & implement RegisterIntent #485

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 46 commits into from
Apr 30, 2025

Conversation

louisinger
Copy link
Collaborator

@louisinger louisinger commented Feb 26, 2025

update: #485 (comment)

This PR deletes the nostr notifications system and replace it by a simple GetNote API. OwnershipProof is also replaced by BIP0322 "Proof of Funds".

GetNote

GetNote RPC expects bip322_signature and the associated message. If the signature is valid, the server returns a note where amount = sum of bip322_signature outpoints. The server also mark the VTXOs as spent in DB to prevent cheating.

BIP0322 Proof of funds

common.bip322 package is standalone and follows the BIP0322 specifications ⚠️ except that it doesn't verify the inputs sequence in order to allow the proof to be used for offchain outpoints.

The message must be the current Unix timestamp. It is considered valid by the server if and only if it is close to current timestamp.

CLI and SDK

sdk.RecoverSweptVtxos or ark recover CLI command automatically fetch swept and unspent VTXOs, create a BIP0322 signature, fetch the associated note and redeem it.

it closes #484
it closes #483

@altafan @Kukks please review

@louisinger louisinger requested a review from altafan February 26, 2025 14:01
@louisinger louisinger changed the title Swept vtxos recovering: replace nostr notifications by GetNote RPC Swept vtxos recovery : replace nostr notifications by GetNote RPC Feb 26, 2025
@Kukks
Copy link
Contributor

Kukks commented Feb 27, 2025

Couldn't one simply use the VTXO ownership proof in itself as a note? The api to exchange a proof for a vtxo is redundant:

This flow:

  • VTXO expires/gets swept
  • Wallet goes online, detected expired vtxo
  • Wallet creates proof, send to GetNote
  • Server returns note
  • Wallet redeems note for new VTXO

Proposed flow:

  • VTXO expires/gets swept
  • Wallet goes online, detected expired vtxo
  • Wallet creates proof and registers it as input for next batch

@louisinger
Copy link
Collaborator Author

louisinger commented Feb 27, 2025

Proposed flow:

  • VTXO expires/gets swept
  • Wallet goes online, detected expired vtxo
  • Wallet creates proof and registers it as input for next batch

I agree, but if we do that, we should be able to register also the not expired VTXOs in the same proof no ? If I have 1 VTXO not swept + 1 expired VTXO, I create a proof containing both outpoints and use it as input ?

something like:

message RegisterInputsForNextRoundRequest {
  repeated TaprootTree revealed_taproot_tree = 1; // reveal tapscripts of unspent & not expired vtxos
  repeated string notes = 2;
  string bip322_signature = 3; // proof of funds for "inputs" array + swept vtxos you want to recover
}

@louisinger
Copy link
Collaborator Author

louisinger commented Feb 28, 2025

According to the latest discussion, I've removed the GetNote RPC and reworked the inputs' registration flow:

message RegisterInputsForNextRoundRequest {
  map<string, Tapscripts> tapscripts = 1; 
  Bip322Signature bip322_signature = 2;
  repeated string notes = 3;
}

To register inputs, users must provide a valid BIP322 signature signing a timestamp message. The server accepts the signature if now - timestamp < 15 seconds.

The BIP322 proof of funds tx may include:

  • boarding UTXOs
  • unspent VTXOs
  • recoverable VTXOs (expired but unspent)

map<string, Tapscripts> tapscripts = 1; field should contain the revealed tapscripts for boarding and unspent VTXOs.

@louisinger louisinger changed the title Swept vtxos recovery : replace nostr notifications by GetNote RPC Add BIP0322 Proof of Funds to RegisterInputsForNextRoundRequest Feb 28, 2025
@louisinger louisinger requested a review from altafan February 28, 2025 15:38
@@ -123,11 +109,13 @@ message GetBoardingAddressResponse {

/* In-Round Transaction API messages */

message RegisterInputsForNextRoundRequest {
repeated Input inputs = 1;
message RegisterIntentRequest {
Copy link
Member

Choose a reason for hiding this comment

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

lets not replace it, and only add a new RPC

Copy link
Contributor

Choose a reason for hiding this comment

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

lets not replace it, and only add a new RPC

Ideally we do remove it in the medium term, it's a redundant rpc and keeps duplicate logic around input proofs

@altafan altafan merged commit d60c6a9 into arkade-os:next-version Apr 30, 2025
9 of 10 checks passed
altafan added a commit that referenced this pull request May 3, 2025
…ite db (#544)

* Replace boarding descriptor with boarding exit delay (#501)

* replace boarding descriptor by boarding exit delay

* fix wasm

---------

Co-authored-by: altafan <[email protected]>

* Add RegisterIntent & Support for BIP0322 proof of funds (#485)

* safer forfeitTxsMap.sign

* add bip322 package

* replace nostr notifications APIs by GetNote RPC + BIP322 proof of funds

* fix permissions

* update wasm wrappers

* update signature_test.go

* remove fixture generation

* update utils.go

* drop entity repo and view

* add craftToSign func

* make proto

* rework message verification

* rework RegisterInputsForNextRound, remove GetNote

* drop unused functions

* remove toVtxoKeys

* make genrest

* Replace boarding descriptor with boarding exit delay (#501)

* replace boarding descriptor by boarding exit delay

* fix wasm

---------

Co-authored-by: altafan <[email protected]>

* implement RegisterIntent

* fix GetInfo

* revert arkservice.go

* allign with next-version GetInfo

* revert changes from master

* fix ContainsOutput

* move Message struct and rename

* fix IntentMessage comment

* Select --> selectFunds

* revert covenantless.go constant change

* use time to check exitDelay

* check vtxo key

* remove unused parser

* drop GetNote from permissions.go

* run integration CI in every PR

* run unit test on every PR

* update permisssions.go file

* Make changes backward compatible

* Fix macaroon permission

---------

Co-authored-by: altafan <[email protected]>

* Drop covenant packages (#469)

* drop covenant/liquid support

* go work sync

* Replace boarding descriptor with boarding exit delay (#501)

* replace boarding descriptor by boarding exit delay

* fix wasm

---------

Co-authored-by: altafan <[email protected]>

* Lint

* Update readme

* Lint

* Fix

* Rename files

* Polish integration tests

* Polish sdk

* Fix

* Polish

---------

Co-authored-by: altafan <[email protected]>

* trick

* [SDK] SQLite store (#545)

* Add SQLite db to sdk

* Lint

* Fix

* Fixes

* Fix

* Fix makefile

* make GetInfoResponse backward compatible

* Lint

---------

Co-authored-by: Louis Singer <[email protected]>
Co-authored-by: Dusan Sekulic <[email protected]>
@louisinger louisinger mentioned this pull request May 13, 2025
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.

Notes simplification BIP322 as ownership proof
5 participants