ZIP 320: The `code-block` rst directive is not supported by rst2html

This commit is contained in:
Kris Nuttycombe 2024-01-13 13:09:18 -07:00
parent 342cd187cc
commit d33a793a93
2 changed files with 24 additions and 19 deletions

View File

@ -73,9 +73,10 @@ Pull-Request: &lt;<a href="https://github.com/zcash/zips/pull/760">https://githu
<p>Wallets and other Senders sending to a TEX address MUST ensure that only transparent UTXOs are spent in the creation of a transaction.</p>
</section>
<section id="reference-implementation-alternative-1"><h3><span class="section-heading">Reference Implementation (Alternative 1)</span><span class="section-anchor"> <a rel="bookmark" href="#reference-implementation-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h3>
<!-- code-block: javascript
import bs58check from 'bs58check'
<p>Javascript:</p>
<pre>import bs58check from 'bs58check'
import {bech32m} from 'bech32'
// From t1 to tex
var b58decoded = bs58check.decode('t1VmmGiyjVNeCjxDZzg7vZmd99WyzVby9yC')
console.assert(b58decoded.length == 22, 'Invalid length');
@ -83,13 +84,14 @@ console.assert(b58decoded[0] == 0x1C &amp;&amp; b58decoded[1] == 0xB8, 'Invalid
var pkh = b58decoded.slice(2)
var tex = bech32m.encode('tex', bech32m.toWords(pkh))
console.log(tex)
// From tex to t1
var bech32decoded = bech32m.decode('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte')
console.assert(bech32decoded.prefix == 'tex', 'Invalid address prefix')
var pkh2 = Uint8Array.from(bech32m.fromWords(bech32decoded.words))
console.assert(pkh2.length == 20, 'Invalid length');
var t1 = bs58check.encode(Buffer.concat([Uint8Array.from([0x1C, 0xB8]), pkh2]))
console.log(t1) -->
console.log(t1)</pre>
</section>
</section>
<section id="alternative-2"><h2><span class="section-heading">Alternative 2</span><span class="section-anchor"> <a rel="bookmark" href="#alternative-2"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>
@ -134,28 +136,30 @@ 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> <a id="footnote-reference-17" class="footnote_reference" href="#zcash-address-wasm">13</a>:</p>
<!-- code-block: javascript
import init, { to_traceable_address } from 'zcash_address_wasm;;
init().then(() =&gt; {
<p>Javascript using <cite>zcash_address_wasm</cite> <a id="footnote-reference-17" class="footnote_reference" href="#zcash-address-wasm">13</a>:</p>
<pre>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);
}); -->
});</pre>
<p>Rust:</p>
<!-- code-block: rust
use zcash_address::{
<pre>use zcash_address::{
unified::{self, Encoding},
Network, ToAddress, TryFromAddress, ZcashAddress,
};
struct TraceableReceiver {
net: Network,
data: [u8; 20],
}
impl TraceableReceiver {
fn to_address(&amp;self, expiry_time: u64) -&gt; ZcashAddress {
let traceable_addr = unified::Address::try_from_items(vec![
@ -169,18 +173,21 @@ impl TraceableReceiver {
},
])
.expect("We know that this produces a valid address.");
ZcashAddress::from_unified(self.net, traceable_addr)
}
}
impl TryFromAddress for TraceableReceiver {
type Error = unified::ParseError;
fn try_from_transparent_p2pkh(
net: Network,
data: [u8; 20],
) -&gt; Result&lt;Self, zcash_address::ConversionError&lt;Self::Error&gt;&gt; {
Ok(TraceableReceiver { net, data })
}
} -->
}</pre>
</section>
</section>
<section id="analysis-of-alternative-1"><h2><span class="section-heading">Analysis of Alternative 1</span><span class="section-anchor"> <a rel="bookmark" href="#analysis-of-alternative-1"><img width="24" height="24" class="section-anchor" src="assets/images/section-anchor.png" alt=""></a></span></h2>

View File

@ -130,7 +130,7 @@ transparent UTXOs are spent in the creation of a transaction.
Reference Implementation (Alternative 1)
----------------------------------------
.. code-block: javascript
Javascript::
import bs58check from 'bs58check'
import {bech32m} from 'bech32'
@ -234,11 +234,10 @@ that only transparent UTXOs are spent in the creation of a transaction.
Reference Implementation (Alternative 2)
----------------------------------------
Javascript library `zcash_address_wasm` [#zcash_address_wasm]_:
Javascript using `zcash_address_wasm` [#zcash_address_wasm]_::
.. code-block: javascript
import init, { to_traceable_address } from 'zcash_address_wasm;;
init().then(() => {
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
@ -248,11 +247,10 @@ Javascript library `zcash_address_wasm` [#zcash_address_wasm]_:
var traceable_address = to_traceable_address(t_address, expiry_unix_seconds);
console.log(traceable_address);
});
});
Rust:
Rust::
.. code-block: rust
use zcash_address::{
unified::{self, Encoding},
Network, ToAddress, TryFromAddress, ZcashAddress,