starkware-libs / cairo-lang

Apache License 2.0
1.35k stars 266 forks source link

non working `--use_poseidon` flag on `cairo-hash-program` cli arg v0.13.1 #184

Open rkdud007 opened 8 months ago

rkdud007 commented 8 months ago

Context

https://github.com/starkware-libs/cairo-lang/blob/efa9648f57568aad8f8a13fbf027d2de7c63c2c0/src/starkware/cairo/bootloaders/hash_program.py#L41 --use_poseidon flag is not working properly in this cli argument

cairo-hash-program --use_poseidon false --program compiled_cairo/v1_hdp.json
0x36b89f0e160f103b39a8a6fb0d3271833225aeea2bb00d0c1cf06f4a6de0445

cairo-hash-program --use_poseidon true --program compiled_cairo/v1_hdp.json
0x36b89f0e160f103b39a8a6fb0d3271833225aeea2bb00d0c1cf06f4a6de0445

cairo-hash-program --program compiled_cairo/v1_hdp.json
0x71e9f412ed7dd8c0cc82f15a4739e35b958e2efe9d6b5b0bed937b8389dc9f0

cairo-hash-program --use_poseidon trudddde --program compiled_cairo/v1_hdp.json
0x36b89f0e160f103b39a8a6fb0d3271833225aeea2bb00d0c1cf06f4a6de0445

basically any thing after --use_poseidon flag, will route it to hash in poseidon. And I could not even use this flag without some value ( which is pretty confusing ).

cairo-hash-program --use_poseidon --program compiled_cairo/v1_hdp.json

usage: cairo-hash-program [-h] [-v] --program PROGRAM [--flavor {Debug,Release,RelWithDebInfo}] [--use_poseidon USE_POSEIDON]
cairo-hash-program: error: argument --use_poseidon: expected one argument

Suggested change

Would like to have , simply, if I pass --use_poseidon , will consider as true ( use poseidon hash for compute program hash ) if i don't pass that flag, use pedersen as before.

parser.add_argument(
    "--use_poseidon",
    action="store_true",  # Automatically stores True if --use_poseidon is exist, otherwise False.
    help="Use Poseidon hash.",
)