elliptic-curves icon indicating copy to clipboard operation
elliptic-curves copied to clipboard

Add core::fmt::Debug constraint to PrimeCurveParams::FieldElement

Open coder0xff opened this issue 1 year ago • 3 comments
trafficstars

Building with master causes the below error depending on usage.

error[E0277]: `<C as PrimeCurveParams>::FieldElement` doesn't implement `Debug`
   --> /home/coder0xff/Dropbox/Documents/Projects/Community/src/community/elliptic-curves/primeorder/src/affine.rs:290:30
    |
290 | impl<C> PrimeCurveAffine for AffinePoint<C>
    |                              ^^^^^^^^^^^^^^ `<C as PrimeCurveParams>::FieldElement` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = help: the trait `Debug` is not implemented for `<C as PrimeCurveParams>::FieldElement`
note: required for `AffinePoint<C>` to implement `Debug`
   --> /home/coder0xff/Dropbox/Documents/Projects/Community/src/community/elliptic-curves/primeorder/src/affine.rs:28:23
    |
28  | #[derive(Clone, Copy, Debug)]
    |                       ^^^^^ unsatisfied trait bound introduced in this `derive` macro
note: required by a bound in `PrimeCurveAffine`
   --> /home/coder0xff/.cargo/registry/src/index.crates.io-6f17d22bba15001f/group-0.13.0/src/prime.rs:27:7
    |
21  | pub trait PrimeCurveAffine: GroupEncoding
    |           ---------------- required by a bound in this trait
...
27  |     + fmt::Debug
    |       ^^^^^^^^^^ required by this bound in `PrimeCurveAffine`
    = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider further restricting the associated type
    |
298 |     <UncompressedPointSize<C> as ArraySize>::ArrayType<u8>: Copy, <C as PrimeCurveParams>::FieldElement: Debug
    |                                                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

coder0xff avatar Mar 12 '24 22:03 coder0xff

I'm confused what's the error you're reporting here. Everything builds for me locally and in CI.

tarcieri avatar Mar 12 '24 23:03 tarcieri

The toolchain for the embedded platform I'm working on is based on nightly Rust, so it could be caused by that. The constraint I added isn't wrong at least, as Debug isn't included in PrimeField or Invert.

coder0xff avatar Mar 13 '24 01:03 coder0xff

I can also build all of the crates in this repo locally with 1.78.0-nightly (7065f0ef4 2024-03-12).

It's unclear to me what's requiring a Debug impl in this case.

We can potentially add one, but it would be helpful to fully understand the situation first.

tarcieri avatar Mar 13 '24 02:03 tarcieri