Crate strict_encoding
source ·Expand description
Library implementing strict encoding standard, defined by LNPBP-7. Strict encoding is a binary conservative encoding extensively used in client-side-validation for deterministic portable (platform-independent) serialization of data with a known internal data structure. Strict encoding is a schema-less encoding.
As a part of strict encoding, crate also includes implementation of network address uniform encoding standard (LMPBP-42), which allows representation of any kind of network address as a fixed-size byte string occupying 37 bytes. This standard is used for the strict encoding of networking addresses.
Library defines two main traits, StrictEncode and StrictDecode,
which should be implemented on each type that requires to be represented
for client-side-validation. It also defines possible encoding error cases
with [derive@Error] and provides derivation macros
#[derive(StrictEncode, StrictDecode)], which are a part of
strict_encode_derive sub-crate and represented by a default feature
derive. Finally, it implements strict encoding traits for main data types
defined by rust standard library and frequently used crates; the latter
increases the number of dependencies and thus can be controlled with
feature flags:
chrono(used by default): date & time types fromchronocrateminiscript: types defined in bitcoin Miniscriptcrypto: non-bitcoin cryptographic primitives, which include Ed25519 curve, X25519 signatures fromed25519-daleklibrary and pedersen commitments + bulletproofs fromlnpbp_secp256k1zkplibrary. Encodings for other cryptography-related types, such as Secp256k1 and hashes, are always included as a part of the library - see NB below.
NB: this crate requires bitcoin as an upstream dependency since many of
strict-encoded formats are standardized as using bitcoin consensus
encoding.
Re-exports
pub extern crate strict_encoding_derive as derive;pub use strategies::Strategy;Modules
Macros
Structs
u32::MAX elements in strict
encoding representation.u24::MAX elements in strict
encoding representation.Enums
Traits
strict_encode::ReadExt
Extensions of Read to decode data as per Bitcoin consensusStrictEncode, the actual commit verification MUST be done with
CommitVerify, TryCommitVerify and EmbedCommitVerify traits, which,
instead of deserializing (nonce operation for commitments) repeat the
commitment procedure for the revealed message and verify it against the
provided commitment.CommitVerify, TryCommitVerify and EmbedCommitVerify traitsfrom
commit_verify module.strict_encode::ReadExt
Extensions of Write to encode data as per Bitcoin consensusFunctions
StrictDecode from any byt data source.StrictEncode into a byte vector.Derive Macros
StrictDecode implementation for the type, also providing TLV
extension support.StrictEncode implementation for the type, also providing TLV
extension support.StrictDecode implementation for the type.StrictEncode implementation for the type.