From c11451199b8152f67b90a35120b4f3488c8cbe73 Mon Sep 17 00:00:00 2001 From: Egge Date: Thu, 28 Nov 2024 09:35:10 +0000 Subject: [PATCH 1/8] base spec binary token encoding --- 00.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/00.md b/00.md index cb16c76..64235ab 100644 --- a/00.md +++ b/00.md @@ -306,6 +306,17 @@ We serialize this JSON using CBOR which can be seen [here](https://cbor.nemo157. cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4NTAxNDkyMThhZjkwZjcxNmE1MmJmNGE1ZWQzNDdlNDhlY2MxM2Y3NzM4OGFjWCECRFODGd5IXVW-07KaZCvuWHk3WrnnpiDhHki6SCQh88-iYWlIAK0mjE0fWCZhcIKjYWECYXN4QDEzMjNkM2Q0NzA3YTU4YWQyZTIzYWRhNGU5ZjFmNDlmNWE1YjRhYzdiNzA4ZWIwZDYxZjczOGY0ODMwN2U4ZWVhY1ghAjRWqhENhLSsdHrr2Cw7AFrKUL9Ffr1XN6RBT6w659lNo2FhAWFzeEA1NmJjYmNiYjdjYzY0MDZiM2ZhNWQ1N2QyMTc0ZjRlZmY4YjQ0MDJiMTc2OTI2ZDNhNTdkM2MzZGNiYjU5ZDU3YWNYIQJzEpxXGeWZN5qXSmJjY8MzxWyvwObQGr5G1YCCgHicY2FtdWh0dHA6Ly9sb2NhbGhvc3Q6MzMzOGF1Y3NhdA ``` +#### Binary Token + +V3 and V4 Token can be transmitted in a binary format when applicable. For this a list containing a prefix, a version and the token object is constructed and then serialised using `cbor`. + +``` +cbor(["craw", , ]) +``` + +- Token V3 Version Int: 1 +- Token V4 Version Int: 2 + [00]: 00.md [01]: 01.md [02]: 02.md From f2906445a9b7df3f9aeee826c39fb0490d1324b8 Mon Sep 17 00:00:00 2001 From: Egge Date: Thu, 28 Nov 2024 09:39:50 +0000 Subject: [PATCH 2/8] version --- 00.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/00.md b/00.md index 64235ab..60db4ae 100644 --- a/00.md +++ b/00.md @@ -314,8 +314,8 @@ V3 and V4 Token can be transmitted in a binary format when applicable. For this cbor(["craw", , ]) ``` -- Token V3 Version Int: 1 -- Token V4 Version Int: 2 +- Token V3 Version: 1 +- Token V4 Version: 2 [00]: 00.md [01]: 01.md From 2c2538c4bbb3fb26dece0e354508fc4ceb0b8583 Mon Sep 17 00:00:00 2001 From: Egge Date: Thu, 28 Nov 2024 10:16:15 +0000 Subject: [PATCH 3/8] separated prefixes and encoding --- 00.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/00.md b/00.md index 60db4ae..542d654 100644 --- a/00.md +++ b/00.md @@ -308,14 +308,14 @@ cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4NTAxNDkyMT #### Binary Token -V3 and V4 Token can be transmitted in a binary format when applicable. For this a list containing a prefix, a version and the token object is constructed and then serialised using `cbor`. +V3 and V4 Token can be transmitted in a binary format when applicable. For this the serialised token is prepended with a prefix and a version byte. ``` -cbor(["craw", , ]) +utf8('CRAW') ``` -- Token V3 Version: 1 -- Token V4 Version: 2 +- Token V3 Version: `utf8('CRAW') 0x01 cbor(token_object)` +- Token V4 Version: `utf8('CRAW') 0x02 cbor(token_object)` [00]: 00.md [01]: 01.md From 291f7257761cb55eaec74ad1cdebee42ae51a553 Mon Sep 17 00:00:00 2001 From: Egge Date: Fri, 29 Nov 2024 14:30:33 +0100 Subject: [PATCH 4/8] token version --- 00.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/00.md b/00.md index 542d654..a59e5b0 100644 --- a/00.md +++ b/00.md @@ -311,11 +311,11 @@ cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4NTAxNDkyMT V3 and V4 Token can be transmitted in a binary format when applicable. For this the serialised token is prepended with a prefix and a version byte. ``` -utf8('CRAW') +utf8('craw') utf8() ``` -- Token V3 Version: `utf8('CRAW') 0x01 cbor(token_object)` -- Token V4 Version: `utf8('CRAW') 0x02 cbor(token_object)` +- Token V3 Version: `utf8('craw') utf8("A") cbor(token_object)` +- Token V4 Version: `utf8('craw') utf8("B") cbor(token_object)` [00]: 00.md [01]: 01.md From 6887a430d4b1fd36df4a43834552e51be8f7b6cc Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Fri, 29 Nov 2024 15:52:20 +0100 Subject: [PATCH 5/8] small typos --- 00.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/00.md b/00.md index a59e5b0..34f1dae 100644 --- a/00.md +++ b/00.md @@ -308,14 +308,15 @@ cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4NTAxNDkyMT #### Binary Token -V3 and V4 Token can be transmitted in a binary format when applicable. For this the serialised token is prepended with a prefix and a version byte. +V3 and V4 Token can be transmitted in a binary format when applicable (for example when transmitting via NFC). +For this the serialised token is prepended with a prefix and a version byte. ``` -utf8('craw') utf8() +utf8("craw") utf8() ``` -- Token V3 Version: `utf8('craw') utf8("A") cbor(token_object)` -- Token V4 Version: `utf8('craw') utf8("B") cbor(token_object)` +- Token V3 Version: `utf8("craw") utf8("A") cbor(token_object)` +- Token V4 Version: `utf8("craw") utf8("B") cbor(token_object)` [00]: 00.md [01]: 01.md From b3f4aea47c3f71c0b3c33cb9e1941e6ec6720cd1 Mon Sep 17 00:00:00 2001 From: Egge Date: Wed, 11 Dec 2024 17:44:09 +0100 Subject: [PATCH 6/8] added tests --- tests/00-tests.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/00-tests.md b/tests/00-tests.md index d383773..06d8ac8 100644 --- a/tests/00-tests.md +++ b/tests/00-tests.md @@ -191,4 +191,72 @@ Serialized: cashuBo2F0gqJhaUgA_9SLj17PgGFwgaNhYQFhc3hAYWNjMTI0MzVlN2I4NDg0YzNjZjE4NTAxNDkyMThhZjkwZjcxNmE1MmJmNGE1ZWQzNDdlNDhlY2MxM2Y3NzM4OGFjWCECRFODGd5IXVW-07KaZCvuWHk3WrnnpiDhHki6SCQh88-iYWlIAK0mjE0fWCZhcIKjYWECYXN4QDEzMjNkM2Q0NzA3YTU4YWQyZTIzYWRhNGU5ZjFmNDlmNWE1YjRhYzdiNzA4ZWIwZDYxZjczOGY0ODMwN2U4ZWVhY1ghAjRWqhENhLSsdHrr2Cw7AFrKUL9Ffr1XN6RBT6w659lNo2FhAWFzeEA1NmJjYmNiYjdjYzY0MDZiM2ZhNWQ1N2QyMTc0ZjRlZmY4YjQ0MDJiMTc2OTI2ZDNhNTdkM2MzZGNiYjU5ZDU3YWNYIQJzEpxXGeWZN5qXSmJjY8MzxWyvwObQGr5G1YCCgHicY2FtdWh0dHA6Ly9sb2NhbGhvc3Q6MzMzOGF1Y3NhdA ``` +## Raw Token Serialization + +### TokenV3 + +What follows is a TokenV3 Token serialized in its raw binary form. `h''` values are bytes in hex notation. + +Token: + +```json +{ + "token": [ + { + "mint": "https://8333.space:3338", + "proofs": [ + { + "amount": 2, + "id": "009a1f293253e41e", + "secret": "407915bc212be61a77e3e6d2aeb4c727980bda51cd06a6afc29e2861768a7837", + "C": "02bc9097997d81afb2cc7346b5e4345a9346bd2a506eb7958598a72f0cf85163ea" + }, + { + "amount": 8, + "id": "009a1f293253e41e", + "secret": "fe15109314e61d7756b0f8ee0f23a624acaa3f4e042f61433c728c7057b931be", + "C": "029e8e5050b890a7d6c0968db16bc1d5d5fa040ea1de284f6ec69d61299f671059" + } + ] + } + ], + "unit": "sat", + "memo": "Thank you." +} +``` + +Serialized to raw binary: + +`h'6372617741a365746f6b656e81a2646d696e747768747470733a2f2f383333332e73706163653a333333386670726f6f667382a466616d6f756e740262696470303039613166323933323533653431656673656372657478403430373931356263323132626536316137376533653664326165623463373237393830626461353163643036613661666332396532383631373638613738333761437842303262633930393739393764383161666232636337333436623565343334356139333436626432613530366562373935383539386137326630636638353136336561a466616d6f756e74086269647030303961316632393332353365343165667365637265747840666531353130393331346536316437373536623066386565306632336136323461636161336634653034326636313433336337323863373035376239333162656143784230323965386535303530623839306137643663303936386462313662633164356435666130343065613164653238346636656336396436313239396636373130353964756e697463736174646d656d6f6a5468616e6b20796f752e'` + +### TokenV4 + +What follows is a TokenV4 Token serialized in its raw binary form. `h''` values are bytes in hex notation. + +Token: + +```json +{ + "t": [ + { + "i": h'00ad268c4d1f5826', + "p": [ + { + "a": 1, + "s": "9a6dbb847bd232ba76db0df197216b29d3b8cc14553cd27827fc1cc942fedb4e", + "c": h'038618543ffb6b8695df4ad4babcde92a34a96bdcd97dcee0d7ccf98d472126792', + }, + ], + }, + ], + "d": "Thank you", + "m": "http://localhost:3338", + "u": "sat", +} +``` + +Serialized to raw binary: + +`h'6372617742a4617481a261694800ad268c4d1f5826617081a3616101617378403961366462623834376264323332626137366462306466313937323136623239643362386363313435353363643237383237666331636339343266656462346561635821038618543ffb6b8695df4ad4babcde92a34a96bdcd97dcee0d7ccf98d4721267926164695468616e6b20796f75616d75687474703a2f2f6c6f63616c686f73743a33333338617563736174'` + [NUT-10]: ../10.md From 7301f6be22da1e1160ec7355d2d92ed4e27d4390 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:59:56 +0100 Subject: [PATCH 7/8] Update 00.md --- 00.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/00.md b/00.md index 34f1dae..ab8ae3a 100644 --- a/00.md +++ b/00.md @@ -312,7 +312,7 @@ V3 and V4 Token can be transmitted in a binary format when applicable (for examp For this the serialised token is prepended with a prefix and a version byte. ``` -utf8("craw") utf8() +utf8("craw") || utf8() || ``` - Token V3 Version: `utf8("craw") utf8("A") cbor(token_object)` From 6b207a342c22dc840e1dae2d885ba67aaad98e05 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:00:02 +0100 Subject: [PATCH 8/8] Update 00.md --- 00.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/00.md b/00.md index ab8ae3a..caf6c23 100644 --- a/00.md +++ b/00.md @@ -315,8 +315,8 @@ For this the serialised token is prepended with a prefix and a version byte. utf8("craw") || utf8() || ``` -- Token V3 Version: `utf8("craw") utf8("A") cbor(token_object)` -- Token V4 Version: `utf8("craw") utf8("B") cbor(token_object)` +- Token V3 Version: `utf8("craw") || utf8("A") || cbor(token_object)` +- Token V4 Version: `utf8("craw") || utf8("B") || cbor(token_object)` [00]: 00.md [01]: 01.md