Keys & Crypto¶
Keys¶
PubKey
¶
Construction Examples:
xpub661MyMwAqRbcFvXwqbgwigDczeocqeBEibKMCkoc31RiyB464Ybc1z8sWMnR38JdeCBJPPkSM7mKahcBX2nPX9KYVTz3cotpLmSkMxrp99Lpubkey(03b2123025f45648c3f31fd4b7d3e1ec3344769ab3f53dec5af9b8a9a95385cbd5)[0f9e8d7c/3]b2123025f45648c3f31fd4b7d3e1ec3344769ab3f53dec5af9b8a9a95385cbd5
→ See Key Construction and Key Structure for more details.
PubKey<SingleKey>|PubKey<Xpub>PubKey<SinglePath>|PubKey<MultiPath>PubKey<Definite>|PubKey<Indefinite>
Coerces from:
SecKey– converted into a public key (key origin preserved)Bytes<33>– single public key (with no key origin, always compressed)Bytes<32>– single x-only public key (with no key origin)Bytes<78>–Xpubencoded using the BIP32 serialization format (only the immediate parent origin is known)
To fully preserve key origin information, use the
str()/repr()encoding instead of Bytes.
Underlying type: miniscript::DescriptorPublicKey
(Not to be confused with pk())
Rust source code: src/stdlib/keys.rs:N/A
The key identifier as defined in
BIP 32
(HASH160 of the public key).
Only available for definite keys.
The key fingerprint as defined in BIP 32
(first four bytes of the identifier).
Only available for definite keys.
Aliased as: PubKey->is_xkey
Whether this key has an underived /* wildcard modifier.
Whether this is a multi-path key.
Whether this is an X-only key (X-only are always SingleKey).
The chain code as defined in BIP 32.
Only available for definite Xpub keys.
0x00000000 if there's none.
The full derivation path from the master_fingerprint.
Only available for single-path keys.
For multi-path keys, an array of all expanded derivation paths.
For single-path keys, an array with a single element equal to derivation_path.
SecKey
¶
Construction Examples:
xprv9s21ZrQH143K37CBUxq5bSXTyHwKc5KwYWsm6onCYDmiPBBDyiz3bYwvHYH9NXzsY6mDiXmhf77Ym2EJkGreLHB3s6MH5tRkfKQT9uDQ4r2L4oC7AMPJkKPwuVipfFaKcJKBhsR3kmXy89f7oAFhSQSPWLNXocJ(WIF)seckey(e215fcbcb22c3118fb1974b7188922b760b14a24f94d06d5b45d127c278aba77)
→ See Key Construction and Key Structure for more details.
SecKey<SingleKey>|SecKey<Xpriv>SecKey<SinglePath>|SecKey<MultiPath>SecKey<Definite>|SecKey<Indefinite>
Coerces from:
Bytes<32>– single secret key (with no key origin)Bytes<78>–Xprivencoded using the BIP32 serialization format (only the immediate parent origin is known)
To fully preserve key origin information, use the
str()/repr()encoding instead of Bytes.
Underlying type: miniscript::DescriptorSecretKey
Rust source code: src/stdlib/keys.rs:N/A
Aliased as: SecKey->is_xkey
SecKey->...
¶
With the exception of is_xpub and is_xonly, all of the PubKey
fields are available on SecKey too. They are not repeated here for brevity.
Generate a random single secret key.
Rust source code: src/stdlib/keys.rs:N/A
Generate a random Xpriv.
Rust source code: src/stdlib/keys.rs:N/A
Construct Xpriv from seed.
Rust source code: src/stdlib/keys.rs:N/A
Rust source code: src/stdlib/keys.rs:N/A
singles()
¶
singles(PubKey<MultiPath>) -> Array<PubKey<SinglePath>>
singles(SecKey<MultiPath>) -> Array<SecKey<SinglePath>>
singles(Policy<MultiPath>) -> Array<Policy<SinglePath>>
singles(Descriptor<MultiPath>) -> Array<Descriptor<SinglePath>>
Rust source code: src/stdlib/keys.rs:N/A
Rust source code: src/stdlib/keys.rs:N/A
Rust source code: src/stdlib/keys.rs:N/A
Derive a unique, deterministic, provably unspendable Xpub based on the given seed.
Unlike NUMS, outside observers cannot tell its unspendable without access to the seed.
Minsc source code: src/stdlib/btc.minsc:N/A
The provably unspendable NUMS key suggested in BIP 341
for use as a Taproot internal key.
Hashing¶
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Hash
¶
Signing¶
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
RNG¶
Minsc provides a CSPRNG based on the rand crate's default ThreadRng, which uses ChaCha12 with OS RNG seeding.
See its Security section for more details.
Deterministic randomness based on an explicit seed is supported by providing the seed parameter.
The seed can be any Bytes sequence (or Bytes-coercible, including Strings and Numbers),
and will be hashed using SHA256 to seed ChaCha12.
When used without a seed, the RNG is the only possible source of non-determinism in Minsc.
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Rust source code: src/stdlib/crypto.rs:N/A
Minsc source code: src/stdlib/stdlib.minsc:N/A
Minsc source code: src/stdlib/stdlib.minsc:N/A
Minsc source code: src/stdlib/stdlib.minsc:N/A
Minsc source code: src/stdlib/stdlib.minsc:N/A