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, ConfinedEncode
and ConfinedDecode
,
which should be implemented on each type that requires to be represented
for client-side-validation. It also defines possible encoding error cases
with Error
and provides derivation macros
#[derive(ConfinedEncode, ConfinedDecode)]
, which are a part of
confined_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 fromchrono
crateminiscript
: types defined in bitcoin Miniscriptcrypto
: non-bitcoin cryptographic primitives, which include Ed25519 curve, X25519 signatures fromed25519-dalek
library and pedersen commitments + bulletproofs fromgrin_secp256k1zkp
library. 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 confined_encoding_derive as derive;
Macros§
- confined_
decode_ self - Macro simplifying decoding of a structure with a given list of fields
- confined_
encode_ list - Macro simplifying encoding for a given list of items
- hash_
encoding - Implements confined encoding for a hash type
Enums§
- Error
- Possible errors during strict encoding and decoding process
Traits§
- Confined
Decode - Binary decoding according to the strict rules that usually apply to
consensus-critical data structures. May be used for network communications.
MUST NOT be used for commitment verification: even if the commit procedure
uses
ConfinedEncode
, the actual commit verification MUST be done withCommitVerify
,TryCommitVerify
andEmbedCommitVerify
traits, which, instead of deserializing (nonce operation for commitments) repeat the commitment procedure for the revealed message and verify it against the provided commitment. - Confined
Encode - Binary encoding according to the strict rules that usually apply to
consensus-critical data structures. May be used for network communications;
in some circumstances may be used for commitment procedures; however it must
be kept in mind that sometime commitment may follow “fold” scheme
(Merklization or nested commitments) and in such cases this trait can’t be
applied. It is generally recommended for consensus-related commitments to
utilize
CommitVerify
,TryCommitVerify
andEmbedCommitVerify
traits
fromcommit_verify
module. - ReadExt
- Re-exporting extended read and write functions from bitcoin consensus
module so others may use semantic convenience
confined_encode::ReadExt
Extensions ofRead
to decode data as per Bitcoin consensus - Write
Ext - Re-exporting extended read and write functions from bitcoin consensus
module so others may use semantic convenience
confined_encode::ReadExt
Extensions ofWrite
to encode data as per Bitcoin consensus
Derive Macros§
- Confined
Decode - Derives
ConfinedDecode
implementation for the type. - Confined
Encode - Derives
ConfinedEncode
implementation for the type.