docknetwork / crypto

Rust crypto library for data privacy tools
Apache License 2.0
78 stars 21 forks source link

some crates use path to reference other creates, others do not: leading to "two version" problem #9

Closed haroldcarr closed 1 year ago

haroldcarr commented 1 year ago

I am compiling some code I added to a custom crate (here called xxxx). It has been compiling fine until I rebased to f5b61cd. Now I am getting several errors like:

error[E0308]: arguments to this function are incorrect
   --> xxxx/src/proofsystem_algo.rs:102:20
    |
102 |     statements.add(PoKSignatureBBSG1Stmt::new_statement_from_params(
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: expected struct `bbs_plus::setup::SignatureParamsG1`, found struct `SignatureParamsG1`
   --> xxxx/src/proofsystem_algo.rs:103:9
    |
103 |         sig_params.clone(),
    |         ^^^^^^^^^^^^^^^^^^
    = note: struct `SignatureParamsG1` and struct `bbs_plus::setup::SignatureParamsG1` have similar names, but are actually distinct types
note: struct `SignatureParamsG1` is defined in crate `bbs_plus`
   --> /Users/me/ws/OLABS/github-docknetwork-crypto-NEW-f5b61cd/bbs_plus/src/setup.rs:343:1
    |
343 | impl_sig_params!(SignatureParamsG1, G1Affine, G1, G2Affine, G2);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: struct `bbs_plus::setup::SignatureParamsG1` is defined in crate `bbs_plus`
   --> /Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/bbs_plus-0.11.0/src/setup.rs:343:1
    |
343 | impl_sig_params!(SignatureParamsG1, G1Affine, G1, G2Affine, G2);
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `bbs_plus` are being used?

This might be related to a cargo issue: https://github.com/rust-lang/cargo/issues/11490

Note, the top-level Cargo.lock file does have two versions of bbs_plus in it:

name = "bbs_plus"
version = "0.11.0"
dependencies = [
 "ark-bls12-381",
 "ark-ec 0.4.1",
 "ark-ff 0.4.1",
 "ark-serialize 0.4.1",
 "ark-std 0.4.0",
 "blake2",
 "digest 0.10.6",
 "dock_crypto_utils 0.9.0",
 "rayon",
 "rmp-serde",
 "schnorr_pok 0.9.0",
 "serde",
 "serde_json",
 "serde_with",
 "zeroize",
]

[[package]]
name = "bbs_plus"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9007b7a0f5ce3fe4b22e3acbbd05d7fbb13e722cb6380254ed0ae3684764602"
dependencies = [
 "ark-ec 0.4.1",
 "ark-ff 0.4.1",
 "ark-serialize 0.4.1",
 "ark-std 0.4.0",
 "digest 0.10.6",
 "dock_crypto_utils 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "rayon",
 "schnorr_pok 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 "serde",
 "serde_with",
 "zeroize",
]

I also note that some of the docknetwork/crypto crate's Cargo.toml include a path to other crates in the repo while others do not. For example: see proof_system compared to bbs_plus below.

The following output is editted and formatted for readability:

find . -type f -exec grep --color=auto -nH --null -e "version =" \{\} +

./compressed_sigma/Cargo.toml17:dock_crypto_utils = { version = "0.9.0", default-features = false }

./test_utils/Cargo.toml9:bbs_plus = { version = "0.11.0", default-features = false }
./test_utils/Cargo.toml10:schnorr_pok = { version = "0.9.0", default-features = false }
./test_utils/Cargo.toml11:vb_accumulator = { version = "0.12.0", default-features = false }
./test_utils/Cargo.toml18:proof_system = { version = "0.18.0", default-features = false, path = "../proof_system" }

./saver/Cargo.toml20:dock_crypto_utils = { version = "0.9.0", default-features = false }

./proof_system/Cargo.toml21:bbs_plus = { version = "0.11.0", default-features = false }
./proof_system/Cargo.toml22:schnorr_pok = { version = "0.9.0", default-features = false }
./proof_system/Cargo.toml23:vb_accumulator = { version = "0.12.0", default-features = false }
./proof_system/Cargo.toml24:dock_crypto_utils = { version = "0.9.0", default-features = false }
./proof_system/Cargo.toml25:saver = { version = "0.9.0", default-features = false }

./delegatable_credentials/Cargo.toml20:dock_crypto_utils = { version = "0.9.0", default-features = false }
./delegatable_credentials/Cargo.toml23:schnorr_pok = { version = "0.9.0", default-features = false }

./schnorr_pok/Cargo.toml21:dock_crypto_utils = { version = "0.9.0", default-features = false, path = "../utils" }

./vb_accumulator/Cargo.toml25:schnorr_pok = { version = "0.9.0", default-features = false, path = "../schnorr_pok" }
./vb_accumulator/Cargo.toml26:dock_crypto_utils = { version = "0.9.0", default-features = false, path = "../utils" }

./benches/Cargo.toml9:bbs_plus = { version = "0.11.0", default-features = false, path = "../bbs_plus" }
./benches/Cargo.toml10:schnorr_pok = { version = "0.9.0", default-features = false, path = "../schnorr_pok" }
./benches/Cargo.toml11:vb_accumulator = { version = "0.12.0", default-features = false, path = "../vb_accumulator" }
./benches/Cargo.toml12:test_utils = { version = "0.1.0", default-features = false, path = "../test_utils" }

./secret_sharing_and_dkg/Cargo.toml21:dock_crypto_utils = { version = "0.9.0", default-features = false }
./secret_sharing_and_dkg/Cargo.toml22:schnorr_pok = { version = "0.9.0", default-features = false }

./bbs_plus/Cargo.toml21:schnorr_pok = { version = "0.9.0", default-features = false, path = "../schnorr_pok" }
./bbs_plus/Cargo.toml22:dock_crypto_utils = { version = "0.9.0", default-features = false, path = "../utils" }

One last thing. `saver/Cargo.toml' seems to indicate the need for paths:

./saver/Cargo.toml33:#proof_system = { path = "../proof_system" }
./saver/Cargo.toml34:#bbs_plus = { path = "../bbs_plus" }

Bottom line: the rust compiler can't tell the difference between what is in the local registry and what is available via path.

I am assuming that is my problem, but maybe not.

Thank you, H

> cargo --version
cargo 1.67.1 (8ecd4f20a 2023-01-10)
> rustc --version
rustc 1.67.1 (d5a82bbd2 2023-02-07)
haroldcarr commented 1 year ago

Solution: build my crate in its own repo and only depend on public docknetwork crypto crates.

FWIW: I am experimenting with building a C API.