1
- ## Payment Envelope
1
+ ## Payment Envelope Schema
2
2
3
3
### Connect Envelope
4
4
19
19
"id" : " xyz123" , // Gateway unique payment ID
20
20
"issued" : " 2006-01-02T15:04:05-07:00" , // RFC 3339 Timestamp
21
21
"timeout" : 60 , // Timeout in seconds
22
- "gateway " : " https://example.com/.." , // DogeConnect Gateway URL
22
+ "relay " : " https://example.com/.." , // Payment Relay to submit payment tx
23
23
"vendor_icon" : " https://example.com/.." , // vendor icon URL, JPG or PNG
24
24
"vendor_name" : " Vendor Co" , // vendor display name
25
25
"vendor_address" : " 123 Example St" , // vendor business address (optional)
31
31
}
32
32
```
33
33
34
- Do not submit a payment transaction after the time ` issued ` + ` timeout ` .
35
-
36
34
### Connect Item
37
35
38
36
``` json
@@ -56,3 +54,31 @@ Do not submit a payment transaction after the time `issued` + `timeout`.
56
54
"amount" : " 1.0" , // Amount, DECMIAL string
57
55
}
58
56
```
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 ) .
0 commit comments