ElementsProject / elements-miniscript

Creative Commons Zero v1.0 Universal
11 stars 14 forks source link

Introduce 64 bit arithmetic expressions #26

Closed sanket1729 closed 2 years ago

sanket1729 commented 2 years ago
apoelstra commented 2 years ago

Overall this looks really great! The last commit makes me worry that the code will start to become unweildy the more things we add to instrospect, but it's fine to clean that up in a later PR.

One thing I don't fully grok is why we always have the user provide a value then VERIFY that it matches the introspected value. Couldn't we just let the user do this herself using the Arith::Eq fragement, if needed?

sanket1729 commented 2 years ago

@apoelstra

user provide a value then VERIFY that it matches the introspected value.

I don't fully understand this. The user does not provide a value. All values are taken from transaction introspection or are fixed constants. The VERIFY in the inner fragments asserts that the value is explicit. We need this to compose with other arithmetic operations.

Recall that INSPECTXXXVALUE pushes two things on stack . We are asserting the prefix in the inner fragment. And we are checking the value equality in the Eq fragment along with overflow check.

sanket1729 commented 2 years ago

The last commit makes me worry that the code will start to become unweildy the more things we add to instrospect, but it's fine to clean that up in a later PR.

FTR, I don't see us adding any more things. But I also don't know any way to clean up these things.

apoelstra commented 2 years ago

The VERIFY in the inner fragments asserts that the value is explicit. We need this to compose with other arithmetic operations.

Oh, derp, thank you. I forgot this.

FTR, I don't see us adding any more things. But I also don't know any way to clean up these things.

Well, it adds a whole bunch of function parameters that maybe could be simplified a bit with a TxEnv-like structure.