algebra
algebra copied to clipboard
A confusing "conflict implementation" when implementing the curves for customized trait.
I'm trying to implement a trait for a projective curve with the following code
use ark_bls12_381;
use ark_ec::PairingEngine;
pub trait CustomizedTrait {}
impl CustomizedTrait for <ark_bls12_381::Bls12_381 as PairingEngine>::G1Projective {}
impl CustomizedTrait for u64 {}
However, the rust compiler results in an error. It thinks u64
and <Bls12_381 as PairingEngine>::G1Projective
are the same type.
error[E0119]: conflicting implementations of trait `CustomizedTrait` for type `u64`:
--> src\main.rs:31:1
|
30 | impl CustomizedTrait for <ark_bls12_381::Bls12_381 as PairingEngine>::G1Projective {}
| ---------------------------------------------------------------------------------- first implementation here
31 | impl CustomizedTrait for u64 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u64`
But if I implement the trait for the projective curve directly, every things go well.
use ark_bls12_381;
use ark_ec::PairingEngine;
pub trait CustomizedTrait {}
impl CustomizedTrait for ark_bls12_381::G1Projective {}
impl CustomizedTrait for u64 {}
Have you met this problem when developing such project, especially when implementing the serialization components?
I think this is a problem with Rust atm, not our libraries; it might be related to lazy normalization. I’ll try to produce an independent example
Is this still an issue with the latest stable?
Is this still an issue with the latest stable?
Yes, this issue still exists with the most recent rust version 1.64.0 and arkworks version 0.3.0.