-
Notifications
You must be signed in to change notification settings - Fork 12
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
Merkle tree #99
Merkle tree #99
Conversation
Thus app icon copies norrectly in non-dockerized build, or build via make shell.
How does this relate to #96 ? |
Thanks! |
validateCryptoOptions(cryptoOptions); | ||
|
||
const getVersionResponse = await this.getVersion(); | ||
const pathSerializationVersion = (compareVersion(getVersionResponse, 0, 9, 12) <= 0) ? 0 : 1; | ||
|
||
return this.signGetChunks(path, cryptoOptions, pathSerializationVersion, message).then((chunks) => { | ||
// APDU call sequence without Merkle trees | ||
if (compareVersion(getVersionResponse, 0, 10, 3) <= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the compareVersion
function can be renamed so that the name would indicate what it does (e.g. isVersionAtLeast
or something). It's unnecessarily hard to understand what <= 0 means for its result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is quite standard three-way comparison. Maybe slightly less readable but slightly more flexible. I think I will keep it now, but I will consider this change when there is more backward compatibility code.
js/src/index.js
Outdated
@@ -98,6 +100,31 @@ export default class FlowApp { | |||
return FlowApp.prepareChunks(serializedPath, message); | |||
} | |||
|
|||
async signGetChunksv2(path, options, pathSerializationVersion, message, scriptHash) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this function. E.g.
- what are basic chunks vs. other chunks, or actually what are chunks?
- why is it async? all of the code seems synchronous in the end (or I have overlooked something)
- since there are no types, code like
scriptHash.slice(0, 16)
is incomprehensible to me; perhaps we can extract the operation ".slice(0,16)" into a function with a meaningful name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK, some suggestions for improvements in the comments.
return false; | ||
case 4: | ||
if (validateStoredTxMetadataMerkleTreeLevel(&(G_io_apdu_buffer[OFFSET_DATA]), rx - OFFSET_DATA) != PARSER_OK) { | ||
THROW(APDU_CODE_DATA_INVALID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be safest to reset the proof state before THROW. The same in case 5 and possibly elsewhere (e.g. if it is possible to send APDU 1 before APDU 0).
|
||
1. Add/modify the manifest files in `transaction_metadata` directory, modify the script to include new files. | ||
2. Copy the resulting `txMerkleTree.js` file to `js/src`. Re-build js and re-install speculos (to include newly build js). | ||
3. Take the top level hash from `txMerkleTree.js` and move it to `merkleTreeRoot` variable of `app/src/tx_metadata.c` (you need to split the hex into C array of uint8_t's). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is annoying and error-prone. It would be better if an appropriate C source file was generated by some script and included in tx_metadata.c (e.g. as with https://github.com/vacuumlabs/ledger-app-cardano-shelley/tree/develop/tokenRegistry).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I do not want to introduce anything elaborate and I want to work hands on for some time. As the comment bellow suggest, changes will be necessary very soon (backward compatibility, scaling up the processes 100s of transactions). When I will have enough information I will definitely automate this but as of now I am not sure how do this in such a way that I will not have to rework the solution soon.
Errors should be easily detected by tests, so I am not that worried about this.
return PARSER_METADATA_ERROR; | ||
} | ||
|
||
//validate that current hash is in the list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather move this calculation into a function, it's a small detail that takes too much space (and would be covered in a single statement if this was not C).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion is that this function is quite simple and this represent the the non-trivial thing the function does.
@@ -48,7 +48,7 @@ endif | |||
|
|||
APPVERSION_M=0 | |||
APPVERSION_N=10 | |||
APPVERSION_P=0 | |||
APPVERSION_P=4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we jumping from 0.10.0 to 0.10.4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am leaving space. We plan to insert a small release containing staking transactions. This will be 0.10.1. I can see 0.10.2 somehow happen. Maybe we should change it to 0.11.0. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the breaking change?
Adds Merkle tree support