rooftopsparrow / resource-locking

Circular Storage with Partial State Operations
MIT License
1 stars 2 forks source link

Only true vs. true or false #29

Open hdemarco4 opened 7 years ago

hdemarco4 commented 7 years ago

Our FourBit only opens when all the bits are true, but the spec says that it should open when they're all true or all false. I don't think it matters on locks this small. I'm just a little worried about it.

arcturas1 commented 7 years ago

spin returns true if all the bits are the same value; regardless of whether than value is T or F. Our algorithm pushes them to T if they don't happen to all be false first, but the selection of which direction to push for is somewhat irrelevant. So long as we have a check prior to each peek/poke that ensures that spin returned false before proceeding to change any bits, it will stop if all the bits are the same value, guaranteed.

hdemarco4 commented 7 years ago

Yeah, I really don't think it would matter unless the lock was much bigger. Then time might be a problem if the lock was already mostly F, but not all.

arcturas1 commented 7 years ago

It may be so in the case of different size locks, but the general case, for an optimized solution, requires a different approach. Depending on the type of the device, it may make sense to attempt to dynamically set a "goal" state instead of assuming one in advance, however that would have to depend on both the device bit size and the disclosure size, and require some machinery to deal with how to set and when to change the goal. All of which could be interesting to play with, but is overkill for this project, since you can impose that (assuming the device isn't unlocked already) at least half of the bits are T following your first spin.

rooftopsparrow commented 7 years ago

I have a test that makes sure the unlocker works with all false. And in the case of 4/2 we're only talking about 1 of the patterns ([T, F, F, F]) etc would be better to start with F instead of T. I think it does matter for larger devices, so we should keep this issue open in case we need to address it