arkworks-rs / crypto-primitives

Interfaces and implementations of cryptographic primitives, along with R1CS constraints for them
https://www.arkworks.rs
Apache License 2.0
175 stars 86 forks source link

AssignmentMissing when using a private PathVar witness #46

Open rozbb opened 3 years ago

rozbb commented 3 years ago

Currently, it's not possible to use PathVar::new_witness for a placeholder PathVar in the merkle module. The reason why is that it takes in a Result<Vec<T>, SynthesisError> instead of something more like Vec<Option<T>>, which is used in other sequence-like variables. The reason the latter is necessary is because the allocator needs to know how many variables to create.

This is an issue and not a PR because I don't have any good ways off the top of my head to fix this. The workaround is pretty easy (just make an arbitrary Path of the appropriate length), but that doesn't fit with how the rest of the library works.

rozbb commented 3 years ago

Note that the more immediate reason for this error is simply that PathVar::new_variable calls and_then() on its argument, regardless of the value of mode. But the bug remains even after fixing that behavior.

Pratyush commented 3 years ago

This is related to https://github.com/arkworks-rs/r1cs-std/issues/17. In the meanwhile, I would recommend allocating a "dummy" path of the appropriate (worst-case) length.