Welcome to bbclib’s documentation!¶
bbclib package¶
Subpackages¶
bbclib.compat package¶
Submodules¶
bbclib.compat.bbclib module¶
Copyright (c) 2019 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.compat.bbclib.
BBcAsset
(user_id=None, asset_file=None, asset_body=None, format_type=0, id_length=32)[source]¶ Bases:
object
Asset part in a transaction
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
deserialize_obj
(obj)[source]¶ Deserialize bson/msgpack data into this object
Parameters: obj (bytes) – object data Returns: True if successful Return type: bool
-
digest
()[source]¶ Calculate the digest
The digest corresponds to the asset_id of this object
Returns: asset_id (or digest) Return type: bytes
-
get_asset_file
()[source]¶ Get asset file content and its digest
Returns: digest of the file content bytes: the file content Return type: bytes
-
-
class
bbclib.compat.bbclib.
BBcCrossRef
(domain_id=None, transaction_id=None, deserialize=None, format_type=0)[source]¶ Bases:
object
CrossRef part in a transaction
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
BBcEvent
(asset_group_id=None, format_type=0, id_length=32)[source]¶ Bases:
object
Event part in a transaction
-
add
(asset_group_id=None, reference_index=None, mandatory_approver=None, option_approver_num_numerator=0, option_approver_num_denominator=0, option_approver=None, asset=None)[source]¶ Add parts
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
BBcFormat
[source]¶ Bases:
object
-
FORMAT_BINARY
= 0¶
-
FORMAT_BSON
= 1¶
-
FORMAT_BSON_COMPRESS_BZ2
= 2¶
-
FORMAT_BSON_COMPRESS_ZLIB
= 3¶
-
FORMAT_MSGPACK
= 4¶
-
FORMAT_MSGPACK_COMPRESS_BZ2
= 5¶
-
FORMAT_MSGPACK_COMPRESS_ZLIB
= 6¶
-
-
class
bbclib.compat.bbclib.
BBcPointer
(transaction_id=None, asset_id=None, format_type=0, id_length=32)[source]¶ Bases:
object
Pointer part in a transaction
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
BBcReference
(asset_group_id, transaction, ref_transaction=None, event_index_in_ref=0, format_type=0, id_length=32)[source]¶ Bases:
object
Reference part in a transaction
-
add_signature
(user_id=None, signature=None)[source]¶ Add signature in the reserved space
Parameters: - user_id (bytes) – user_id of the signature owner
- signature (BBcSignature) – signature
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
BBcRelation
(asset_group_id=None, format_type=0, id_length=32)[source]¶ Bases:
object
Relation part in a transaction
-
deserialize
(data)[source]¶ Deserialize bson data into this object
Parameters: data (dict) – bson data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
BBcSignature
(key_type=2, deserialize=None, format_type=0)[source]¶ Bases:
object
Signature part in a transaction
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
BBcTransaction
(version=1, deserialize=None, format_type=0, id_length=32)[source]¶ Bases:
object
Transaction object
-
WITH_WIRE
= True¶
-
add_signature
(user_id=None, signature=None)[source]¶ Add signature in the reserved space
Parameters: - user_id (bytes) – user_id of the signature owner
- signature (BBcSignature) – signature
Returns: True if successful
Return type: bool
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
deserialize_obj
(data)[source]¶ Deserialize bson/msgpack data into this object
Parameters: data (bytes) – object data Returns: True if successful Return type: bool
-
digest
()[source]¶ Calculate the digest
The digest corresponds to the transaction_id of this object
Returns: transaction_id (or digest) Return type: bytes
-
get_sig_index
(user_id)[source]¶ Reserve a space for signature for the specified user_id
Parameters: user_id (bytes) – user_id whose signature will be added to the signature part Returns: position (index) in the signature part Return type: int
-
sign
(key_type=2, private_key=None, public_key=None, keypair=None)[source]¶ Sign the transaction
Parameters: - key_type (int) – Type of encryption key’s curve
- private_key (bytes) –
- public_key (bytes) –
- keypair (KeyPair) – keypair or set of private_key and public_key needs to be given
Returns: Return type:
-
-
class
bbclib.compat.bbclib.
BBcWitness
(format_type=0, id_length=32)[source]¶ Bases:
object
Witness part in a transaction
-
add_signature
(user_id=None, signature=None)[source]¶ Add signature in the reserved space for the user_id that was registered before
Parameters: - user_id (bytes) – user_id of the signature owner
- signature (bytes) – signature
-
deserialize
(data)[source]¶ Deserialize into this object
Parameters: data (bytes) – serialized binary data Returns: True if successful Return type: bool
-
-
class
bbclib.compat.bbclib.
KeyPair
(curvetype=2, compression=False, privkey=None, pubkey=None)[source]¶ Bases:
object
-
POINT_CONVERSION_COMPRESSED
= 2¶
-
POINT_CONVERSION_UNCOMPRESSED
= 4¶ Key pair container
-
import_publickey_cert_pem
(cert_pemstring, privkey_pemstring=None)[source]¶ Verify and import X509 public key certificate in pem format
-
mk_keyobj_from_private_key_der
(derdat)[source]¶ Make a keypair object from the private key in DER format
-
mk_keyobj_from_private_key_pem
(pemdat_string)[source]¶ Make a keypair object from the private key in PEM format
-
-
class
bbclib.compat.bbclib.
KeyPairFast
(curvetype=2, compression=False, privkey=None, pubkey=None)[source]¶ Bases:
object
-
POINT_CONVERSION_COMPRESSED
= 2¶
-
POINT_CONVERSION_UNCOMPRESSED
= 4¶ Key pair container
-
import_publickey_cert_pem
(cert_pemstring, privkey_pemstring=None)[source]¶ Verify and import X509 public key certificate in pem format
-
mk_keyobj_from_private_key_der
(derdat)[source]¶ Make a keypair object from the private key in DER format
-
mk_keyobj_from_private_key_pem
(pemdat_string)[source]¶ Make a keypair object from the private key in PEM format
-
-
class
bbclib.compat.bbclib.
KeyType
[source]¶ Bases:
object
-
ECDSA_P256v1
= 2¶
-
ECDSA_SECP256k1
= 1¶
-
NOT_INITIALIZED
= 0¶
-
-
class
bbclib.compat.bbclib.
MsgType
[source]¶ Bases:
object
Message types for between core node and client
-
CANCEL_INSERT_NOTIFICATION
= 16¶
-
DOMAIN_PING
= 12¶
-
MESSAGE
= 66¶
-
NOTIFY_CROSS_REF
= 74¶
-
NOTIFY_DOMAIN_KEY_UPDATE
= 19¶
-
NOTIFY_INSERTED
= 73¶
-
REGISTER
= 64¶
-
REQUEST_CLOSE_DOMAIN
= 31¶
-
REQUEST_COUNT_TRANSACTIONS
= 95¶
-
REQUEST_CROSS_REF_LIST
= 92¶
-
REQUEST_CROSS_REF_VERIFY
= 90¶
-
REQUEST_ECDH_KEY_EXCHANGE
= 33¶
-
REQUEST_GATHER_SIGNATURE
= 67¶
-
REQUEST_GET_CONFIG
= 8¶
-
REQUEST_GET_DOMAINLIST
= 13¶
-
REQUEST_GET_FORWARDING_LIST
= 25¶
-
REQUEST_GET_NEIGHBORLIST
= 21¶
-
REQUEST_GET_NODEID
= 27¶
-
REQUEST_GET_NOTIFICATION_LIST
= 29¶
-
REQUEST_GET_STATS
= 17¶
-
REQUEST_GET_USERS
= 23¶
-
REQUEST_INSERT
= 71¶
-
REQUEST_INSERT_NOTIFICATION
= 15¶
-
REQUEST_MANIP_LEDGER_SUBSYS
= 10¶
-
REQUEST_REGISTER_HASH_IN_SUBSYS
= 128¶
-
REQUEST_REPAIR
= 94¶
-
REQUEST_SEARCH_TRANSACTION
= 82¶
-
REQUEST_SEARCH_WITH_CONDITIONS
= 86¶
-
REQUEST_SETUP_DOMAIN
= 0¶
-
REQUEST_SET_STATIC_NODE
= 4¶
-
REQUEST_SIGNATURE
= 69¶
-
REQUEST_TRAVERSE_TRANSACTIONS
= 88¶
-
REQUEST_VERIFY_HASH_IN_SUBSYS
= 130¶
-
RESPONSE_CLOSE_DOMAIN
= 32¶
-
RESPONSE_COUNT_TRANSACTIONS
= 95¶
-
RESPONSE_CROSS_REF_LIST
= 93¶
-
RESPONSE_CROSS_REF_VERIFY
= 91¶
-
RESPONSE_ECDH_KEY_EXCHANGE
= 34¶
-
RESPONSE_GATHER_SIGNATURE
= 68¶
-
RESPONSE_GET_CONFIG
= 9¶
-
RESPONSE_GET_DOMAINLIST
= 14¶
-
RESPONSE_GET_FORWARDING_LIST
= 26¶
-
RESPONSE_GET_NEIGHBORLIST
= 22¶
-
RESPONSE_GET_NODEID
= 28¶
-
RESPONSE_GET_NOTIFICATION_LIST
= 30¶
-
RESPONSE_GET_STATS
= 18¶
-
RESPONSE_GET_USERS
= 24¶
-
RESPONSE_INSERT
= 72¶
-
RESPONSE_MANIP_LEDGER_SUBSYS
= 11¶
-
RESPONSE_REGISTER_HASH_IN_SUBSYS
= 129¶
-
RESPONSE_SEARCH_TRANSACTION
= 83¶
-
RESPONSE_SEARCH_WITH_CONDITIONS
= 87¶
-
RESPONSE_SETUP_DOMAIN
= 1¶
-
RESPONSE_SET_STATIC_NODE
= 5¶
-
RESPONSE_SIGNATURE
= 70¶
-
RESPONSE_TRAVERSE_TRANSACTIONS
= 89¶
-
RESPONSE_VERIFY_HASH_IN_SUBSYS
= 131¶
-
UNREGISTER
= 65¶
-
-
bbclib.compat.bbclib.
add_event_asset
(transaction, event_idx, asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to add BBcEvent object with BBcAsset in the transaction
-
bbclib.compat.bbclib.
add_pointer_in_relation
(relation, ref_transaction_id=None, ref_asset_id=None)[source]¶ Utility to add BBcRelation object with BBcPointer in the BBcRelation object
-
bbclib.compat.bbclib.
add_reference_to_transaction
(transaction, asset_group_id, ref_transaction_obj, event_index_in_ref)[source]¶ Utility to add BBcReference object in the transaction
Returns: Return type: BBcReference
-
bbclib.compat.bbclib.
add_relation_asset
(transaction, relation_idx, asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to add BBcRelation object with BBcAsset in the transaction
-
bbclib.compat.bbclib.
add_relation_pointer
(transaction, relation_idx, ref_transaction_id=None, ref_asset_id=None)[source]¶ Utility to add BBcRelation object with BBcPointer in the transaction
-
bbclib.compat.bbclib.
convert_id_to_string
(data, bytelen=32)[source]¶ Convert binary data to hex string
-
bbclib.compat.bbclib.
convert_idstring_to_bytes
(datastr, bytelen=32)[source]¶ Convert hex string to binary data
-
bbclib.compat.bbclib.
deep_copy_with_key_stringify
(u, d=None)[source]¶ Utility for updating nested dictionary
-
bbclib.compat.bbclib.
get_new_id
(seed_str=None, include_timestamp=True)[source]¶ Return 256-bit binary data
Parameters: - seed_str (str) – seed string that is hashed by SHA256
- include_timestamp (bool) – if True, timestamp (current time) is appended to the seed string
Returns: 256-bit binary
Return type: bytes
-
bbclib.compat.bbclib.
get_random_id
()[source]¶ Return 256-bit binary data
Returns: 256-bit random binary Return type: bytes
-
bbclib.compat.bbclib.
make_relation_with_asset
(asset_group_id, user_id, asset_body=None, asset_file=None, format_type=0, id_length=32)[source]¶ Utility to make BBcRelation object
-
bbclib.compat.bbclib.
make_transaction
(event_num=0, relation_num=0, witness=False, format_type=0, id_length=32)[source]¶ Utility to make transaction object
Parameters: - event_num (int) – the number of BBcEvent object to include in the transaction
- relation_num (int) – the number of BBcRelation object to include in the transaction
- witness (bool) – If true, BBcWitness object is included in the transaction
- format_type (int) – Data format defined in BBcFormat class
- id_length (int) – If <32, IDs will be truncated
Returns: Return type:
-
bbclib.compat.bbclib.
recover_signature_object
(data, format_type=0)[source]¶ Deserialize signature data
-
bbclib.compat.bbclib.
validate_transaction_object
(txobj, asset_files=None)[source]¶ Validate transaction and its asset
Parameters: - txobj (BBcTransaction) – target transaction object
- asset_files (dict) – dictionary containing the asset file contents
Returns: True if valid tuple: list of valid assets tuple: list of invalid assets
Return type: bool
-
bbclib.compat.bbclib.
verify_using_cross_ref
(domain_id, transaction_id, transaction_base_digest, cross_ref_data, sigdata, format_type=0)[source]¶ Confirm the existence of the transaction using cross_ref
Parameters: - domain_id (bytes) – target domain_id
- transaction_id (bytes) – target transaction_id of which existence you want to confirm
- transaction_base_digest (bytes) – digest obtained from the outer domain
- cross_ref_data (bytes) – serialized BBcCrossRef object
- sigdata (bytes) – serialized signature
- format_type (int) – Data format type when calculating the digest (transaction_id)
Returns: True if valid
Return type: bool
Module contents¶
bbclib.libs package¶
Submodules¶
bbclib.libs.bbclib_asset module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_asset.
BBcAsset
(user_id=None, asset_file=None, asset_body=None, id_length=None, version=2)[source]¶ Bases:
object
Asset part in a transaction
-
digest
()[source]¶ Calculate the digest
The digest corresponds to the asset_id of this object
Returns: asset_id (or digest) Return type: bytes
-
get_asset_file
()[source]¶ Get asset file content and its digest
Returns: digest of the file content bytes: the file content Return type: bytes
-
bbclib.libs.bbclib_asset_hash module¶
Copyright (c) 2019 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_asset_raw module¶
Copyright (c) 2019 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_asset_raw.
BBcAssetRaw
(asset_id=None, asset_body=None, id_length=None)[source]¶ Bases:
object
AssetRaw part in a transaction
In this object, asset_id should be given externally, meaning that this object does not care about how to calculate the digest.
bbclib.libs.bbclib_config module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_crossref module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_error module¶
Copyright (c) 2019 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_event module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_event.
BBcEvent
(asset_group_id=None, id_length=None)[source]¶ Bases:
object
Event part in a transaction
bbclib.libs.bbclib_keypair module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
bbclib.libs.bbclib_keypair.
KeyPair
¶ alias of
bbclib.libs.bbclib_keypair.KeyPairPy
-
class
bbclib.libs.bbclib_keypair.
KeyPairPy
(curvetype=2, compression=False, privkey=None, pubkey=None)[source]¶ Bases:
object
-
POINT_CONVERSION_COMPRESSED
= 2¶
-
POINT_CONVERSION_UNCOMPRESSED
= 4¶ Key pair container
-
import_publickey_cert_pem
(cert_pemstring, privkey_pemstring=None)[source]¶ Verify and import X509 public key certificate in pem format
-
mk_keyobj_from_private_key
(privkey)[source]¶ Make a keypair object from the binary data of private key
-
mk_keyobj_from_private_key_der
(derdat)[source]¶ Make a keypair object from the private key in DER format
-
mk_keyobj_from_private_key_pem
(pemdat_string)[source]¶ Make a keypair object from the private key in PEM format
-
bbclib.libs.bbclib_keypair_fast module¶
bbclib.libs.bbclib_msgtype module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_msgtype.
MsgType
[source]¶ Bases:
object
Message types for between core node and client
-
CANCEL_INSERT_NOTIFICATION
= 16¶
-
DOMAIN_PING
= 12¶
-
MESSAGE
= 66¶
-
NOTIFY_CROSS_REF
= 74¶
-
NOTIFY_DOMAIN_KEY_UPDATE
= 19¶
-
NOTIFY_INSERTED
= 73¶
-
REGISTER
= 64¶
-
REQUEST_CLOSE_DOMAIN
= 31¶
-
REQUEST_COUNT_TRANSACTIONS
= 95¶
-
REQUEST_CROSS_REF_LIST
= 92¶
-
REQUEST_CROSS_REF_VERIFY
= 90¶
-
REQUEST_ECDH_KEY_EXCHANGE
= 33¶
-
REQUEST_GATHER_SIGNATURE
= 67¶
-
REQUEST_GET_CONFIG
= 8¶
-
REQUEST_GET_DOMAINLIST
= 13¶
-
REQUEST_GET_FORWARDING_LIST
= 25¶
-
REQUEST_GET_NEIGHBORLIST
= 21¶
-
REQUEST_GET_NODEID
= 27¶
-
REQUEST_GET_NOTIFICATION_LIST
= 29¶
-
REQUEST_GET_STATS
= 17¶
-
REQUEST_GET_USERS
= 23¶
-
REQUEST_INSERT
= 71¶
-
REQUEST_INSERT_NOTIFICATION
= 15¶
-
REQUEST_MANIP_LEDGER_SUBSYS
= 10¶
-
REQUEST_REGISTER_HASH_IN_SUBSYS
= 128¶
-
REQUEST_REPAIR
= 94¶
-
REQUEST_SEARCH_TRANSACTION
= 82¶
-
REQUEST_SEARCH_WITH_CONDITIONS
= 86¶
-
REQUEST_SETUP_DOMAIN
= 0¶
-
REQUEST_SET_STATIC_NODE
= 4¶
-
REQUEST_SIGNATURE
= 69¶
-
REQUEST_TRAVERSE_TRANSACTIONS
= 88¶
-
REQUEST_VERIFY_HASH_IN_SUBSYS
= 130¶
-
RESPONSE_CLOSE_DOMAIN
= 32¶
-
RESPONSE_COUNT_TRANSACTIONS
= 95¶
-
RESPONSE_CROSS_REF_LIST
= 93¶
-
RESPONSE_CROSS_REF_VERIFY
= 91¶
-
RESPONSE_ECDH_KEY_EXCHANGE
= 34¶
-
RESPONSE_GATHER_SIGNATURE
= 68¶
-
RESPONSE_GET_CONFIG
= 9¶
-
RESPONSE_GET_DOMAINLIST
= 14¶
-
RESPONSE_GET_FORWARDING_LIST
= 26¶
-
RESPONSE_GET_NEIGHBORLIST
= 22¶
-
RESPONSE_GET_NODEID
= 28¶
-
RESPONSE_GET_NOTIFICATION_LIST
= 30¶
-
RESPONSE_GET_STATS
= 18¶
-
RESPONSE_GET_USERS
= 24¶
-
RESPONSE_INSERT
= 72¶
-
RESPONSE_MANIP_LEDGER_SUBSYS
= 11¶
-
RESPONSE_REGISTER_HASH_IN_SUBSYS
= 129¶
-
RESPONSE_SEARCH_TRANSACTION
= 83¶
-
RESPONSE_SEARCH_WITH_CONDITIONS
= 87¶
-
RESPONSE_SETUP_DOMAIN
= 1¶
-
RESPONSE_SET_STATIC_NODE
= 5¶
-
RESPONSE_SIGNATURE
= 70¶
-
RESPONSE_TRAVERSE_TRANSACTIONS
= 89¶
-
RESPONSE_VERIFY_HASH_IN_SUBSYS
= 131¶
-
UNREGISTER
= 65¶
-
bbclib.libs.bbclib_pointer module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_reference module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_reference.
BBcReference
(asset_group_id, transaction, ref_transaction=None, event_index_in_ref=0, id_length=None)[source]¶ Bases:
object
Reference part in a transaction
-
add_signature
(user_id=None, signature=None)[source]¶ Add signature in the reserved space
Parameters: - user_id (bytes) – user_id of the signature owner
- signature (BBcSignature) – signature
-
bbclib.libs.bbclib_relation module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_signature module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
bbclib.libs.bbclib_transaction module¶
Copyright (c) 2017 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_transaction.
BBcTransaction
(version=1, unpack=None, id_length=None)[source]¶ Bases:
object
Transaction object
-
WITH_WIRE
= False¶
-
add_signature
(user_id=None, signature=None)[source]¶ Add signature in the reserved space
Parameters: - user_id (bytes) – user_id of the signature owner
- signature (BBcSignature) – signature
Returns: True if successful
Return type: bool
-
digest
()[source]¶ Calculate the digest
The digest corresponds to the transaction_id of this object
Returns: transaction_id (or digest) Return type: bytes
-
get_sig_index
(user_id)[source]¶ Reserve a space for signature for the specified user_id
Parameters: user_id (bytes) – user_id whose signature will be added to the signature part Returns: position (index) in the signature part Return type: int
-
set_sig_index
(user_id, idx)[source]¶ Map a user_id with the index of signature list
Parameters: - user_id (bytes) – user_id whose signature will be added to the signature part
- idx (int) – index number
-
sign
(key_type=2, private_key=None, public_key=None, keypair=None, no_pubkey=False)[source]¶ Sign the transaction
Parameters: - key_type (int) – Type of encryption key’s curve
- private_key (bytes) –
- public_key (bytes) –
- keypair (KeyPair) – keypair or set of private_key and public_key needs to be given
- no_pubkey (bool) – If True, public key is not contained in the BBcSignature object (needs to be given externally when verification)
Returns: Return type:
-
bbclib.libs.bbclib_utils module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
bbclib.libs.bbclib_utils.
add_event_asset
(transaction, event_idx, asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to add BBcEvent object with BBcAsset in the transaction
-
bbclib.libs.bbclib_utils.
add_pointer_in_relation
(relation, ref_transaction_id=None, ref_asset_id=None)[source]¶ Utility to add BBcRelation object with BBcPointer in the BBcRelation object
Parameters: - relation (BBcRelation) – BBcRelation object to manipulate
- ref_transaction_id (bytes) – transaction_id of the transaction that the base transaction object refers to
- ref_asset_id (bytes) – asset_id of the asset that the transaction object refers to
-
bbclib.libs.bbclib_utils.
add_reference_to_transaction
(transaction, asset_group_id, ref_transaction_obj, event_index_in_ref)[source]¶ Utility to add BBcReference object in the transaction
Parameters: - transaction (BBcTransaction) – the base transaction object to manipulate
- asset_group_id (bytes) – asset_group_id of the asset in the object
- ref_transaction_obj (BBcTransaction) – the transaction object that the base transaction object refers to
- event_index_in_ref (int) – the number of BBcEvent object to include in the transaction that the base transaction object refers to
Returns: Return type:
-
bbclib.libs.bbclib_utils.
add_relation_asset
(transaction, relation_idx, asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to add BBcRelation object with BBcAsset in the transaction
Parameters: - transaction (BBcTransaction) – transaction object to manipulate
- relation_idx (int) – the number of BBcRelation object to include in the transaction
- asset_group_id (bytes) – asset_group_id of the asset in the object
- user_id (bytes) – user_id of the owner of the asset
- asset_body (str|bytes|dict) – asset data
- asset_file (bytes) – file data (binary) for asset
-
bbclib.libs.bbclib_utils.
add_relation_asset_hash
(transaction, relation_idx, asset_group_id, asset_ids=None)[source]¶ Utility to add BBcRelation object with BBcAssetHash in the transaction
Parameters: - transaction (BBcTransaction) – transaction object to manipulate
- relation_idx (int) – the number of BBcRelation object to include in the transaction
- asset_group_id (bytes) – asset_group_id of the asset in the object
- asset_ids (list(bytes)) – list of the identifiers of assets
-
bbclib.libs.bbclib_utils.
add_relation_asset_raw
(transaction, relation_idx, asset_group_id, asset_id=None, asset_body=None)[source]¶ Utility to add BBcRelation object with BBcAssetRaw in the transaction
Parameters: - transaction (BBcTransaction) – transaction object to manipulate
- relation_idx (int) – the number of BBcRelation object to include in the transaction
- asset_group_id (bytes) – asset_group_id of the asset in the object
- asset_id (bytes) – the identifier of the asset
- asset_body (str|bytes|dict) – asset data
-
bbclib.libs.bbclib_utils.
add_relation_pointer
(transaction, relation_idx, ref_transaction_id=None, ref_asset_id=None)[source]¶ Utility to add BBcRelation object with BBcPointer in the transaction
Parameters: - transaction (BBcTransaction) – the base transaction object to manipulate
- relation_idx (int) – the number of BBcRelation object to include in the transaction
- ref_transaction_id (bytes) – transaction_id of the transaction that the base transaction object refers to
- ref_asset_id (bytes) – asset_id of the asset that the transaction object refers to
-
bbclib.libs.bbclib_utils.
convert_id_to_string
(data, bytelen=32)[source]¶ Convert binary data to hex string
Parameters: - data (bytes) – data to convert
- bytelen (int) – length of the result
Returns: converted string
Return type: str
-
bbclib.libs.bbclib_utils.
convert_idstring_to_bytes
(datastr, bytelen=32)[source]¶ Convert hex string to binary data
Parameters: - datastr (str) – data to convert
- bytelen (int) – length of the result
Returns: converted byte data
Return type: bytes
-
bbclib.libs.bbclib_utils.
deep_copy_with_key_stringify
(u, d=None)[source]¶ Utility for updating nested dictionary
-
bbclib.libs.bbclib_utils.
get_new_id
(seed_str=None, include_timestamp=True)[source]¶ Return 256-bit binary data
Parameters: - seed_str (str) – seed string that is hashed by SHA256
- include_timestamp (bool) – if True, timestamp (current time) is appended to the seed string
Returns: 256-bit binary
Return type: bytes
-
bbclib.libs.bbclib_utils.
get_random_id
()[source]¶ Return 256-bit binary data
Returns: 256-bit random binary Return type: bytes
-
bbclib.libs.bbclib_utils.
get_random_value
(length=32)[source]¶ Return random bytes
Parameters: length (int) – length of the result Returns: random bytes Return type: bytes
-
bbclib.libs.bbclib_utils.
make_relation_with_asset
(asset_group_id, user_id, asset_body=None, asset_file=None)[source]¶ Utility to make BBcRelation object with BBcAsset
Parameters: - asset_group_id (bytes) – asset_group_id of the asset in the object
- user_id (bytes) – user_id of the owner of the asset
- asset_body (str|bytes|dict) – asset data
- asset_file (bytes) – file data (binary) for asset
Returns: created BBcRelation object
Return type:
-
bbclib.libs.bbclib_utils.
make_relation_with_asset_hash
(asset_group_id, asset_ids=None)[source]¶ Utility to make BBcRelation object with BBcAssetHash
Parameters: - asset_group_id (bytes) – asset_group_id of the asset in the object
- asset_ids (list(bytes)) – list of the identifiers of assets
Returns: created BBcRelation object
Return type:
-
bbclib.libs.bbclib_utils.
make_relation_with_asset_raw
(asset_group_id, asset_id=None, asset_body=None)[source]¶ Utility to make BBcRelation object with BBcAssetRaw
Parameters: - asset_group_id (bytes) – asset_group_id of the asset in the object
- asset_id (bytes) – the identifier of the asset
- asset_body (str|bytes|dict) – asset data
Returns: created BBcRelation object
Return type:
-
bbclib.libs.bbclib_utils.
make_transaction
(event_num=0, relation_num=0, witness=False, version=1)[source]¶ Utility to make transaction object
Parameters: - event_num (int) – the number of BBcEvent object to include in the transaction
- relation_num (int) – the number of BBcRelation object to include in the transaction
- witness (bool) – If true, BBcWitness object is included in the transaction
- version (int) – version of the transaction format
Returns: Return type:
-
bbclib.libs.bbclib_utils.
recover_signature_object
(data)[source]¶ Unpack signature data
Parameters: data (bytes) – Serialized data of BBcSignature object Returns: BBcSignature object Return type: BBcSignature
-
bbclib.libs.bbclib_utils.
validate_transaction_object
(txobj, asset_files=None)[source]¶ Validate transaction and its asset
Parameters: - txobj (BBcTransaction) – target transaction object
- asset_files (dict) – dictionary containing the asset file contents
Returns: True if valid tuple: list of valid assets tuple: list of invalid assets
Return type: bool
-
bbclib.libs.bbclib_utils.
verify_using_cross_ref
(domain_id, transaction_id, transaction_base_digest, cross_ref_data, sigdata)[source]¶ Confirm the existence of the transaction using cross_ref
Parameters: - domain_id (bytes) – target domain_id
- transaction_id (bytes) – target transaction_id of which existence you want to confirm
- transaction_base_digest (bytes) – digest obtained from the outer domain
- cross_ref_data (bytes) – packed BBcCrossRef object
- sigdata (bytes) – packed signature
Returns: True if valid
Return type: bool
bbclib.libs.bbclib_wire module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_wire.
BBcFormat
[source]¶ Bases:
object
-
FORMAT_PLAIN
= 0¶
-
FORMAT_ZLIB
= 16¶
-
bbclib.libs.bbclib_witness module¶
Copyright (c) 2018 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
class
bbclib.libs.bbclib_witness.
BBcWitness
(id_length=None)[source]¶ Bases:
object
Witness part in a transaction
-
add_signature
(user_id=None, signature=None)[source]¶ Add signature in the reserved space for the user_id that was registered before
Parameters: - user_id (bytes) – user_id of the signature owner
- signature (BBcSignature) – signature
-
Module contents¶
Module contents¶
Copyright (c) 2017 beyond-blockchain.org.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.