forked from SmartTokenLabs/TokenScript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEncodingAttestationInURI.html
72 lines (70 loc) · 8.4 KB
/
EncodingAttestationInURI.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html
SYSTEM "about:legacy-compat">
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><meta name="copyright" content="(C) Copyright 2020"><meta name="DC.rights.owner" content="(C) Copyright 2020"><meta name="DC.type" content="task"><meta name="description" content="Encoding an attestation in URI format that is colloquially called Magic Link."><meta name="DC.relation" scheme="URI" content="../specs/Intro.html"><meta name="DC.format" content="HTML5"><meta name="DC.identifier" content="task_t51_w4p_qmb"><link rel="stylesheet" type="text/css" href="../css/commonltr.css"><link rel="stylesheet" type="text/css" href="../css/custom.css"><title>Encoding Attestation in URI</title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab|Lato">
<script type="text/javascript" src="https://alphawallet.com/wp-content/themes/alphawallet/discourse/widget.js"></script>
</head><body id="task_t51_w4p_qmb"><header role="banner"><nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
<div class="container">
<a class="navbar-brand" href="/">🆃okenScript</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item"><a class="nav-link" href="/TokenScript.html">Documents</a></li>
<li class="nav-item"><a class="nav-link" href="/guides/Intro.html">Guides</a></li>
<li class="nav-item"><a class="nav-link" href="/specs/Intro.html">Specs</a></li>
<li class="nav-item external"><a class="nav-link" href="">TokenScript community forum</a></li>
<li class="nav-item external"><a class="nav-link" href="/TokenScript.html">AlphaWallet (uses TokenScript)</a></li>
<li class="nav-item external"><a class="nav-link" href="/guides/Intro.html">Github TokenScript</a></li>
<li class="nav-item external"><a class="nav-link" href="/specs/Intro.html">Github TokenScript Examples</a></li>
</ul>
</div>
</div>
</nav></header><div class="container" id="content"><div class="row"><nav role="toc" class="col-lg-3"><ul><li><a href="../Tokenization.html">Tokenization and dApps</a></li><li><a href="../index.html">Introduction to TokenScript</a></li><li><a href="../QuickStart.html">Quick Start (usuable now)</a></li><li><a href="../BasicConcepts.html">Basic Concepts</a></li><li><a href="../Deploy.html">Deploy TokenScript</a></li><li><a href="../features/FeatureImplementation.html">Features implemented</a></li><li><a href="../specs/Intro.html">TokenScript Specs</a><ul><li class="active"><a href="../specs/EncodingAttestationInURI.html">Encoding Attestation in URI</a></li></ul></li><li><a href="../guides/Intro.html">TokenScript Guides</a></li></ul></nav><main role="main" class="col-lg-9"><article role="article" aria-labelledby="ariaid-title1">
<h1 class="title topictitle1" id="ariaid-title1">Encoding Attestation in URI</h1>
<div class="body taskbody"><p class="shortdesc">Encoding an attestation in URI format that is colloquially called <a class="xref" href="../MagicLink.html" title="Magic Links does something magic, with cryptography!">Magic Link</a>.</p>
<section class="section context">
<p class="p">Encoding takes as argument the address of `a smart contract which the attestation
should be encoded towards.</p>
<p class="p">The encoding then proceeds as follows:</p>
</section>
<section><ol class="ol steps"><li class="li step stepexpand">
<span class="ph cmd"><code class="ph codeph">signatureAlgorithm</code> is defined in Sec. 4.1.1.2 of RFC 5280. If the algorithm has OID 1.2.840.10045.4.3.2 (ECDSA with SHA256), then remove <code class="ph codeph">signatureAlgorithm</code>. Curve choice is not possible under OID 1.2.840.10045.4.3.2 and will be assumed to be secp256k1. Similarly for the optional field <code class="ph codeph">algorithm</code> in <code class="ph codeph">SubjectPublicKeyInfo</code>.</span>
</li><li class="li step stepexpand">
<span class="ph cmd"><code class="ph codeph">signature</code> is defined in Sec. 4.1.2.3 of RFC 5280. It
<em class="ph i">must</em> contain the same value as <code class="ph codeph">signatureAlgortihm</code>
and is thus always removed.</span>
</li><li class="li step stepexpand"><span class="ph cmd">The remaining structure is DER encoded.</span></li><li class="li step stepexpand"><span class="ph cmd">The DER encoding is then base64 encoded, with the following exceptions:</span>
<ul class="ul"><li class="li">The content of <code class="ph codeph">dataObject</code> is decoded back into its human readable ASCII representation. It is furthermore moved to the beginning of the encoding (i.e. before the base64 encoding starts) and appended an exclamation point, !.</li>
<li class="li">If the <code class="ph codeph">signatureAlgorithm</code> has OID 1.2.840.10045.4.3.2 then the data in the <code class="ph codeph">CommonName</code> field within the <code class="ph codeph">Name</code> structure of the <code class="ph codeph">issuer</code> field is decoded back into ASCII (which implicitly is actually a hex encoding, and thus human readable). It is appended an exclamation point, !, and then moved to be right after the exclamation point ending the <code class="ph codeph">dataObject</code> encoding. Thus the format of the encoding is now:</li></ul>
<div class="itemgroup stepresult">The format of the encoding is
now<pre class="pre codeblock"><code><dataObject>!0x<fingerprint>!<base64 of DER encoding></code></pre></div>
</li><li class="li step stepexpand">
<span class="ph cmd">URL sensitive characters of the ASCII representation are escaped using the URL
percent encoding approach as specified in RFC 3986 section 2.1. </span>
</li><li class="li step stepexpand">
<span class="ph cmd">The address of the smart contract which the attestation is being linked to is
appended with an exclamation point, !. Finally the address and exclamation point
is prepended to the encoding of the attestation.</span>
</li><li class="li step stepexpand">
<span class="ph cmd"> URL sensitive characters of the encoding (specifically the base64 encoded
part) are substituted according to the following rules:</span>
<ul class="ul">
<li class="li">Addition sign, <code class="ph codeph">+</code>, is replaced with the minus sign, <code class="ph codeph">-</code>.</li>
<li class="li">Forward slash, <code class="ph codeph">/</code>, is replaced with the underscore, <code class="ph codeph">_</code>.</li>
<li class="li">Equality, <code class="ph codeph">=</code>, is replaced with the multiplication sign, <code class="ph codeph">*</code>.</li>
</ul>
<div class="itemgroup stepresult"><p class="p">That is, an attestation will look something like the following when the
smart contract address is assumed to be 0x34288B5B65D616B746AE, the fingerprint
of the public is 0xAB89BBEF99736629DC23, the <code class="ph codeph">dataObject</code> has the
following ASN.1 form:</p>
<pre class="pre codeblock"><code>"dataObject":{
"match":1,
"class":"lounge/lobby",
"admission":1
}</code></pre> <p class="p">The URI being:</p><pre class="pre codeblock"><code>0x34288B5B65D616B746AE!match=1;class=lounge%2Flobby;admission=1;0xAB89BBEF99736629DC23!CICyyZb8QcHv0k0bDUV3T0W_EVGGMWOwKD_RIpnbFT_cTAiBsZiTXYqH870YYKE6tjwhnis-BbE8hCNfFlTmrRaCM-gg\*\*</code></pre>
</div>
</li></ol></section>
</div>
<nav role="navigation" class="related-links"><div class="familylinks"><div class="parentlink"><strong>Parent topic:</strong> <a class="link" href="../specs/Intro.html">TokenScript Specs</a></div></div></nav></article></main></div></div></body></html>