1 <!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A marker trait used to indicate that an `RngCore` or `BlockRngCore` implementation is supposed to be cryptographically secure."><title>CryptoRng in bdk_chain::bitcoin::secp256k1::rand::prelude - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../../../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../../../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../../../../static.files/rustdoc-46132b98.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="bdk_chain" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0-nightly (a4cb3c831 2024-12-17)" data-channel="nightly" data-search-js="search-036cda7a.js" data-settings-js="settings-0f613d39.js" ><script src="../../../../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../../../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../../../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../../../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../../../../bdk_chain/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../../../bdk_chain/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt="logo"></a><h2><a href="../../../../../bdk_chain/index.html">bdk_<wbr>chain</a><span class="version">0.21.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Crypto<wbr>Rng</a></h2><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-CryptoRng-for-%26mut+R" title="&'a mut R">&'a mut R</a></li><li><a href="#impl-CryptoRng-for-Box%3CR%3E" title="Box<R>">Box<R></a></li><li><a href="#impl-CryptoRng-for-ChaCha12Core" title="ChaCha12Core">ChaCha12Core</a></li><li><a href="#impl-CryptoRng-for-ChaCha12Rng" title="ChaCha12Rng">ChaCha12Rng</a></li><li><a href="#impl-CryptoRng-for-ChaCha20Core" title="ChaCha20Core">ChaCha20Core</a></li><li><a href="#impl-CryptoRng-for-ChaCha20Rng" title="ChaCha20Rng">ChaCha20Rng</a></li><li><a href="#impl-CryptoRng-for-ChaCha8Core" title="ChaCha8Core">ChaCha8Core</a></li><li><a href="#impl-CryptoRng-for-ChaCha8Rng" title="ChaCha8Rng">ChaCha8Rng</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bdk_<wbr>chain::<wbr>bitcoin::<wbr>secp256k1::<wbr>rand::<wbr>prelude</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../../../../index.html">bdk_chain</a>::<wbr><a href="../../../index.html">bitcoin</a>::<wbr><a href="../../index.html">secp256k1</a>::<wbr><a href="../index.html">rand</a>::<wbr><a href="index.html">prelude</a></span><h1>Trait <span class="trait">CryptoRng</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="https://rust-random.github.io/rand/src/rand_core/lib.rs.html#209">Source</a> </span></div><pre class="rust item-decl"><code>pub trait CryptoRng { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A marker trait used to indicate that an <a href="../trait.RngCore.html" title="trait bdk_chain::bitcoin::secp256k1::rand::RngCore"><code>RngCore</code></a> or <a href="https://rust-random.github.io/rand/rand_core/block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore"><code>BlockRngCore</code></a>
2 implementation is supposed to be cryptographically secure.</p>
3 <p><em>Cryptographically secure generators</em>, also known as <em>CSPRNGs</em>, should
4 satisfy an additional properties over other generators: given the first
5 <em>k</em> bits of an algorithm’s output
6 sequence, it should not be possible using polynomial-time algorithms to
7 predict the next bit with probability significantly greater than 50%.</p>
8 <p>Some generators may satisfy an additional property, however this is not
9 required by this trait: if the CSPRNG’s state is revealed, it should not be
10 computationally-feasible to reconstruct output prior to this. Some other
11 generators allow backwards-computation and are considered <em>reversible</em>.</p>
12 <p>Note that this trait is provided for guidance only and cannot guarantee
13 suitability for cryptographic applications. In general it should only be
14 implemented for well-reviewed code implementing well-regarded algorithms.</p>
15 <p>Note also that use of a <code>CryptoRng</code> does not protect against other
16 weaknesses such as seeding from a weak entropy source or leaking state.</p>
17 </div></details><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-CryptoRng-for-ChaCha8Core" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_chacha/chacha.rs.html#345">Source</a><a href="#impl-CryptoRng-for-ChaCha8Core" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_chacha/chacha/struct.ChaCha8Core.html" title="struct rand_chacha::chacha::ChaCha8Core">ChaCha8Core</a></h3></section><section id="impl-CryptoRng-for-ChaCha8Rng" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_chacha/chacha.rs.html#345">Source</a><a href="#impl-CryptoRng-for-ChaCha8Rng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_chacha/chacha/struct.ChaCha8Rng.html" title="struct rand_chacha::chacha::ChaCha8Rng">ChaCha8Rng</a></h3></section><section id="impl-CryptoRng-for-ChaCha12Core" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_chacha/chacha.rs.html#344">Source</a><a href="#impl-CryptoRng-for-ChaCha12Core" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_chacha/chacha/struct.ChaCha12Core.html" title="struct rand_chacha::chacha::ChaCha12Core">ChaCha12Core</a></h3></section><section id="impl-CryptoRng-for-ChaCha12Rng" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_chacha/chacha.rs.html#344">Source</a><a href="#impl-CryptoRng-for-ChaCha12Rng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_chacha/chacha/struct.ChaCha12Rng.html" title="struct rand_chacha::chacha::ChaCha12Rng">ChaCha12Rng</a></h3></section><section id="impl-CryptoRng-for-ChaCha20Core" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_chacha/chacha.rs.html#343">Source</a><a href="#impl-CryptoRng-for-ChaCha20Core" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_chacha/chacha/struct.ChaCha20Core.html" title="struct rand_chacha::chacha::ChaCha20Core">ChaCha20Core</a></h3></section><section id="impl-CryptoRng-for-ChaCha20Rng" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_chacha/chacha.rs.html#343">Source</a><a href="#impl-CryptoRng-for-ChaCha20Rng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_chacha/chacha/struct.ChaCha20Rng.html" title="struct rand_chacha::chacha::ChaCha20Rng">ChaCha20Rng</a></h3></section><section id="impl-CryptoRng-for-%26mut+R" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_core/lib.rs.html#481">Source</a><a href="#impl-CryptoRng-for-%26mut+R" class="anchor">§</a><h3 class="code-header">impl<'a, R> <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut R</a><div class="where">where
18 R: <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section><section id="impl-CryptoRng-for-Box%3CR%3E" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_core/lib.rs.html#485">Source</a><a href="#impl-CryptoRng-for-Box%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><R><div class="where">where
19 R: <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-CryptoRng-for-OsRng" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_core/os.rs.html#50">Source</a><a href="#impl-CryptoRng-for-OsRng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="../rngs/struct.OsRng.html" title="struct bdk_chain::bitcoin::secp256k1::rand::rngs::OsRng">OsRng</a></h3></section><section id="impl-CryptoRng-for-StdRng" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/rngs/std.rs.html#72">Source</a><a href="#impl-CryptoRng-for-StdRng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="../rngs/struct.StdRng.html" title="struct bdk_chain::bitcoin::secp256k1::rand::rngs::StdRng">StdRng</a></h3></section><section id="impl-CryptoRng-for-ThreadRng" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/rngs/thread.rs.html#131">Source</a><a href="#impl-CryptoRng-for-ThreadRng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="../rngs/struct.ThreadRng.html" title="struct bdk_chain::bitcoin::secp256k1::rand::rngs::ThreadRng">ThreadRng</a></h3></section><section id="impl-CryptoRng-for-BlockRng%3CR%3E" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand_core/block.rs.html#431">Source</a><a href="#impl-CryptoRng-for-BlockRng%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="https://rust-random.github.io/rand/rand_core/block/struct.BlockRng.html" title="struct rand_core::block::BlockRng">BlockRng</a><R><div class="where">where
20 R: <a class="trait" href="https://rust-random.github.io/rand/rand_core/block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore">BlockRngCore</a> + <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a>,</div></h3></section><section id="impl-CryptoRng-for-ReseedingRng%3CR,+Rsdr%3E" class="impl"><a class="src rightside" href="https://rust-random.github.io/rand/src/rand/rngs/adapter/reseeding.rs.html#149-152">Source</a><a href="#impl-CryptoRng-for-ReseedingRng%3CR,+Rsdr%3E" class="anchor">§</a><h3 class="code-header">impl<R, Rsdr> <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a> for <a class="struct" href="../rngs/adapter/struct.ReseedingRng.html" title="struct bdk_chain::bitcoin::secp256k1::rand::rngs::adapter::ReseedingRng">ReseedingRng</a><R, Rsdr><div class="where">where
21 R: <a class="trait" href="https://rust-random.github.io/rand/rand_core/block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore">BlockRngCore</a> + <a class="trait" href="../trait.SeedableRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::SeedableRng">SeedableRng</a> + <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a>,
22 Rsdr: <a class="trait" href="../trait.RngCore.html" title="trait bdk_chain::bitcoin::secp256k1::rand::RngCore">RngCore</a> + <a class="trait" href="../trait.CryptoRng.html" title="trait bdk_chain::bitcoin::secp256k1::rand::CryptoRng">CryptoRng</a>,</div></h3></section></div><script src="../../../../../trait.impl/rand_core/trait.CryptoRng.js" data-ignore-extern-crates="rand,rand_core,alloc,rand_chacha" async></script></section></div></main></body></html>