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

no way to decode program #94

Closed
apoelstra opened this issue Jun 2, 2023 · 8 comments
Closed

no way to decode program #94

apoelstra opened this issue Jun 2, 2023 · 8 comments

Comments

@apoelstra
Copy link
Collaborator

It appears that there is no canonical way to decode a program as a CommitNode; the decode_program_fresh_witness function is private.

Also, despite having "program" in the name, it does not check that the decoded node is 1->1. It should.

@apoelstra
Copy link
Collaborator Author

Also decode_program_fresh_witness crashes if you give it the hex "3f0000ff0100000000000000000000001f0200000000000000db00000000000000050700".

@uncomputable
Copy link
Collaborator

uncomputable commented Jun 2, 2023

We added this functionality to hal-simplicity a while back, using unit values as placeholders in the witness. You ended up (de)serializing RedeemNodes with dummy witnesses, but it was basically CommitNodes. I removed it today, but we could add something similar to rust-simplicity.

@apoelstra
Copy link
Collaborator Author

In #97 I fixed the issue, but I am going to do a followup PR that eliminates this logic entirely.

@uncomputable
Copy link
Collaborator

Isn't the canonical way CommitNode::decode()?

@apoelstra
Copy link
Collaborator Author

@uncomputable it could be, but CommitNode::decode() doesn't enforce that the root type is 1->1, nor should it, because it could be used to decode any expression.

I think we should change decode_program so it's the same as CommitNode::decode but also sets the root type.

@uncomputable
Copy link
Collaborator

This relates to #43 that we have no concept of "program" in the code as an "expression" of type 1 → 1. I'm not sure if it makes sense to decode arbitrary expressions. We could open another issue with the explicit goal of separating expressions from programs.

@apoelstra
Copy link
Collaborator Author

Near the bottom of #99 (which I should maybe split into multiple PRs) I add a decode_program method which basically just does CommitNode::decode followed by a typeck. I think having that method is all the "program" support that we need, and that that PR would close this issue.

@uncomputable
Copy link
Collaborator

Resolved by #99

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