mirror of https://github.com/zcash/zips.git
ZIP 320: Add a link to proof-of-concept Traceable Address javascript library.
This commit is contained in:
parent
a49c9c2fdd
commit
342cd187cc
|
@ -78,7 +78,7 @@ import bs58check from 'bs58check'
|
||||||
import {bech32m} from 'bech32'
|
import {bech32m} from 'bech32'
|
||||||
// From t1 to tex
|
// From t1 to tex
|
||||||
var b58decoded = bs58check.decode('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC')
|
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');
|
console.assert(b58decoded[0] == 0x1C && b58decoded[1] == 0xB8, 'Invalid address prefix');
|
||||||
var pkh = b58decoded.slice(2)
|
var pkh = b58decoded.slice(2)
|
||||||
var tex = bech32m.encode('tex', bech32m.toWords(pkh))
|
var tex = bech32m.encode('tex', bech32m.toWords(pkh))
|
||||||
|
@ -87,7 +87,7 @@ console.log(tex)
|
||||||
var bech32decoded = bech32m.decode('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte')
|
var bech32decoded = bech32m.decode('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte')
|
||||||
console.assert(bech32decoded.prefix == 'tex', 'Invalid address prefix')
|
console.assert(bech32decoded.prefix == 'tex', 'Invalid address prefix')
|
||||||
var pkh2 = Uint8Array.from(bech32m.fromWords(bech32decoded.words))
|
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]))
|
var t1 = bs58check.encode(Buffer.concat([Uint8Array.from([0x1C, 0xB8]), pkh2]))
|
||||||
console.log(t1) -->
|
console.log(t1) -->
|
||||||
</section>
|
</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>
|
<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>
|
||||||
<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>
|
<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
|
<!-- code-block: javascript
|
||||||
import { to_traceable_address } from 'zcash_address_wasm'
|
import init, { to_traceable_address } from 'zcash_address_wasm;;
|
||||||
// Create a deposit address that is valid for 30 days
|
init().then(() => {
|
||||||
var expiry_time = new Date();
|
var t_address = "t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC";
|
||||||
expiry_time.setDate(expiry_time.getDate() + 30);
|
// Create a deposit address that is valid for 30 days
|
||||||
var traceable_addr = to_traceable_address('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC', expiry_time.getTime() / 1000) -->
|
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>
|
<p>Rust:</p>
|
||||||
<!-- code-block: rust
|
<!-- code-block: rust
|
||||||
use zcash_address::{
|
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>
|
<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>
|
<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>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>
|
<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>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
@ -202,7 +207,7 @@ impl TryFromAddress for TraceableReceiver {
|
||||||
</section>
|
</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>
|
<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>
|
<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>
|
</ul>
|
||||||
<table id="bcp14" class="footnote">
|
<table id="bcp14" class="footnote">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -300,6 +305,14 @@ impl TryFromAddress for TraceableReceiver {
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</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>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
12
zip-0320.rst
12
zip-0320.rst
|
@ -234,16 +234,21 @@ that only transparent UTXOs are spent in the creation of a transaction.
|
||||||
Reference Implementation (Alternative 2)
|
Reference Implementation (Alternative 2)
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
Javascript library `zcash_address_wasm`:
|
Javascript library `zcash_address_wasm` [#zcash_address_wasm]_:
|
||||||
|
|
||||||
.. code-block: javascript
|
.. 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
|
// Create a deposit address that is valid for 30 days
|
||||||
var expiry_time = new Date();
|
var expiry_time = new Date();
|
||||||
expiry_time.setDate(expiry_time.getDate() + 30);
|
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:
|
Rust:
|
||||||
|
|
||||||
|
@ -355,3 +360,4 @@ Cons to Alternative 2
|
||||||
.. [#Base58Check] `Base58Check encoding — Bitcoin Wiki <https://en.bitcoin.it/wiki/Base58Check_encoding>`_
|
.. [#Base58Check] `Base58Check encoding — Bitcoin Wiki <https://en.bitcoin.it/wiki/Base58Check_encoding>`_
|
||||||
.. [#F4Jumble] `ZIP 316: F4Jumble encoding <zip-0316#jumbling>`_
|
.. [#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>`_
|
.. [#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>`_
|
||||||
|
|
Loading…
Reference in New Issue