Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bbclib] Unreasonable structure of transactions #112

Closed
junkurihara opened this issue Oct 30, 2018 · 4 comments
Closed

[bbclib] Unreasonable structure of transactions #112

junkurihara opened this issue Oct 30, 2018 · 4 comments

Comments

@junkurihara
Copy link
Contributor

I just checked the current structure of bbclib, and found that the transaction could be composed in bson and bson+zlib in addition to the original dedicated binary format. The format of a transaction (bson, bson+zlib or dedicated one) is described OUTSIDE data structure. In fact, it is specified by the first 2 bytes of the output of bbclib, i.e., a transaction data, as a flag. I believe that from the following reason, either one of bson or dedicated format should be eliminated from the core structure of bbclib:

  • Signatures do not protect the flag in a transaction currently. This implies that attackers can modify such flags of transactions and then users cannot correctly decode such modified transactions. Hence the system could be compromised.
  • The definition bbclib is currently ambiguous. IMHO, it should be a small 'core' module to sign/verify/compose/decompose transactions, and should not be a composer of wire formats.

From the above observations, I would like to propose to define (de)composers of wire format, i.e., bson and bson+zlib, as output plugins of bbc1, and fix the transaction format only with the dedicated one.

@quvox
Copy link
Collaborator

quvox commented Nov 13, 2018

Thanks for your proposal.
As you pointed out, the format should be simpler and clearer. Although bson/bson+zlib format was implemented in v1.0, the default format is still the binary format, and there would not be strong requirements to use bson at this point. (If we have javascript based bbclib and it is widely used, the situation would be different.)

With considering backward compatibility, how about the following ideas?

  • We use the first two byte which is not protected by the signature for wire-format identifier
  • The default value 0 is for plain binary (same as the current binary format).
  • The two-byte identifier of 1 to 6 is for the backward compatibility (will be obsoleted in the near future)
  • If someone wants to compress a transaction, a new two-byte identifier will be defined and the wire-format encoder/decoder would be implemented outside bbclib.py

@junkurihara
Copy link
Contributor Author

Hello. I believe the change you proposed looks no problem and promising!

quvox added a commit that referenced this issue Nov 21, 2018
* serializing transaction object consists of packing object into binary and serializing it into wire format. (new format types are 0x0000 and 0x0010)
* refactor bbclib.py and its related files
* update documents and API documents
@quvox
Copy link
Collaborator

quvox commented Nov 21, 2018

@quvox
Copy link
Collaborator

quvox commented Nov 27, 2018

version 1.2 implelents the ideas. Note that serializing/deserializing code in apps need to be modified a bit.

@quvox quvox closed this as completed Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants