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
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
8363c65
safer forfeitTxsMap.sign
louisinger Feb 26, 2025
642d42c
add bip322 package
louisinger Feb 26, 2025
10c6cd3
replace nostr notifications APIs by GetNote RPC + BIP322 proof of funds
louisinger Feb 26, 2025
44d436f
fix permissions
louisinger Feb 26, 2025
e425913
update wasm wrappers
louisinger Feb 26, 2025
d588106
update signature_test.go
louisinger Feb 26, 2025
5009334
remove fixture generation
louisinger Feb 26, 2025
6ddc8a1
update utils.go
louisinger Feb 26, 2025
3c919f4
drop entity repo and view
louisinger Feb 26, 2025
dd29de3
Merge remote-tracking branch 'origin/master' into note-API
louisinger Feb 26, 2025
ba17504
add craftToSign func
louisinger Feb 27, 2025
8e45def
make proto
louisinger Feb 27, 2025
9fe53e1
rework message verification
louisinger Feb 27, 2025
5bf3662
rework RegisterInputsForNextRound, remove GetNote
louisinger Feb 28, 2025
72ea4b5
drop unused functions
louisinger Feb 28, 2025
37023ec
Merge remote-tracking branch 'origin/master' into note-API
louisinger Feb 28, 2025
1f6e8f7
remove toVtxoKeys
louisinger Feb 28, 2025
143d4eb
Merge branch master into note-API
louisinger Mar 19, 2025
01be2dc
make genrest
louisinger Mar 19, 2025
de82c5f
merge origin/master
louisinger Apr 1, 2025
35667e0
Merge remote-tracking branch 'origin/master' into note-API
louisinger Apr 7, 2025
d1794b7
Replace boarding descriptor with boarding exit delay (#501)
louisinger Apr 8, 2025
d777044
Merge branch master into note-API
louisinger Apr 24, 2025
2a5a6e8
fix notes registration
louisinger Apr 24, 2025
f1b4c53
implement RegisterIntent
louisinger Apr 24, 2025
d6fc955
Merge branch 'master' into next-version
altafan Apr 25, 2025
4ea11a6
Merge remote-tracking branch origin/next-version into note-API
louisinger Apr 25, 2025
1df976d
fix GetInfo
louisinger Apr 25, 2025
19c669a
revert arkservice.go
louisinger Apr 25, 2025
05ac1c4
allign with next-version GetInfo
louisinger Apr 25, 2025
84df665
revert changes from master
louisinger Apr 25, 2025
c8b9d7b
fix ContainsOutput
louisinger Apr 25, 2025
acac47e
move Message struct and rename
louisinger Apr 25, 2025
4f9c400
fix IntentMessage comment
louisinger Apr 25, 2025
c620f94
Select --> selectFunds
louisinger Apr 25, 2025
09f7ea3
revert covenantless.go constant change
louisinger Apr 25, 2025
96d4fd7
use time to check exitDelay
louisinger Apr 25, 2025
13c61db
check vtxo key
louisinger Apr 25, 2025
6cf527d
remove unused parser
louisinger Apr 25, 2025
79111f5
drop GetNote from permissions.go
louisinger Apr 25, 2025
79c8a30
run integration CI in every PR
louisinger Apr 25, 2025
8733685
run unit test on every PR
louisinger Apr 25, 2025
029af91
update permisssions.go file
louisinger Apr 25, 2025
d7d10a4
Merge branch 'next-version' into note-API
altafan Apr 30, 2025
4eb096e
Make changes backward compatible
altafan Apr 30, 2025
0cfcd5e
Fix macaroon permission
altafan Apr 30, 2025
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
165 changes: 18 additions & 147 deletions api-spec/openapi/swagger/ark/v1/service.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,14 @@
]
}
},
"/v1/round/registerInputs": {
"/v1/round/registerIntent": {
"post": {
"operationId": "ArkService_RegisterInputsForNextRound",
"operationId": "ArkService_RegisterIntent",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1RegisterInputsForNextRoundResponse"
"$ref": "#/definitions/v1RegisterIntentResponse"
}
},
"default": {
Expand All @@ -187,7 +187,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1RegisterInputsForNextRoundRequest"
"$ref": "#/definitions/v1RegisterIntentRequest"
}
}
],
Expand Down Expand Up @@ -354,70 +354,6 @@
"ArkService"
]
}
},
"/v1/vtxo/nostr": {
"post": {
"operationId": "ArkService_SetNostrRecipient",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1SetNostrRecipientResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1SetNostrRecipientRequest"
}
}
],
"tags": [
"ArkService"
]
}
},
"/v1/vtxo/nostr/delete": {
"post": {
"operationId": "ArkService_DeleteNostrRecipient",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v1DeleteNostrRecipientResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1DeleteNostrRecipientRequest"
}
}
],
"tags": [
"ArkService"
]
}
}
},
"definitions": {
Expand Down Expand Up @@ -449,21 +385,17 @@
}
}
},
"v1DeleteNostrRecipientRequest": {
"v1Bip322Signature": {
"type": "object",
"properties": {
"vtxos": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1SignedVtxoOutpoint"
}
"signature": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"v1DeleteNostrRecipientResponse": {
"type": "object"
},
"v1GetBoardingAddressRequest": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -531,8 +463,9 @@
"type": "string",
"format": "int64"
},
"boardingDescriptorTemplate": {
"type": "string"
"boardingExitDelay": {
"type": "string",
"format": "int64"
},
"vtxoDescriptorTemplates": {
"type": "array",
Expand Down Expand Up @@ -582,20 +515,6 @@
}
}
},
"v1Input": {
"type": "object",
"properties": {
"outpoint": {
"$ref": "#/definitions/v1Outpoint"
},
"descriptor": {
"type": "string"
},
"tapscripts": {
"$ref": "#/definitions/v1Tapscripts"
}
}
},
"v1MarketHour": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -671,22 +590,6 @@
}
}
},
"v1OwnershipProof": {
"type": "object",
"properties": {
"controlBlock": {
"type": "string"
},
"script": {
"type": "string"
},
"signature": {
"type": "string",
"title": "VTXO outpoint signed with script's secret key"
}
},
"description": "This message is used to prove to the server that the user controls the vtxo without revealing the whole VTXO taproot tree."
},
"v1PingResponse": {
"type": "object"
},
Expand Down Expand Up @@ -715,15 +618,12 @@
}
}
},
"v1RegisterInputsForNextRoundRequest": {
"v1RegisterIntentRequest": {
"type": "object",
"properties": {
"inputs": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1Input"
}
"bip322Signature": {
"$ref": "#/definitions/v1Bip322Signature",
"title": "BIP322 signature embeds the outpoints and the proof of funds"
},
"notes": {
"type": "array",
Expand All @@ -733,7 +633,7 @@
}
}
},
"v1RegisterInputsForNextRoundResponse": {
"v1RegisterIntentResponse": {
"type": "object",
"properties": {
"requestId": {
Expand Down Expand Up @@ -876,35 +776,6 @@
}
}
},
"v1SetNostrRecipientRequest": {
"type": "object",
"properties": {
"nostrRecipient": {
"type": "string"
},
"vtxos": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/v1SignedVtxoOutpoint"
}
}
}
},
"v1SetNostrRecipientResponse": {
"type": "object"
},
"v1SignedVtxoOutpoint": {
"type": "object",
"properties": {
"outpoint": {
"$ref": "#/definitions/v1Outpoint"
},
"proof": {
"$ref": "#/definitions/v1OwnershipProof"
}
}
},
"v1SubmitRedeemTxRequest": {
"type": "object",
"properties": {
Expand Down
39 changes: 8 additions & 31 deletions api-spec/protobuf/ark/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ service ArkService {

/* In-Round Transaction APIs */

rpc RegisterInputsForNextRound(RegisterInputsForNextRoundRequest) returns (RegisterInputsForNextRoundResponse) {
rpc RegisterIntent(RegisterIntentRequest) returns (RegisterIntentResponse) {
option (google.api.http) = {
post: "/v1/round/registerInputs"
post: "/v1/round/registerIntent"
body: "*"
};
};
Expand Down Expand Up @@ -70,25 +70,11 @@ service ArkService {
};
}

/* Nostr APIs */

rpc GetTransactionsStream(GetTransactionsStreamRequest) returns (stream GetTransactionsStreamResponse) {
option (google.api.http) = {
get: "/v1/transactions"
};
}
rpc SetNostrRecipient(SetNostrRecipientRequest) returns (SetNostrRecipientResponse) {
option (google.api.http) = {
post: "/v1/vtxo/nostr"
body: "*"
};
}
rpc DeleteNostrRecipient(DeleteNostrRecipientRequest) returns (DeleteNostrRecipientResponse) {
option (google.api.http) = {
post: "/v1/vtxo/nostr/delete"
body: "*"
};
}
}

message GetInfoRequest {}
Expand All @@ -99,7 +85,7 @@ message GetInfoResponse {
int64 round_interval = 4;
string network = 5;
int64 dust = 6;
string boarding_descriptor_template = 7;
int64 boarding_exit_delay = 7;
repeated string vtxo_descriptor_templates = 8;
string forfeit_address = 9;
MarketHour market_hour = 10;
Expand All @@ -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

// BIP322 signature embeds the outpoints and the proof of funds
Bip322Signature bip322_signature = 1;
repeated string notes = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
repeated string notes = 2;
// TODO: Consolidate into bip322 as well
repeated string notes = 2;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the "problem" is BIP322 expecting at least one "real" utxo to be signed. If the intent contains only notes, the bip322 proof will be an unsigned, is it a problem ?

Copy link
Contributor

Choose a reason for hiding this comment

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

just the existence of knowing the note should be enough? Plus, we can technically issue notes that are locked to a script with this proposal?

Copy link
Contributor

Choose a reason for hiding this comment

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

Technically a note is a preimage, we can migrate existing notes to a script that uses a hashlock

Copy link
Collaborator

Choose a reason for hiding this comment

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

we do it in another pr, this became too big already

}
message RegisterInputsForNextRoundResponse {

message RegisterIntentResponse {
string request_id = 1;
}

Expand Down Expand Up @@ -200,14 +188,3 @@ message GetTransactionsStreamResponse {
RedeemTransaction redeem = 2;
}
}

message SetNostrRecipientRequest {
string nostr_recipient = 1;
repeated SignedVtxoOutpoint vtxos = 2;
}
message SetNostrRecipientResponse {}

message DeleteNostrRecipientRequest {
repeated SignedVtxoOutpoint vtxos = 1;
}
message DeleteNostrRecipientResponse {}
25 changes: 5 additions & 20 deletions api-spec/protobuf/ark/v1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ message Outpoint {
uint32 vout = 2;
}

message Input {
Outpoint outpoint = 1;
oneof taproot_tree {
string descriptor = 2;
Tapscripts tapscripts = 3;
}
}

message Output {
string address = 1; // onchain or off-chain
uint64 amount = 2; // Amount to send in satoshis.
Expand Down Expand Up @@ -84,22 +76,15 @@ message RedeemTransaction {
string hex = 4;
}

// This message is used to prove to the server that the user controls the vtxo without revealing the whole VTXO taproot tree.
message OwnershipProof {
string control_block = 1;
string script = 2;
string signature = 3; // VTXO outpoint signed with script's secret key
}

message SignedVtxoOutpoint {
Outpoint outpoint = 1;
OwnershipProof proof = 2;
}

message Tapscripts {
repeated string scripts = 1;
}

message Bip322Signature {
string signature = 1;
string message = 2;
}

message MarketHour {
int64 next_start_time = 1;
int64 next_end_time = 2;
Expand Down
Loading
Loading