Commit Graph

797 Commits

Author SHA1 Message Date
Jack Grigg 3329b4de85 Migrate to `ff 0.12`, `group 0.12`
MSRV is now 1.56.0.
2022-05-04 23:22:15 +00:00
str4d 6aa6882bda
Merge pull request #39 from zcash/38-fix-book-workflow
Fix book deployment
2022-05-05 00:05:07 +01:00
Jack Grigg c2500bd999 Fix book deployment 2022-05-04 23:04:30 +00:00
ebfull c9f5f90229
Merge pull request #37 from zcash/release-0.3.1
`pasta_curves 0.3.1`
2022-04-20 12:05:43 -06:00
Jack Grigg 94d6a8be03 `pasta_curves 0.3.1` 2022-04-20 11:15:43 +00:00
str4d 43d4496d6b
Merge pull request #23 from daira/dual-license
Ensure that GitHub's "View license" link points to complete license information
2022-04-19 16:10:07 +02:00
ebfull a80ed3e8aa
Merge pull request #30 from dot-asm/repr-c
Add 'repr-c' feature to facilitate FFI.
2022-04-19 08:04:29 -06:00
Andy Polyakov 1bee4d2989 fixup! Document recent changes in CHANGELOG.md. 2022-04-19 08:13:51 +02:00
Andy Polyakov 73eb83d52d Document recent changes in CHANGELOG.md. 2022-04-19 00:12:55 +02:00
Andy Polyakov ef39fba64c Simplify $name_affine.ct_eq().
By @ebfull's suggestion.
2022-04-18 19:04:03 +02:00
Andy Polyakov 3507ba6ffe Omit 'infinity' field from affine coordinates structure. 2022-04-13 22:23:23 +02:00
str4d 2796b6b65e
Merge pull request #31 from vmx/ec-gpu
Implement ec_gpu:GpuField for Fp/Fq
2022-03-24 17:08:37 +00:00
Daira Hopwood cc57a3b75b
Merge pull request #34 from davidnevadoc/coordinates-pub
Add constructor for `Coordinates`
2022-03-24 11:19:46 +00:00
Volker Mische 678cd40419 chore: fix source formatting 2022-03-15 16:25:18 +01:00
David Nevado 8b101d67c4
Add `Coordinates` constructor 2022-03-12 15:46:43 +01:00
David Nevado 8a3643682f
Change `Coordinates` attrs back to `pub(crate)` 2022-03-12 15:44:46 +01:00
Volker Mische b1f03fbc9c Document helper function 2022-03-11 17:47:17 +01:00
Volker Mische cc51340dc5
fix: less allocations
Co-authored-by: str4d <thestr4d@gmail.com>
2022-03-11 17:37:47 +01:00
David Nevado 8042906484
Change `Coordinates` fields to `pub` 2022-03-07 11:19:15 +01:00
Volker Mische 870939ab03 Implement ec_gpu:GpuField for Fp/Fq
This commit introduces a new feature called "gpu", which enables an
`ec_gpu:GpuField` implementation of `Fp` and `Fq`. This enables the
field arithmetics to be run on a GPU.

The code to convert from a u64 to a u32 vector was taken from
07a84f9727/src/lib.rs (L102-L108)
2022-03-02 14:44:11 +01:00
Andy Polyakov 872065c8a1 Add 'repr-c' feature to facilitate FFI. 2022-02-17 17:06:02 +01:00
Daira Hopwood ac5acca3b4 Ensure that GitHub's "View license" link points to complete license information.
refs https://github.com/zcash/librustzcash/issues/443

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 17:30:00 +00:00
ebfull de99732e20
Merge pull request #29 from zcash/release-0.3.0
Release 0.3.0
2022-01-04 08:55:36 -07:00
Jack Grigg 6b2090ff2c `pasta_curves 0.3.0` 2022-01-03 13:57:42 +00:00
Jack Grigg 61fac8a5af `blake2b_simd 1`
We also move this dependency behind the `alloc` feature flag, as it is
only required for `crate::hashtocurve`.
2022-01-03 13:56:07 +00:00
Jack Grigg 53f65f7e6d Changelog and comment cleanups 2022-01-03 13:56:07 +00:00
str4d 738fb60796
Merge pull request #28 from zcash/27-remove-std-feature-flag
Remove `std` feature flag
2021-12-25 12:36:29 +00:00
str4d 93c6a18e92
Merge pull request #26 from zcash/no-std-field-traits
Remove field traits from behind `std` feature flag
2021-12-25 12:33:47 +00:00
str4d c10960351d
Fix typo in code comment
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-12-25 12:20:18 +00:00
Jack Grigg 21fd9e2c1b Remove `std` feature flag
Closes zcash/pasta_curves#27.
2021-12-22 05:41:04 +00:00
Jack Grigg 69cf8f5f77 Remove `CurveAffine::{read, write}`
This removes the last dependency on `std::io`.
2021-12-22 05:22:56 +00:00
Jack Grigg f874d29238 Remove `FieldExt::rand`
This removes a dependency on the `getrandom` crate in no-std mode, which
doesn't work on some no-std targets that `getrandom` doesn't support.
2021-12-22 05:15:06 +00:00
Jack Grigg ab03c3d5e1 Remove field traits from behind `std` feature flag
Now that we have a default implementation of `SqrtRatio::sqrt_ratio`, we
can use it and `FieldExt` in no-std environments.

We introduce an `alloc` feature flag to form a common feature dependency
between `std` and `sqrt-table`. It is currently unused directly, but
will be used after `CurveAffine` is refactored to remove the `std`
dependency.

Closes zcash/pasta_curves#25.
2021-12-22 05:06:16 +00:00
Jack Grigg 314b1bcb94 Place `SqrtTables` behind a `sqrt-tables` feature flag
This enables the crate to be compiled without the tables, instead using
a simple fallback for `SqrtRatio::sqrt_ratio`.
2021-12-22 04:38:14 +00:00
Jack Grigg 96116e20e5 Annotate docs with required feature flags 2021-12-07 14:31:27 +00:00
str4d c052756831
Merge pull request #20 from zcash/refactor
Refactor the crate APIs
2021-10-01 06:07:38 +13:00
Jack Grigg a91e262235 Document that the generator in `SqrtRatio::sqrt_ratio` might change 2021-09-30 13:57:59 +01:00
Jack Grigg 32cc10db46 Move `FieldExt::get_lower_32` to `SqrtRatio` trait
It is only used internally by the table-based square root impl, and we
should probably refactor this further, but for now it can live in the
sqrt extension trait.
2021-09-30 13:57:59 +01:00
Jack Grigg 3a6f71d2f0 Remove `FieldExt::{from_bytes, read, to_bytes, write}`
- `ff::PrimeField::{from_repr, to_repr}` are direct replacements for
  `FieldExt::{from_bytes, to_bytes}`.
- `FieldExt::{read, write}` were added for reading and writing `halo2`
  proofs, but `halo2::transcript` now handles this internally.
2021-09-23 14:45:02 +01:00
Jack Grigg ad0360bc1c Remove `FieldExt::from_u64` 2021-09-23 14:45:02 +01:00
Jack Grigg 11c5ddbc02 Remove `FieldExt::{RESCUE_ALPHA, RESCUE_INVALPHA}` 2021-09-23 14:45:02 +01:00
Jack Grigg e31787d462 Remove unnecessary bounds on `CurveExt`
They are already bounds on `group::Group`, which `CurveExt` inherits
via `group::prime::PrimeCurve`.
2021-09-23 14:45:02 +01:00
Jack Grigg 1b2f581ac1 Move square-root operations from `FieldExt` into a separate trait 2021-09-23 14:45:02 +01:00
Jack Grigg 0c58a40a98 Remove `pasta_curves::arithmetic::Field` 2021-09-23 14:44:10 +01:00
Jack Grigg aeda766c34 Remove `FieldExt::ROOT_OF_UNITY`
We can use the `ff::PrimeField::root_of_unity` method everywhere we
currently use this associated constant. If there is a more general
need for accessing this as an associated constant, we should consider
that for `ff::PrimeField`.
2021-09-23 14:44:10 +01:00
str4d 275dad22ad
Merge pull request #4 from zcash/no-std
Support no-std builds
2021-09-24 01:39:25 +12:00
str4d 2b350118b0
Fix naming of Tonelli-Shanks
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-09-21 10:44:07 +12:00
Jack Grigg 9999964d17 Add no-std support
We re-introduce the Tonelli-Shank square root algoritm that was removed
in zcash/halo2#120, to use in no-std mode (the table-based impl requires
allocations, and also uses 29kiB of memory which is a problem for
constrained environments that typically need no-std).
2021-09-20 18:56:23 +01:00
Jack Grigg 8fabb44ad4 fields: Use `ff::PrimeField` instead of `FieldExt` where possible 2021-09-20 17:41:46 +01:00
Jack Grigg 6a47700b1d fields: Ensure that trait impl dependencies match trait bounds
The `FieldExt` trait was originally the only trait implemented in this
crate. When we added `ff` support, we reworked `FieldExt` to be an
extension trait on top of `ff::PrimeField`, but left the existing impls
in `FieldExt`. This resulted in some circular dependencies that prevent
us from making `FieldExt` conditional (e.g. for no-std support).

This commit removes the cycles like so:

- `ff::PrimeField::{from_repr, to_repr}` were implemented as calls to
  `FieldExt::{from_bytes, to_bytes}`. The field encoding/decoding logic
  is moved into the `ff::PrimeField` trait impl, and `FieldExt` now
  calls into `ff::PrimeField`.

- `ff::Field::sqrt` was implemented in terms of `FieldExt::sqrt_alt`.
  Given that the latter is a trivial wrapper around the `SqrtTables`
  implementation, we duplicate the call to eliminate the cycle.

- `ff::Field::random` used `FieldExt::from_bytes_wide`, which wraps
  either `Fp::from_u512` or `Fq::from_u512`. We now use these internal
  methods directly.
2021-09-20 17:41:46 +01:00