Commit graph

772 commits

Author SHA1 Message Date
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
Jack Grigg
87488ec1f6 CI: Add no-std build check 2021-09-20 13:58:41 +01:00
str4d
adf66ae0d1
Merge pull request #19 from zcash/relicense-mit-apache
Relicense `pasta_curves` as MIT OR Apache-2.0
2021-09-18 03:43:40 +12:00
Jack Grigg
bb2564d586 pasta_curves 0.2.1 2021-09-17 16:37:00 +01:00
Jack Grigg
f747efc6ff Relicense pasta_curves as MIT OR Apache-2.0 2021-09-17 16:32:36 +01:00
str4d
5fb3037b9e
Merge pull request #18 from porcuquine/reexport-group
Re-export group crate.
2021-09-06 18:13:41 +01:00
porcuquine
65a138cd77 Re-export group crate. 2021-09-02 13:19:32 -07:00
ebfull
4f85fa5c7f
Merge pull request #17 from zcash/ff-0.11
ff 0.11, group 0.11
2021-09-02 11:45:18 -06:00
Jack Grigg
6a28a85d8b pasta_curves 0.2.0 2021-09-02 18:37:13 +01:00
Jack Grigg
fd7a6edbb1 ff 0.11, group 0.11 2021-09-02 18:10:05 +01:00
Daira Hopwood
bdb1c3797f
Merge pull request #16 from daira/point-bench
Add benchmarks for point operations
2021-08-11 19:01:16 +01:00
Daira Hopwood
329f59493c Add benchmarks for point operations.
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2021-08-11 15:09:34 +01:00
Jack Grigg
1bac885af5 Release 0.1.2 2021-08-06 13:29:03 +01:00
str4d
b786a0c488
Merge pull request #15 from zcash/wnaf-group
Enable Pasta curve elements to be used with `group::Wnaf`
2021-08-06 13:27:11 +01:00
Jack Grigg
43251286c0 Enable Pasta curve elements to be used with group::Wnaf 2021-08-06 01:23:27 +01:00
str4d
d8547d2326
Merge pull request #13 from zcash/cofactorcurve
impl CofactorCurve for Pallas and Vesta
2021-06-04 20:24:31 +01:00
Jack Grigg
15e16839b3 Release 0.1.1 2021-06-04 18:54:09 +01:00
Jack Grigg
a6b018fb0e impl CofactorCurve for Pallas and Vesta
They already implement CofactorGroup (trivially, with the prime-order
subgroup being Self); this just enables Pallas and Vesta to be used in
cofactor-aware protocols that also want to leverage the affine point
representation.
2021-06-04 00:54:39 +01:00
str4d
93df9c0cb9
Merge pull request #12 from zcash/release-0.1.0
Release 0.1.0
2021-06-01 23:48:15 +01:00
Jack Grigg
084d57ab10 Release 0.1.0 2021-06-01 23:40:45 +01:00
Jack Grigg
17b2e5275b Exclude contributor agreement from published crate
Can't contribute to hash-pinned binaries! This file is only needed in
the repo itself.
2021-06-01 23:38:30 +01:00
Jack Grigg
38db112596 Fix clippy lints 2021-06-01 23:34:22 +01:00
Jack Grigg
bc20c5826b Migrate to ff 0.10.0 2021-06-01 23:31:00 +01:00
Jack Grigg
45c57f9352 Bump MSRV to 1.51.0
Necessary for ff 0.10 etc.
2021-06-01 23:22:25 +01:00
Jack Grigg
7663200468 Fill in readme details 2021-06-01 23:19:14 +01:00
Jack Grigg
5d128a6c12 Add rust-toolchain file with MSRV 2021-06-01 23:09:07 +01:00