Commit Graph

87 Commits

Author SHA1 Message Date
Henry de Valence 288177b63d
libsodium 1.0.15 was used without ED25519_COMPAT (#18)
The previous implementation exactly matched the behavior of libsodium 1.0.15
with the ED25519_COMPAT configuration, but this configuration wasn't used by
zcashd.  This commit changes the validation rules to exactly match *without*
ED25519_COMPAT, and highlights the remaining inconsistencies with the Zcash
specification.
2020-06-15 13:27:36 -07:00
Henry de Valence 709676ee8d
Use the hex crate for nicer debug output. (#14) 2020-06-09 17:06:17 -07:00
dependabot-preview[bot] 6b3316673b Create Dependabot config file 2020-06-09 16:34:36 -04:00
dependabot-preview[bot] 3dc7c554ee Update hex requirement from 0.3 to 0.4
Updates the requirements on [hex](https://github.com/KokaKiwi/rust-hex) to permit the latest version.
- [Release notes](https://github.com/KokaKiwi/rust-hex/releases)
- [Commits](https://github.com/KokaKiwi/rust-hex/compare/v0.3...v0.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-05-10 18:10:35 -04:00
Henry de Valence d3ce6937dd Merge branch 'release/0.2.2' into main 2020-04-01 19:17:22 -07:00
Henry de Valence 095910f32f Bump version to 0.2.2 2020-04-01 19:16:27 -07:00
Henry de Valence aa7b85a3ff
Merge pull request #11 from ZcashFoundation/asref2
Add impl AsRef<[u8]> for all types except Signature.
2020-04-01 19:15:16 -07:00
Henry de Valence d1be2bfbc5 Add impl AsRef<[u8]> for all types except Signature.
This ensures that any
```
impl From<T> for [u8; N]
```
is accompanied by a matching
```
impl AsRef<[u8]> for T
```
except for Signature, whose internals have to change (issue #9).
2020-04-01 19:11:29 -07:00
Henry de Valence b5cfcac4e1 Merge branch 'release/0.2.1' into main 2020-04-01 19:01:20 -07:00
Henry de Valence 2e30e16048 Bump version to 0.2.1 2020-04-01 19:00:05 -07:00
Henry de Valence 16cdda4696
Merge pull request #7 from ZcashFoundation/asref
impl AsRef<[u8]> for PublicKeyBytes
2020-04-01 18:57:04 -07:00
Henry de Valence 5954953126 impl AsRef<[u8]> for PublicKeyBytes
It would be good to also implement AsRef<[u8]> for Signature but this requires
changing the internal representation of Signature.
2020-04-01 18:50:56 -07:00
Henry de Valence 87525475b1 Merge branch 'release/0.2.0' into main 2020-01-30 17:53:42 -08:00
Henry de Valence f1fa3805cd Bump version to 0.2.0. 2020-01-30 17:52:13 -08:00
Henry de Valence 3efaec0b50
Merge pull request #5 from ZcashFoundation/batch
Experimental futures-based batch verification.
2020-01-30 17:48:14 -08:00
Henry de Valence bd5efba032 Use in-band signaling to flush batch verification requests.
This changes the `VerificationRequest` type alias (now called `batch::Request`)
to an enum containing either a verification request or a request to flush the
batch.  This allows both automatic and manual control of batch sizes, either by
setting a low batch limit on service creation or by setting a high limit and
manually sending flush commands.

To keep things ergonomic, the `Request` enum now has a `impl From` the previous
tuple, so to send a request, all that's necessary is to assemble a
pubkey-sig-message tuple and call `.into()` on it.
2020-01-30 17:44:09 -08:00
Henry de Valence 2663474cd1 Add motivational documentation to the batch module. 2020-01-30 17:44:09 -08:00
Henry de Valence 96a4ef2481 Add non-batched verification with an identical Service interface.
This will hopefully allow things like building a Tower layer with a timeout and
a retry policy that retries timed out requests (not a big enough concurrent
batch) with singleton verification, or retries a failed batch by falling back
to singleton verification to detect which element of a batch failed.

However, there are still some rough spots in the API, and it's not clear that
manually dropping the service is an adequate way to flush requests (see comment).
2020-01-30 17:44:09 -08:00
Henry de Valence 1d6488f736 Periodically flush pending verification requests.
This implements the last suggestion in the previous commit message: the
verification service maintains a target batch size and periodically flushes
signature verification requests after reaching that many pending requests.
Requests can be manually flushed by dropping the service.  In contrast to
flushing requests by calling an inherent method, this approach has the
advantage that the verification service can be wrapped in other tower
middleware without losing functionality (drops propagate through wrapped
services).

This approach still does not impose any maximum latency on verification
requests, but it seems potentially better to leave that out of scope for the
verification service itself, as consumers wishing to have latency bounds can do
so using a timeout layer, perhaps with a retry policy that does singleton
verification after a timeout, etc.
2020-01-28 23:10:07 -08:00
Henry de Valence 21796986c0 Add benchmarks verifying batch performance estimates.
In fact the speedup can be slightly greater than the 2x predicted, because
although the multiexp is half the size, the remaining half has 128-bit scalars
instead of 256-bit ones.
2020-01-28 21:36:48 -08:00
Henry de Valence d9d64fd050 Initial implementation of futures-based batch verification.
This commit incidentally includes an optimization for batch verification that
improves performance when verifying multiple signatures from the same public
key.

I'm not totally happy with a few things about this API, however.  Currently,
the actual batch computation is performed only when the inherent `finalize()`
method is called on the service.  However, this doesn't work well with `tower`
layering, because once the service is wrapped, the inherent method is no longer
available.  Another option would be for the batching service to be created with
a batch size parameter, automatically resolving the batch computation whenever
the batch size was reached.  This improves latency but does not solve the
problem of finalizing the batch, since unless there's guaranteed to be a
constant stream of verification requests, a tail of requests may be left
unresolved.  A third option would be for the service to return some kind of
control handle on creation that would allow shutdown via a channel or
something, but this is also unsatisfying because it means that the service has
to be listening for a shutdown signal.  A fourth option would be to have a
batch size parameter but customize the `Drop` impl to finalize all pending
requests on drop; this would potentially allow "flushing" pending requests by
manually dropping the service in a way that would still be possible when using
tower wrappers.
2020-01-28 21:36:37 -08:00
Henry de Valence 0d51fe6da5 Add From<&SecretKey> for PublicKeyBytes 2020-01-28 17:30:00 -08:00
Henry de Valence 3a2ee27241 Merge branch 'release/0.1.0' into main 2020-01-24 13:03:37 -08:00
Henry de Valence 2ac8b716fa Prepare 0.1.0 release. 2020-01-24 13:01:41 -08:00
Henry de Valence ce4cd99396
Merge pull request #4 from ZcashFoundation/match-libsodium
Match libsodium behavior.
2020-01-24 12:58:00 -08:00
Henry de Valence abbe9f74d9 Add examples. 2020-01-24 12:55:43 -08:00
Henry de Valence cab40f04e7 Bring ed25519-zebra in line with libsodium 1.0.15. 2020-01-24 12:33:51 -08:00
Henry de Valence d008150968 Update README 2020-01-23 17:26:17 -08:00
Henry de Valence 98d337bed8 Add test vectors from RFC8032. 2020-01-23 17:14:13 -08:00
Henry de Valence 701bc9cc72 Remove unnecessary .clone() 2020-01-23 17:14:13 -08:00
Henry de Valence 8fdc58df74 Store the decompressed pubkey point as -A rather than A. 2020-01-23 17:14:13 -08:00
Henry de Valence 4f9bb3d06b Implement sign, verify. 2020-01-23 17:14:13 -08:00
Henry de Valence 51cefb3bdd Delete empty constants module. 2020-01-22 15:11:34 -08:00
Henry de Valence 77a5dd8680 Stub out the API, based on redjubjub. 2020-01-22 14:57:26 -08:00
Henry de Valence eb6c5e5de4 Add README 2020-01-22 12:37:22 -08:00
Henry de Valence 0461e070cb Add Github actions CI 2020-01-22 11:37:54 -08:00
Henry de Valence 2e62704e6a Initial commit. 2020-01-22 11:31:27 -08:00