ZIP 320: Add a link to proof-of-concept Traceable Address javascript library.

This commit is contained in:
Kris Nuttycombe 2024-01-13 11:19:27 -07:00
parent a49c9c2fdd
commit 342cd187cc
2 changed files with 35 additions and 16 deletions

View File

@ -78,7 +78,7 @@ import bs58check from 'bs58check'
import {bech32m} from 'bech32'
// From t1 to tex
var b58decoded = bs58check.decode('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC')
console.assert(len(b58decoded) == 22, 'Invalid length');
console.assert(b58decoded.length == 22, 'Invalid length');
console.assert(b58decoded[0] == 0x1C && b58decoded[1] == 0xB8, 'Invalid address prefix');
var pkh = b58decoded.slice(2)
var tex = bech32m.encode('tex', bech32m.toWords(pkh))
@ -87,7 +87,7 @@ console.log(tex)
var bech32decoded = bech32m.decode('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte')
console.assert(bech32decoded.prefix == 'tex', 'Invalid address prefix')
var pkh2 = Uint8Array.from(bech32m.fromWords(bech32decoded.words))
console.assert(len(pkh2) == 20, 'Invalid length');
console.assert(pkh2.length == 20, 'Invalid length');
var t1 = bs58check.encode(Buffer.concat([Uint8Array.from([0x1C, 0xB8]), pkh2]))
console.log(t1) -->
</section>
@ -134,13 +134,18 @@ A Unified Viewing Key MUST contain at least one shielded Item (Typecodes
<p>Wallets and other Senders sending to a Traceable Unified Address MUST ensure that only transparent UTXOs are spent in the creation of a transaction.</p>
</section>
<section id="reference-implementation-alternative-2"><h3><span class="section-heading">Reference Implementation (Alternative 2)</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation-alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<p>Javascript library <cite>zcash_address_wasm</cite>:</p>
<p>Javascript library <cite>zcash_address_wasm</cite> <a id="footnote-reference-17" class="footnote_reference" href="#zcash-address-wasm">13</a>:</p>
<!-- code-block: javascript
import { to_traceable_address } from 'zcash_address_wasm'
// Create a deposit address that is valid for 30 days
var expiry_time = new Date();
expiry_time.setDate(expiry_time.getDate() + 30);
var traceable_addr = to_traceable_address('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC', expiry_time.getTime() / 1000) -->
import init, { to_traceable_address } from 'zcash_address_wasm;;
init().then(() =&gt; {
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
// Create a deposit address that is valid for 30 days
var expiry_time = new Date();
expiry_time.setDate(expiry_time.getDate() + 30);
var expiry_unix_seconds = BigInt(Math.floor(expiry_time.getTime() / 1000));
var traceable_address = to_traceable_address(t_address, expiry_unix_seconds);
console.log(traceable_address);
}); -->
<p>Rust:</p>
<!-- code-block: rust
use zcash_address::{
@ -187,7 +192,7 @@ impl TryFromAddress for TraceableReceiver {
<section id="cons-to-alternative-1"><h3><span class="section-heading">Cons to Alternative 1</span><span class="section-anchor"> <a rel="bookmark" href="#cons-to-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<ul>
<li>Existing wallets and other Consumers will regard the new address type as entirely invalid, and will not automatically prompt their users that they need to upgrade in order to send to this type of address.</li>
<li>Creation of a new fully-distinct address type further fragments the Zcash address ecosystem. Avoiding such fragmentation and providing smooth upgrade paths and good error messages to users is exactly the problem that Unifed Addresses <a id="footnote-reference-17" class="footnote_reference" href="#zip-0316-unified-addresses">5</a> were intended to avoid.</li>
<li>Creation of a new fully-distinct address type further fragments the Zcash address ecosystem. Avoiding such fragmentation and providing smooth upgrade paths and good error messages to users is exactly the problem that Unifed Addresses <a id="footnote-reference-18" class="footnote_reference" href="#zip-0316-unified-addresses">5</a> were intended to avoid.</li>
<li>The TEX address type does not provide any mechanism for address expiration. One of the questions Binance has asked has been what to do about users who have stored their existing transparent deposit address in their wallets, or as a withdrawal address for other exchanges or services. This is a challenging problem to mitigate now because address expiration was not previously implemented. We should not further compound this problem by defining a new distinct address type that does not provide a mechanism for address expiry.</li>
</ul>
</section>
@ -202,7 +207,7 @@ impl TryFromAddress for TraceableReceiver {
</section>
<section id="cons-to-alternative-2"><h3><span class="section-heading">Cons to Alternative 2</span><span class="section-anchor"> <a rel="bookmark" href="#cons-to-alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<ul>
<li>Unified Address encoding is slightly more complex than the proposed TEX address encoding, and requires use of the F4Jumble encoding algorithm <a id="footnote-reference-18" class="footnote_reference" href="#f4jumble">11</a>. However, this can be readily mitigated by providing a purpose-built library for Traceable Address encoding to Producers.</li>
<li>Unified Address encoding is slightly more complex than the proposed TEX address encoding, and requires use of the F4Jumble encoding algorithm <a id="footnote-reference-19" class="footnote_reference" href="#f4jumble">11</a>. However, this can be readily mitigated by providing a purpose-built library for Traceable Address encoding to Producers.</li>
</ul>
<table id="bcp14" class="footnote">
<tbody>
@ -300,6 +305,14 @@ impl TryFromAddress for TraceableReceiver {
</tr>
</tbody>
</table>
<table id="zcash-address-wasm" class="footnote">
<tbody>
<tr>
<th>13</th>
<td><a href="https://github.com/nuttycom/zcash_address_wasm">zcash_address_wasm: Proof of concept library for Traceable Address Encoding</a></td>
</tr>
</tbody>
</table>
</section>
</section>
</section>

View File

@ -234,16 +234,21 @@ that only transparent UTXOs are spent in the creation of a transaction.
Reference Implementation (Alternative 2)
----------------------------------------
Javascript library `zcash_address_wasm`:
Javascript library `zcash_address_wasm` [#zcash_address_wasm]_:
.. code-block: javascript
import { to_traceable_address } from 'zcash_address_wasm'
import init, { to_traceable_address } from 'zcash_address_wasm;;
init().then(() => {
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
// Create a deposit address that is valid for 30 days
var expiry_time = new Date();
expiry_time.setDate(expiry_time.getDate() + 30);
// Create a deposit address that is valid for 30 days
var expiry_time = new Date();
expiry_time.setDate(expiry_time.getDate() + 30);
var expiry_unix_seconds = BigInt(Math.floor(expiry_time.getTime() / 1000));
var traceable_addr = to_traceable_address('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC', expiry_time.getTime() / 1000)
var traceable_address = to_traceable_address(t_address, expiry_unix_seconds);
console.log(traceable_address);
});
Rust:
@ -355,3 +360,4 @@ Cons to Alternative 2
.. [#Base58Check] `Base58Check encoding — Bitcoin Wiki <https://en.bitcoin.it/wiki/Base58Check_encoding>`_
.. [#F4Jumble] `ZIP 316: F4Jumble encoding <zip-0316#jumbling>`_
.. [#bip-0350] `BIP 350: Bech32m format for v1+ witness addresses <https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki>`_
.. [#zcash_address_wasm] `zcash_address_wasm: Proof of concept library for Traceable Address Encoding <https://github.com/nuttycom/zcash_address_wasm>`_