snipsco / rust-paillier

A pure-Rust implementation of the Paillier encryption scheme
Other
82 stars 12 forks source link

Compiler errors #32

Closed Kycermann closed 4 years ago

Kycermann commented 4 years ago

Hello, thank you for the project.

When I run cargo run with this project in dependencies, the following errors are produced.

With the dependency removed, my hello world program compiles and runs.

I am using Ubuntu with a fresh Rust install.

Compiling framp v0.3.7
error[E0432]: unresolved import `alloc::heap`
  --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/mem.rs:18:5
   |
18 | use alloc::heap;
   |     ^^^^^^^^^^^ no `heap` in the root

error[E0433]: failed to resolve: could not find `heap` in `alloc`
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3614:46
     |
3614 |             ptr: unsafe { Unique::new(alloc::heap::EMPTY as *mut Limb) },
     |                                              ^^^^ could not find `heap` in `alloc`

error[E0407]: method `step` is not a member of trait `std::iter::Step`
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3688:5
     |
3688 | /     fn step(&self, by: &Int) -> Option<Int> {
3689 | |         Some(self + by)
3690 | |     }
     | |_____^ not a member of trait `std::iter::Step`

error[E0407]: method `steps_between_by_one` is not a member of trait `std::iter::Step`
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3707:5
     |
3707 | /     fn steps_between_by_one(start: &Self, end: &Self) -> Option<usize> {
3708 | |         Self::steps_between(start, end, &Self::one())
3709 | |     }
     | |_____^ not a member of trait `std::iter::Step`

error[E0407]: method `is_negative` is not a member of trait `std::iter::Step`
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3711:5
     |
3711 | /     fn is_negative(&self) -> bool {
3712 | |         self.sign() < 0
3713 | |     }
     | |_____^ not a member of trait `std::iter::Step`

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/lib.rs:18:1
   |
18 | #![feature(core_intrinsics, asm, heap_api, associated_consts)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/lib.rs:19:1
   |
19 | #![feature(step_trait, unique, alloc)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals': use `NonNull` instead and consider `PhantomData<T>` (if you also use `#[may_dangle]`), `Send`, and/or `Sync`
  --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:32:5
   |
32 | use std::ptr::Unique;
   |     ^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
  --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:45:5
   |
45 | use alloc::raw_vec::RawVec;
   |     ^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals': use `NonNull` instead and consider `PhantomData<T>` (if you also use `#[may_dangle]`), `Send`, and/or `Sync`
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:126:10
    |
126 |     ptr: Unique<Limb>,
    |          ^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:155:36
    |
155 |     fn with_raw_vec<F: FnOnce(&mut RawVec<Limb>)>(&mut self, f: F) {
    |                                    ^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:158:27
    |
158 |             let mut vec = RawVec::from_raw_parts(self.ptr.as_ptr(), old_cap);
    |                           ^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals': use `NonNull` instead and consider `PhantomData<T>` (if you also use `#[may_dangle]`), `Send`, and/or `Sync`
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:165:24
    |
165 |             self.ptr = Unique::new(vec.ptr());
    |                        ^^^^^^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:979:22
    |
979 |                 drop(RawVec::from_raw_parts(self.ptr.as_ptr(),
    |                      ^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals': use `NonNull` instead and consider `PhantomData<T>` (if you also use `#[may_dangle]`), `Send`, and/or `Sync`
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3614:27
     |
3614 |             ptr: unsafe { Unique::new(alloc::heap::EMPTY as *mut Limb) },
     |                           ^^^^^^^^^^^

error[E0050]: method `steps_between` has 3 parameters but the declaration in trait `std::iter::Step::steps_between` has 2
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3692:29
     |
3692 |     fn steps_between(start: &Int, end: &Int, by: &Int) -> Option<usize> {
     |                             ^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 parameters, found 3
     |
     = note: `steps_between` from trait: `fn(&Self, &Self) -> std::option::Option<usize>`

error[E0046]: not all trait items implemented, missing: `add_usize`
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3687:1
     |
3687 | impl std::iter::Step for Int {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `add_usize` in implementation
     |
     = help: implement the missing item: `fn add_usize(&self, _: usize) -> std::option::Option<Self> { todo!() }`

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:144:20
    |
144 |             *i.ptr.as_ptr() = limb;
    |                    ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:158:59
    |
158 |             let mut vec = RawVec::from_raw_parts(self.ptr.as_ptr(), old_cap);
    |                                                           ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:165:24
    |
165 |             self.ptr = Unique::new(vec.ptr());
    |                        ^^^^^^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:165:40
    |
165 |             self.ptr = Unique::new(vec.ptr());
    |                                        ^^^

error[E0308]: mismatched types
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:165:24
    |
165 |             self.ptr = Unique::new(vec.ptr());
    |                        ^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::Unique`, found enum `std::option::Option`
    |
    = note: expected struct `std::ptr::Unique<_>`
                 found enum `std::option::Option<std::ptr::Unique<_>>`

error[E0599]: no method named `cap` found for struct `alloc::raw_vec::RawVec<ll::limb::Limb>` in the current scope
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:166:31
    |
166 |             let new_cap = vec.cap();
    |                               ^^^ private field, not a method

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:187:36
    |
187 |             ret.with_raw_vec(|v| v.reserve_exact(0, cap as usize))
    |                                    ^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:224:39
    |
224 |             return unsafe { *self.ptr.as_ref() };
    |                                       ^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:288:15
    |
288 |             v.shrink_to_fit(size);
    |               ^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:631:53
    |
631 |                 std::slice::from_raw_parts(self.ptr.as_ref() as *const _ as *const u8,
    |                                                     ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:740:33
    |
740 |             Limbs::new(self.ptr.as_ref(), 0, self.abs_size())
    |                                 ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:746:36
    |
746 |             LimbsMut::new(self.ptr.as_ptr(), 0, self.abs_size())
    |                                    ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:751:32
    |
751 |         LimbsMut::new(self.ptr.as_ptr(), 0, self.cap as i32)
    |                                ^^^^^^

error[E0658]: use of unstable library feature 'raw_vec_internals': implementation detail
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:758:19
    |
758 |                 v.reserve_exact(old_cap, cap as usize - old_cap)
    |                   ^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:787:27
    |
787 |                 *self.ptr.as_ptr().offset((self.abs_size() - 1) as isize) == 0 {
    |                           ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:807:23
    |
807 |             *self.ptr.as_ptr().offset((self.abs_size() - 1) as isize)
    |                       ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
   --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:979:54
    |
979 |                 drop(RawVec::from_raw_parts(self.ptr.as_ptr(),
    |                                                      ^^^^^^

error[E0658]: use of unstable library feature 'ptr_internals'
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3565:55
     |
3565 |                         let higher = unsafe { (*i.ptr.as_ptr().offset(1)).0 } as $t;
     |                                                       ^^^^^^
...
3608 | impl_from_for_prim!(signed   i8, i16, i32, i64, isize);
     | ------------------------------------------------------- in this macro invocation
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: use of unstable library feature 'ptr_internals'
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3593:55
     |
3593 |                         let higher = unsafe { (*i.ptr.as_ptr().offset(1)).0 } as $t;
     |                                                       ^^^^^^
...
3609 | impl_from_for_prim!(unsigned u8, u16, u32, u64, usize);
     | ------------------------------------------------------- in this macro invocation
     |
     = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: use of unstable library feature 'ptr_internals'
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3614:27
     |
3614 |             ptr: unsafe { Unique::new(alloc::heap::EMPTY as *mut Limb) },
     |                           ^^^^^^^^^^^

error[E0308]: mismatched types
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3614:27
     |
3614 |             ptr: unsafe { Unique::new(alloc::heap::EMPTY as *mut Limb) },
     |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `std::ptr::Unique`, found enum `std::option::Option`
     |
     = note: expected struct `std::ptr::Unique<ll::limb::Limb>`
                  found enum `std::option::Option<std::ptr::Unique<_>>`

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
    --> /home/pixel/.cargo/registry/src/github.com-1ecc6299db9ec823/framp-0.3.7/src/int.rs:3708:9
     |
3708 |         Self::steps_between(start, end, &Self::one())
     |         ^^^^^^^^^^^^^^^^^^^ -----  ---  ------------ supplied 3 arguments
     |         |
     |         expected 2 arguments

error: aborting due to 39 previous errors

Some errors have detailed explanations: E0046, E0050, E0061, E0308, E0407, E0432, E0433, E0554, E0599...
For more information about an error, try `rustc --explain E0046`.
error: could not compile `framp`.

To learn more, run the command again with --verbose.
kali commented 4 years ago

Wow, I'm sorry to say, this library is not in a great shape, and we are not maitaining it. I managed to build it though using nightly (because there is some feature gating, not sure why) and by switching framp for num:

cargo +nightly test --no-default-features --features num

@mortendahl 's forked versions here: https://github.com/mortendahl/rust-paillier may be in a better shape.

Kycermann commented 4 years ago

Ah, I see. Thank you for getting back to me :-)