Skip to content

Commit d2bba98

Browse files
committed
Payment Envelope Verification
1 parent c14d956 commit d2bba98

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
- [Introduction](./getting_started/introduction.md)
66
- [Payment QR-Code](./qr_codes/qr_codes.md)
77
- [Payment Envelope](./payment_envelope/envelope.md)
8-
- [Payment Gateway](./payment_gateway/gateway.md)
8+
- [Payment Relay](./payment_relay/relay.md)

src/installation/getting.md

-1
This file was deleted.

src/payment_envelope/envelope.md

+30-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Payment Envelope
1+
## Payment Envelope Schema
22

33
### Connect Envelope
44

@@ -19,7 +19,7 @@
1919
"id": "xyz123", // Gateway unique payment ID
2020
"issued": "2006-01-02T15:04:05-07:00", // RFC 3339 Timestamp
2121
"timeout": 60, // Timeout in seconds
22-
"gateway": "https://example.com/..", // DogeConnect Gateway URL
22+
"relay": "https://example.com/..", // Payment Relay to submit payment tx
2323
"vendor_icon": "https://example.com/..", // vendor icon URL, JPG or PNG
2424
"vendor_name": "Vendor Co", // vendor display name
2525
"vendor_address": "123 Example St", // vendor business address (optional)
@@ -31,8 +31,6 @@
3131
}
3232
```
3333

34-
Do not submit a payment transaction after the time `issued` + `timeout`.
35-
3634
### Connect Item
3735

3836
```json
@@ -56,3 +54,31 @@ Do not submit a payment transaction after the time `issued` + `timeout`.
5654
"amount": "1.0", // Amount, DECMIAL string
5755
}
5856
```
57+
58+
## Payment Envelope Verification
59+
60+
The DogeConnect _Payment Envelope_ contains a Base64-encoded JSON payload,
61+
the _Payment Relay's_ public key, and a digital signature of the payload
62+
signed by the _Payment Relay's_ private key.
63+
64+
Use the following steps to decode and verify the payload.
65+
66+
1. Ensure you verify the `pubkey` hash as described in the [Payment QR-Code](../qr_codes/qr_codes.md) section.
67+
2. Decode the Base64-encoded `payload` field, yielding bytes.
68+
3. Decode the Hex-encoded `pubkey` and `sig` fields, yielding bytes.
69+
4. Compute the Double-SHA256 of the decoded payload bytes from step 2, i.e. `SHA-256(SHA-256(bytes))`
70+
5. Apply BIP-340 `lift_x` algorithm on the `pubkey` to recover the full Public Key.
71+
A BIP-304 library will supply this step (it's essentially parsing a compressed public key.)
72+
6. Verify the BIP-340 Schnorr signature, using the Double-SHA256 hash as the `message`, and the full Public Key and `sig`.
73+
A BIP-304 library will supply the signature verification algorithm.
74+
If this step fails, it suggests a MITM attack or faulty implementation.
75+
7. Parse the JSON payload bytes using a standard JSON parser.
76+
8. Check the `timeout` field: do not submit a payment transaction after the time `issued` + `timeout`.
77+
9. Display the payment information and ask the user to confirm payment.
78+
10. Create and sign a payment transaction and submit it to the `relay` URL.
79+
80+
The goals of the above process are to verify that the _Payment Envelope_ is cryptographically
81+
signed by the _Payment Relay's_ public key, i.e. the envelope was created by the _Payment Relay_.
82+
83+
A reference implementation of these algorithms exist at [github.com/dogeorg/dogeconnect-go](https://github.com/dogeorg/dogeconnect-go)
84+
which can be packaged for mobile using [gomobile bind](https://pkg.go.dev/golang.org/x/mobile/cmd/gobind).

src/payment_gateway/gateway.md

-1
This file was deleted.

src/payment_relay/relay.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Payment Relay

src/using/connect.md

-1
This file was deleted.

0 commit comments

Comments
 (0)