Make oprf::generate_oprf1 generic in the Digest, as long as it matches the hash-to-curve intake of the group

We used to have three problems:
- overuse of the <Sha256 as Digest>::OutputSize, which is just, well, U32. Sometimes used as a parameter (as in generate_oprf1), sometimes as a constant (as in generate_oprf3).
- the `hash_to_curve` operation for `RistrettoPoint` which requires 64 bits of input entropy, is fed 64 bits of which the last 32 are zero,
- the `hash_to_curve` operation for `Curve25519Point` which requires 32 bits of input entropy, is fed 64 bits of which the last 32 are discarded,

This corrects all three and uses U32 where the size of the digest is not meant to be a constraint.

Addresses #15 partially.
This commit is contained in:
François Garillot
2020-07-03 18:28:34 -04:00
parent 45ea7b6e84
commit 41cd80ccb5
12 changed files with 99 additions and 63 deletions
+1
View File
@@ -23,6 +23,7 @@ use std::convert::TryFrom;
struct X255193dhNoSlowHash;
impl CipherSuite for X255193dhNoSlowHash {
type Digest = sha2::Sha256;
type Group = EdwardsPoint;
type KeyFormat = X25519KeyPair;
type SlowHash = NoOpHash;
+1
View File
@@ -21,6 +21,7 @@ use std::convert::TryFrom;
struct Default;
impl CipherSuite for Default {
type Digest = sha2::Sha512;
type Group = RistrettoPoint;
type KeyFormat = crate::keypair::X25519KeyPair;
type SlowHash = crate::slow_hash::NoOpHash;