Module ar_bundles.erl¶
Function Index¶
add_bundle_tags/1* | |
add_list_tags/1* | |
add_manifest_tags/2* | |
ar_bundles_test_/0* | |
assert_data_item/7* | |
check_size/2* | Force that a binary is either empty or the given number of bytes. |
check_type/2* | Ensure that a value is of the given type. |
data_item_signature_data/1 | Generate the data segment to be signed for a data item. |
data_item_signature_data/2* | |
decode_avro_name/3* | |
decode_avro_tags/2* | Decode Avro blocks (for tags) from binary. |
decode_avro_value/4* | |
decode_bundle_header/2* | |
decode_bundle_header/3* | |
decode_bundle_items/2* | |
decode_optional_field/1* | |
decode_signature/1* | Decode the signature from a binary format. |
decode_tags/1 | Decode tags from a binary format using Apache Avro. |
decode_vint/3* | |
decode_zigzag/1* | Decode a VInt encoded ZigZag integer from binary. |
deserialize/1 | Convert binary data back to a #tx record. |
deserialize/2 | |
encode_avro_string/1* | Encode a string for Avro using ZigZag and VInt encoding. |
encode_optional_field/1* | Encode an optional field (target, anchor) with a presence byte. |
encode_signature_type/1* | Only RSA 4096 is currently supported. |
encode_tags/1 | Encode tags into a binary format using Apache Avro. |
encode_tags_size/2* | |
encode_vint/1* | Encode a ZigZag integer to VInt binary format. |
encode_vint/2* | |
encode_zigzag/1* | Encode an integer using ZigZag encoding. |
enforce_valid_tx/1* | Take an item and ensure that it is of valid form. |
finalize_bundle_data/1* | |
find/2 | Find an item in a bundle-map/list and return it. |
find_single_layer/2* | An internal helper for finding an item in a single-layer of a bundle. |
format/1 | |
format/2 | |
format_binary/1* | |
format_data/2* | |
format_line/2* | |
format_line/3* | |
hd/1 | Return the first item in a bundle-map/list. |
id/1 | Return the ID of an item -- either signed or unsigned as specified. |
id/2 | |
is_signed/1 | Check if an item is signed. |
manifest/1 | |
manifest_item/1 | Return the manifest item in a bundle-map/list. |
map/1 | Convert an item containing a map or list into an Erlang map. |
maybe_map_to_list/1* | |
maybe_unbundle/1* | |
maybe_unbundle_map/1* | |
member/2 | Check if an item exists in a bundle-map/list. |
new_item/4 | Create a new data item. |
new_manifest/1* | |
normalize/1 | |
normalize_data/1* | Ensure that a data item (potentially containing a map or list) has a standard, serialized form. |
normalize_data_size/1* | Reset the data size of a data item. |
ok_or_throw/3* | Throw an error if the given value is not ok. |
parse_manifest/1 | |
print/1 | |
reset_ids/1 | Re-calculate both of the IDs for an item. |
run_test/0* | |
serialize/1 | Convert a #tx record to its binary representation. |
serialize/2 | |
serialize_bundle_data/2* | |
sign_item/2 | Sign a data item. |
signer/1 | Return the address of the signer of an item, if it is signed. |
test_basic_member_id/0* | |
test_bundle_map/0* | |
test_bundle_with_one_item/0* | |
test_bundle_with_two_items/0* | |
test_deep_member/0* | |
test_empty_bundle/0* | |
test_extremely_large_bundle/0* | |
test_no_tags/0* | |
test_recursive_bundle/0* | |
test_serialize_deserialize_deep_signed_bundle/0* | |
test_unsigned_data_item_id/0* | |
test_unsigned_data_item_normalization/0* | |
test_with_tags/0* | |
test_with_zero_length_tag/0* | |
to_serialized_pair/1* | |
type/1 | |
unbundle/1* | |
unbundle_list/1* | |
update_ids/1* | Take an item and ensure that both the unsigned and signed IDs are appropriately set. |
utf8_encoded/1* | Encode a UTF-8 string to binary. |
verify_data_item_id/1* | Verify the data item's ID matches the signature. |
verify_data_item_signature/1* | Verify the data item's signature. |
verify_data_item_tags/1* | Verify the validity of the data item's tags. |
verify_item/1 | Verify the validity of a data item. |
Function Details¶
add_bundle_tags/1 *¶
add_bundle_tags(Tags) -> any()
add_list_tags/1 *¶
add_list_tags(Tags) -> any()
add_manifest_tags/2 *¶
add_manifest_tags(Tags, ManifestID) -> any()
ar_bundles_test_/0 *¶
ar_bundles_test_() -> any()
assert_data_item/7 *¶
assert_data_item(KeyType, Owner, Target, Anchor, Tags, Data, DataItem) -> any()
check_size/2 *¶
check_size(Bin, Sizes) -> any()
Force that a binary is either empty or the given number of bytes.
check_type/2 *¶
check_type(Value, X2) -> any()
Ensure that a value is of the given type.
data_item_signature_data/1¶
data_item_signature_data(RawItem) -> any()
Generate the data segment to be signed for a data item.
data_item_signature_data/2 *¶
data_item_signature_data(RawItem, X2) -> any()
decode_avro_name/3 *¶
decode_avro_name(NameSize, Rest, Count) -> any()
decode_avro_tags/2 *¶
decode_avro_tags(Binary, Count) -> any()
Decode Avro blocks (for tags) from binary.
decode_avro_value/4 *¶
decode_avro_value(ValueSize, Name, Rest, Count) -> any()
decode_bundle_header/2 *¶
decode_bundle_header(Count, Bin) -> any()
decode_bundle_header/3 *¶
decode_bundle_header(Count, ItemsBin, Header) -> any()
decode_bundle_items/2 *¶
decode_bundle_items(RestItems, ItemsBin) -> any()
decode_optional_field/1 *¶
decode_optional_field(X1) -> any()
decode_signature/1 *¶
decode_signature(Other) -> any()
Decode the signature from a binary format. Only RSA 4096 is currently supported.
Note: the signature type '1' corresponds to RSA 4096 - but it is is written in
little-endian format which is why we match on <<1, 0>>
.
decode_tags/1¶
decode_tags(X1) -> any()
Decode tags from a binary format using Apache Avro.
decode_vint/3 *¶
decode_vint(X1, Result, Shift) -> any()
decode_zigzag/1 *¶
decode_zigzag(Binary) -> any()
Decode a VInt encoded ZigZag integer from binary.
deserialize/1¶
deserialize(Binary) -> any()
Convert binary data back to a #tx record.
deserialize/2¶
deserialize(Item, X2) -> any()
encode_avro_string/1 *¶
encode_avro_string(String) -> any()
Encode a string for Avro using ZigZag and VInt encoding.
encode_optional_field/1 *¶
encode_optional_field(Field) -> any()
Encode an optional field (target, anchor) with a presence byte.
encode_signature_type/1 *¶
encode_signature_type(X1) -> any()
Only RSA 4096 is currently supported.
Note: the signature type '1' corresponds to RSA 4096 -- but it is is written in
little-endian format which is why we encode to <<1, 0>>
.
encode_tags/1¶
encode_tags(Tags) -> any()
Encode tags into a binary format using Apache Avro.
encode_tags_size/2 *¶
encode_tags_size(Tags, EncodedTags) -> any()
encode_vint/1 *¶
encode_vint(ZigZag) -> any()
Encode a ZigZag integer to VInt binary format.
encode_vint/2 *¶
encode_vint(ZigZag, Acc) -> any()
encode_zigzag/1 *¶
encode_zigzag(Int) -> any()
Encode an integer using ZigZag encoding.
enforce_valid_tx/1 *¶
enforce_valid_tx(List) -> any()
Take an item and ensure that it is of valid form. Useful for ensuring that a message is viable for serialization/deserialization before execution. This function should throw simple, easy to follow errors to aid devs in debugging issues.
finalize_bundle_data/1 *¶
finalize_bundle_data(Processed) -> any()
find/2¶
find(Key, Map) -> any()
Find an item in a bundle-map/list and return it.
find_single_layer/2 *¶
find_single_layer(UnsignedID, TX) -> any()
An internal helper for finding an item in a single-layer of a bundle.
Does not recurse! You probably want find/2
in most cases.
format/1¶
format(Item) -> any()
format/2¶
format(Item, Indent) -> any()
format_binary/1 *¶
format_binary(Bin) -> any()
format_data/2 *¶
format_data(Item, Indent) -> any()
format_line/2 *¶
format_line(Str, Indent) -> any()
format_line/3 *¶
format_line(RawStr, Fmt, Ind) -> any()
hd/1¶
hd(Tx) -> any()
Return the first item in a bundle-map/list.
id/1¶
id(Item) -> any()
Return the ID of an item -- either signed or unsigned as specified.
If the item is unsigned and the user requests the signed ID, we return
the atom not_signed
. In all other cases, we return the ID of the item.
id/2¶
id(Item, Type) -> any()
is_signed/1¶
is_signed(Item) -> any()
Check if an item is signed.
manifest/1¶
manifest(Map) -> any()
manifest_item/1¶
manifest_item(Tx) -> any()
Return the manifest item in a bundle-map/list.
map/1¶
map(Tx) -> any()
Convert an item containing a map or list into an Erlang map.
maybe_map_to_list/1 *¶
maybe_map_to_list(Item) -> any()
maybe_unbundle/1 *¶
maybe_unbundle(Item) -> any()
maybe_unbundle_map/1 *¶
maybe_unbundle_map(Bundle) -> any()
member/2¶
member(Key, Item) -> any()
Check if an item exists in a bundle-map/list.
new_item/4¶
new_item(Target, Anchor, Tags, Data) -> any()
Create a new data item. Should only be used for testing.
new_manifest/1 *¶
new_manifest(Index) -> any()
normalize/1¶
normalize(Item) -> any()
normalize_data/1 *¶
normalize_data(Bundle) -> any()
Ensure that a data item (potentially containing a map or list) has a standard, serialized form.
normalize_data_size/1 *¶
normalize_data_size(Item) -> any()
Reset the data size of a data item. Assumes that the data is already normalized.
ok_or_throw/3 *¶
ok_or_throw(TX, X2, Error) -> any()
Throw an error if the given value is not ok.
parse_manifest/1¶
parse_manifest(Item) -> any()
print/1¶
print(Item) -> any()
reset_ids/1¶
reset_ids(Item) -> any()
Re-calculate both of the IDs for an item. This is a wrapper
function around update_id/1
that ensures both IDs are set from
scratch.
run_test/0 *¶
run_test() -> any()
serialize/1¶
serialize(TX) -> any()
Convert a #tx record to its binary representation.
serialize/2¶
serialize(TX, X2) -> any()
serialize_bundle_data/2 *¶
serialize_bundle_data(Map, Manifest) -> any()
sign_item/2¶
sign_item(RawItem, X2) -> any()
Sign a data item.
signer/1¶
signer(Tx) -> any()
Return the address of the signer of an item, if it is signed.
test_basic_member_id/0 *¶
test_basic_member_id() -> any()
test_bundle_map/0 *¶
test_bundle_map() -> any()
test_bundle_with_one_item/0 *¶
test_bundle_with_one_item() -> any()
test_bundle_with_two_items/0 *¶
test_bundle_with_two_items() -> any()
test_deep_member/0 *¶
test_deep_member() -> any()
test_empty_bundle/0 *¶
test_empty_bundle() -> any()
test_extremely_large_bundle/0 *¶
test_extremely_large_bundle() -> any()
test_no_tags/0 *¶
test_no_tags() -> any()
test_recursive_bundle/0 *¶
test_recursive_bundle() -> any()
test_serialize_deserialize_deep_signed_bundle/0 *¶
test_serialize_deserialize_deep_signed_bundle() -> any()
test_unsigned_data_item_id/0 *¶
test_unsigned_data_item_id() -> any()
test_unsigned_data_item_normalization/0 *¶
test_unsigned_data_item_normalization() -> any()
test_with_tags/0 *¶
test_with_tags() -> any()
test_with_zero_length_tag/0 *¶
test_with_zero_length_tag() -> any()
to_serialized_pair/1 *¶
to_serialized_pair(Item) -> any()
type/1¶
type(Item) -> any()
unbundle/1 *¶
unbundle(Item) -> any()
unbundle_list/1 *¶
unbundle_list(Item) -> any()
update_ids/1 *¶
update_ids(Item) -> any()
Take an item and ensure that both the unsigned and signed IDs are appropriately set. This function is structured to fall through all cases of poorly formed items, recursively ensuring its correctness for each case until the item has a coherent set of IDs. The cases in turn are: - The item has no unsigned_id. This is never valid. - The item has the default signature and ID. This is valid. - The item has the default signature but a non-default ID. Reset the ID. - The item has a signature. We calculate the ID from the signature. - Valid: The item is fully formed and has both an unsigned and signed ID.
utf8_encoded/1 *¶
utf8_encoded(String) -> any()
Encode a UTF-8 string to binary.
verify_data_item_id/1 *¶
verify_data_item_id(DataItem) -> any()
Verify the data item's ID matches the signature.
verify_data_item_signature/1 *¶
verify_data_item_signature(DataItem) -> any()
Verify the data item's signature.
verify_data_item_tags/1 *¶
verify_data_item_tags(DataItem) -> any()
Verify the validity of the data item's tags.
verify_item/1¶
verify_item(DataItem) -> any()
Verify the validity of a data item.