Commit Graph

150 Commits

Author SHA1 Message Date
str4d 98bab6877a Add read_le and write_le to PrimeFieldRepr 2018-05-17 16:50:40 +12:00
bmerge dbe897d365 Auto merge of #79 - ebfull:nomorenightly, r=ebfull
Remove feature(i128_type)

The `i128_type` feature was recently stabilized in Rust, so this is unnecessary now for nightly users. In fact, in a few days there should be a new Rust beta (`1.26`) containing stable support for `i128_type`, meaning that (for Zcash) we can switch to the beta compiler for all future Rust development, and even switch to the stable compiler in six weeks when that's released.
2018-03-30 23:55:32 +00:00
Sean Bowe 2d12b9a858
Apply newer rustfmt rules. 2018-03-29 11:18:15 -06:00
Sean Bowe fcaddaa356
Update Clippy to support latest nightly, and fix some lints. 2018-03-29 10:13:00 -06:00
Sean Bowe bcc8379a7f
Version bump. 2018-03-29 09:23:20 -06:00
Sean Bowe 4cf5a534ec
i128_type feature has been stabilized in Rust. 2018-03-29 09:18:26 -06:00
bmerge ef7ade8c2c Auto merge of #78 - ebfull:release-0.14, r=ebfull
Release of pairing 0.14.0.

This release makes some changes in response to an audit of this library, as well as some obversations about the API that I made. Some names were changed (`divn` -> `shr`, `muln` -> `shl`) and `add_nocarry`/`sub_noborrow` no longer return anything (as their names would suggest.) Some potentially misleading comments are fixed as well.

The release also applies `rustfmt` and new lints from `clippy` to the codebase, enforced by the CI on a more recent version of the Nightly compiler.

Thanks go to @jasondavies for his contributions to this release.
2018-03-05 03:31:26 +00:00
Sean Bowe 92d2c13285
Release of pairing 0.14.0. 2018-03-04 20:01:23 -07:00
bmerge 6fea7e382d Auto merge of #77 - ebfull:rustfmt-application-2, r=ebfull
Apply rustfmt

Supersedes #76

I've made a change to the CI which checks `rustfmt` against the code. Let's see if it worked.
2018-03-05 02:49:40 +00:00
Sean Bowe 53083f4290
Apply rustfmt to the codebase. 2018-02-21 11:08:58 -07:00
bmerge d51a5b0122 Auto merge of #73 - plutomonkey:update-rand-dependency, r=ebfull
Update "rand" dependency to 0.4.
2018-02-21 16:33:33 +00:00
bmerge da717f4472 Auto merge of #75 - ebfull:primerepr-fixes, r=ebfull
PrimeRepr improvements

These are API-breaking changes that make `PrimeRepr` a little nicer.
2018-02-21 15:56:41 +00:00
Sean Bowe 541fda7580
Fix misleading comments on write_be and read_be. 2018-02-13 17:14:17 -07:00
Sean Bowe b971bdedda
Rename divn/muln to shr/shl. 2018-02-13 17:07:10 -07:00
bmerge 7b6e13bcb9 Auto merge of #74 - plutomonkey:clippy, r=ebfull
Update clippy and fix code indentation.

(The code indentation issue was not caught by clippy -- I noticed it by chance!)
2018-02-14 00:03:26 +00:00
Sean Bowe a0fcf717c8
add_nocarry and sub_noborrow should no longer return anything. 2018-02-13 16:41:10 -07:00
Jason Davies bce9f5d639 Update clippy and fix code indentation.
(The code indentation issue was not caught by clippy -- I noticed it by
chance!)
2018-02-13 16:02:30 +00:00
Jason Davies 2338174244 Update "rand" dependency to 0.4. 2018-02-13 15:51:16 +00:00
bmerge a8583dd818 Auto merge of #71 - ebfull:expose-arith, r=ebfull
Expose arithmetic

This exposes `adc`/`sbb`/`mac_with_carry` from this library for downstream use, as long as a `expose-arith` feature is enabled. We need this downstream to avoid code duplication.

This also bumps to `0.13.2`.
2017-12-05 04:43:24 +00:00
Sean Bowe fb679470db
Bump version. 2017-12-04 21:48:22 -07:00
Sean Bowe 04a32fb443
Introduce `expose-arith` unstable feature for exposing arithmetic functions downstream. 2017-12-04 21:47:45 -07:00
bmerge cc8be5b780 Auto merge of #70 - ebfull:comment-fixes, r=ebfull
Fix some comments

The `mod q` stuff was spotted by @Pratyush and/or @howardwu.

I just noticed the `// 2` typo.
2017-11-26 10:19:09 +00:00
Sean Bowe b8394bf14d
Fix some comments. 2017-11-26 03:09:06 -07:00
bmerge ed5a7f31e2 Auto merge of #69 - ebfull:0.13.1-release, r=ebfull
Release of 0.13.1

This release features the following changes:

* The `byteorder` version is now set to `1` as conventional.
* The `CurveAffine`/`CurveProjective` traits now enforce that the scalar field of the `Engine` is the same scalar field for the curves.
* `Engine` is now `'static` and `Clone` to avoid problems with lifetime quirks and auto-derives.
* The scalar field of `Engine` is now guaranteed to be `SqrtField` which helps downstream abstractions.

In this PR I will be updating the `clippy` version and fixing any linting problems that show up. The builder should be using the newest nightly/stable versions of Rust also.
2017-11-26 04:27:58 +00:00
Sean Bowe bb1ced0bd7
Update clippy version. 2017-11-25 21:32:14 -07:00
Sean Bowe 566f100480
Release of 0.13.1. 2017-11-25 21:01:55 -07:00
bmerge df9d2aaa37 Auto merge of #68 - ebfull:scalar-sqrt, r=ebfull
Scalar field should be guaranteed to be SqrtField
2017-11-26 03:50:21 +00:00
Sean Bowe aa0cc06e5e
Scalar field should be guaranteed to be SqrtField. 2017-11-25 20:57:10 -07:00
bmerge affead11a5 Auto merge of #67 - ebfull:static-engine, r=ebfull
Engine should always be 'static, for flexibility in downstream code.
2017-11-21 06:47:28 +00:00
Sean Bowe 4a1ac94799
Implement `Clone` for Bls12. 2017-11-20 23:53:58 -07:00
Sean Bowe 4b366a143d
Ensure `Engine`'s are always Clone. 2017-11-20 23:20:11 -07:00
bmerge 36ad8b672c Auto merge of #66 - ebfull:scalar-assoc, r=ebfull
Enforce that Fr of Engine is the scalar for curve points

In bellman, I want to write:

```rust
pub struct Point<C: CurveProjective>(pub C);

impl<C: CurveProjective> Copy for Point<C> { }

impl<C: CurveProjective> Clone for Point<C> {
    fn clone(&self) -> Point<C> {
        *self
    }
}

impl<C: CurveProjective> Group<C::Engine> for Point<C> {
    fn group_zero() -> Self {
        Point(C::zero())
    }
    fn group_mul_assign(&mut self, by: &C::Scalar) {
        self.0.mul_assign(by.into_repr());
    }
    fn group_add_assign(&mut self, other: &Self) {
        self.0.add_assign(&other.0);
    }
    fn group_sub_assign(&mut self, other: &Self) {
        self.0.sub_assign(&other.0);
    }
}
```

However, this doesn't typecheck because the compiler cannot know that the `Engine`'s `Fr` type (as dictated by the `Group` trait) is the same as the `Scalar` type of the `CurveProjective` point. This can be solved with a where bound over the trait (for now), but it is generally a good idea for this to be constrained in `pairing`.
2017-11-20 19:26:16 +00:00
Sean Bowe f32cb40929
Engine should always be 'static, for flexibility in downstream code. 2017-11-20 12:22:51 -07:00
Sean Bowe 471db6ab27
Enforce that Fr of Engine is the scalar for curve points, for simpler downstream abstractions. 2017-11-12 16:19:08 -07:00
bmerge 5d9f77f5bf Auto merge of #65 - ebfull:byteorder-version, r=ebfull
Use 1 for the byteorder crate's version.
2017-10-12 17:48:25 +00:00
Sean Bowe 342b94c76b
Use "1" for the byteorder crate's version. 2017-10-12 11:20:57 -06:00
bmerge 48044a853f Auto merge of #64 - ebfull:bump-13, r=ebfull
Bump version to 0.13.0

After #58 and #63 are merged.
2017-10-12 17:20:04 +00:00
bmerge 364796d88c Auto merge of #58 - ebfull:derive-clone, r=ebfull
Derive `Clone` for G1/G2 encodings.

AFAIK this will finally work on stable when the next version of Rust is released.

Closes #55
2017-10-12 16:45:21 +00:00
bmerge 30ae5d6313 Auto merge of #63 - ebfull:rand-unknown-exponent, r=ebfull
G1/G2 rand() should produce elements of unknown exponent.

Closes #60.
2017-10-12 16:16:52 +00:00
Sean Bowe 39c25cd506
Bump version to 0.13.0 2017-10-10 01:54:53 -06:00
Sean Bowe 12b9606b9c
G1/G2 rand() should produce elements of unknown exponent. 2017-10-10 01:13:35 -06:00
bmerge 044256c2f7 Auto merge of #62 - mmaker:feature/scale_by_cofactor, r=ebfull
Add "scale_by_cofactor".

Add a function for Affine types that multiplies point by the cofactor of the
group. If the points are in the group, they'll thus end up in the
correct subgroup.

note: this patch is already being tested with previous unittests.
note: this patch raises warning for unused functions and consts.
2017-10-09 23:15:59 +00:00
Sean Bowe 65e50a9e5a
Allow `scale_by_cofactor` to be dead code temporarily. 2017-10-09 17:14:36 -06:00
Michele Orrù e5607bb528 Add "scale_by_cofactor".
Add a function for Affine types that multiplies point by the cofactor of the
group.
2017-10-09 10:04:22 +02:00
bmerge dfb836170b Auto merge of #61 - ebfull:minor-changes, r=ebfull
Minor changes
2017-10-05 18:36:27 +00:00
Sean Bowe dbac57c27b
Further refactoring of get_point_from_x() 2017-10-05 12:35:04 -06:00
Sean Bowe 683f21a4d5
Remove spurious newline. 2017-10-04 14:53:42 -06:00
Sean Bowe 85b95750e2
Fix comment about u128-support. 2017-10-04 14:09:40 -06:00
Sean Bowe 931257599d
Refactor code for finding affine points from x-coordinates. 2017-10-04 11:43:42 -06:00
bmerge f9d4c8b6aa Auto merge of #57 - ebfull:relic-interop, r=ebfull
RELIC interop

Closes #2

RELIC has changed the G2 generator to match ours: 25aafecbec

RELIC will not have the same serialization as us.

One last difference is that RELIC conjugates the pairing result to account for the negative curve parameter. It doesn't matter for BLS curves but it's strictly more correct.
2017-10-04 15:51:28 +00:00