Only store dummy public key (#374)
This commit is contained in:
+1
-1
@@ -316,7 +316,7 @@ impl<CS: CipherSuite> RegistrationUpload<CS> {
|
|||||||
Self {
|
Self {
|
||||||
envelope: Envelope::<CS>::dummy(),
|
envelope: Envelope::<CS>::dummy(),
|
||||||
masking_key,
|
masking_key,
|
||||||
client_s_pk: server_setup.fake_keypair.public().clone(),
|
client_s_pk: server_setup.dummy_pk.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -75,7 +75,7 @@ pub struct ServerSetup<
|
|||||||
> {
|
> {
|
||||||
oprf_seed: OS,
|
oprf_seed: OS,
|
||||||
keypair: KeyPair<KeGroup<CS>, SK>,
|
keypair: KeyPair<KeGroup<CS>, SK>,
|
||||||
pub(crate) fake_keypair: KeyPair<KeGroup<CS>>,
|
pub(crate) dummy_pk: PublicKey<KeGroup<CS>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The state elements the client holds to register itself
|
/// The state elements the client holds to register itself
|
||||||
@@ -165,7 +165,7 @@ pub type ServerSetupLen<
|
|||||||
CS: CipherSuite,
|
CS: CipherSuite,
|
||||||
SK: PrivateKeySerialization<KeGroup<CS>>,
|
SK: PrivateKeySerialization<KeGroup<CS>>,
|
||||||
OS: OprfSeedSerialization<OprfHash<CS>, SK::Error>,
|
OS: OprfSeedSerialization<OprfHash<CS>, SK::Error>,
|
||||||
> = Sum<Sum<OS::Len, SK::Len>, <KeGroup<CS> as Group>::SkLen>;
|
> = Sum<Sum<OS::Len, SK::Len>, <KeGroup<CS> as Group>::PkLen>;
|
||||||
|
|
||||||
impl<CS: CipherSuite, SK: Clone, OS: Clone> ServerSetup<CS, SK, OS> {
|
impl<CS: CipherSuite, SK: Clone, OS: Clone> ServerSetup<CS, SK, OS> {
|
||||||
/// Create [`ServerSetup`] with the given keypair and OPRF seed.
|
/// Create [`ServerSetup`] with the given keypair and OPRF seed.
|
||||||
@@ -181,7 +181,7 @@ impl<CS: CipherSuite, SK: Clone, OS: Clone> ServerSetup<CS, SK, OS> {
|
|||||||
Self {
|
Self {
|
||||||
oprf_seed,
|
oprf_seed,
|
||||||
keypair,
|
keypair,
|
||||||
fake_keypair: KeyPair::<KeGroup<CS>>::random(rng),
|
dummy_pk: KeyPair::<KeGroup<CS>>::random(rng).public().clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,15 +203,15 @@ impl<CS: CipherSuite, SK: Clone, OS: Clone> ServerSetup<CS, SK, OS> {
|
|||||||
where
|
where
|
||||||
SK: PrivateKeySerialization<KeGroup<CS>>,
|
SK: PrivateKeySerialization<KeGroup<CS>>,
|
||||||
OS: OprfSeedSerialization<OprfHash<CS>, SK::Error>,
|
OS: OprfSeedSerialization<OprfHash<CS>, SK::Error>,
|
||||||
// ServerSetup: Hash + KeSk + KeSk
|
// ServerSetup: Hash + KeSk + KePk
|
||||||
OS::Len: Add<SK::Len>,
|
OS::Len: Add<SK::Len>,
|
||||||
Sum<OS::Len, SK::Len>: ArrayLength<u8> + Add<<KeGroup<CS> as Group>::SkLen>,
|
Sum<OS::Len, SK::Len>: ArrayLength<u8> + Add<<KeGroup<CS> as Group>::PkLen>,
|
||||||
ServerSetupLen<CS, SK, OS>: ArrayLength<u8>,
|
ServerSetupLen<CS, SK, OS>: ArrayLength<u8>,
|
||||||
{
|
{
|
||||||
self.oprf_seed
|
self.oprf_seed
|
||||||
.serialize()
|
.serialize()
|
||||||
.concat(SK::serialize_key_pair(&self.keypair))
|
.concat(SK::serialize_key_pair(&self.keypair))
|
||||||
.concat(self.fake_keypair.private().serialize())
|
.concat(self.dummy_pk.serialize())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deserialization from bytes
|
/// Deserialization from bytes
|
||||||
@@ -223,7 +223,7 @@ impl<CS: CipherSuite, SK: Clone, OS: Clone> ServerSetup<CS, SK, OS> {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
oprf_seed: OS::deserialize_take(&mut input)?,
|
oprf_seed: OS::deserialize_take(&mut input)?,
|
||||||
keypair: SK::deserialize_take_key_pair(&mut input)?,
|
keypair: SK::deserialize_take_key_pair(&mut input)?,
|
||||||
fake_keypair: PrivateKey::deserialize_take_key_pair(&mut input)
|
dummy_pk: PublicKey::deserialize_take(&mut input)
|
||||||
.map_err(ProtocolError::into_custom)?,
|
.map_err(ProtocolError::into_custom)?,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-9
@@ -196,7 +196,7 @@ pub struct TestVectorParameters {
|
|||||||
pub server_s_sk: Vec<u8>,
|
pub server_s_sk: Vec<u8>,
|
||||||
pub server_e_pk: Vec<u8>,
|
pub server_e_pk: Vec<u8>,
|
||||||
pub server_e_sk: Vec<u8>,
|
pub server_e_sk: Vec<u8>,
|
||||||
pub fake_sk: Vec<u8>,
|
pub dummy_client_pk: Vec<u8>,
|
||||||
pub credential_identifier: Vec<u8>,
|
pub credential_identifier: Vec<u8>,
|
||||||
pub id_u: Vec<u8>,
|
pub id_u: Vec<u8>,
|
||||||
pub id_s: Vec<u8>,
|
pub id_s: Vec<u8>,
|
||||||
@@ -242,7 +242,7 @@ fn populate_test_vectors(values: &Value) -> TestVectorParameters {
|
|||||||
server_s_sk: decode(values, "server_s_sk").unwrap(),
|
server_s_sk: decode(values, "server_s_sk").unwrap(),
|
||||||
server_e_pk: decode(values, "server_e_pk").unwrap(),
|
server_e_pk: decode(values, "server_e_pk").unwrap(),
|
||||||
server_e_sk: decode(values, "server_e_sk").unwrap(),
|
server_e_sk: decode(values, "server_e_sk").unwrap(),
|
||||||
fake_sk: decode(values, "fake_sk").unwrap(),
|
dummy_client_pk: decode(values, "dummy_client_pk").unwrap(),
|
||||||
credential_identifier: decode(values, "credential_identifier").unwrap(),
|
credential_identifier: decode(values, "credential_identifier").unwrap(),
|
||||||
id_u: decode(values, "id_u").unwrap(),
|
id_u: decode(values, "id_u").unwrap(),
|
||||||
id_s: decode(values, "id_s").unwrap(),
|
id_s: decode(values, "id_s").unwrap(),
|
||||||
@@ -331,7 +331,13 @@ fn stringify_test_vectors(p: &TestVectorParameters) -> String {
|
|||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
);
|
);
|
||||||
s.push_str(format!(" \"fake_sk\": \"{}\",\n", hex::encode(&p.fake_sk)).as_str());
|
s.push_str(
|
||||||
|
format!(
|
||||||
|
" \"dummy_client_pk\": \"{}\",\n",
|
||||||
|
hex::encode(&p.dummy_client_pk)
|
||||||
|
)
|
||||||
|
.as_str(),
|
||||||
|
);
|
||||||
s.push_str(
|
s.push_str(
|
||||||
format!(
|
format!(
|
||||||
" \"credential_identifier\": \"{}\",\n",
|
" \"credential_identifier\": \"{}\",\n",
|
||||||
@@ -523,7 +529,7 @@ where
|
|||||||
let server_e_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
let server_e_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
||||||
let client_s_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
let client_s_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
||||||
let client_e_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
let client_e_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
||||||
let fake_kp = KeyPair::<KeGroup<CS>>::derive_random(&mut rng);
|
let dummy_client_pk = KeyPair::<KeGroup<CS>>::random(&mut rng).public().clone();
|
||||||
let credential_identifier = b"credIdentifier";
|
let credential_identifier = b"credIdentifier";
|
||||||
let id_u = b"idU";
|
let id_u = b"idU";
|
||||||
let id_s = b"idS";
|
let id_s = b"idS";
|
||||||
@@ -546,12 +552,12 @@ where
|
|||||||
let mut client_sig_rng = GenericArray::<u8, <KeGroup<CS> as Group>::SkLen>::default();
|
let mut client_sig_rng = GenericArray::<u8, <KeGroup<CS> as Group>::SkLen>::default();
|
||||||
rng.fill_bytes(&mut client_sig_rng);
|
rng.fill_bytes(&mut client_sig_rng);
|
||||||
|
|
||||||
let fake_sk: Vec<u8> = fake_kp.private().serialize().to_vec();
|
let dummy_client_pk = dummy_client_pk.serialize();
|
||||||
let server_setup = ServerSetup::<CS>::deserialize(
|
let server_setup = ServerSetup::<CS>::deserialize(
|
||||||
&[
|
&[
|
||||||
oprf_seed.as_ref(),
|
oprf_seed.as_ref(),
|
||||||
&server_s_kp.private().serialize(),
|
&server_s_kp.private().serialize(),
|
||||||
&fake_sk,
|
&dummy_client_pk,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)
|
)
|
||||||
@@ -676,7 +682,7 @@ where
|
|||||||
server_s_sk: server_s_kp.private().serialize().to_vec(),
|
server_s_sk: server_s_kp.private().serialize().to_vec(),
|
||||||
server_e_pk: server_e_kp.public().serialize().to_vec(),
|
server_e_pk: server_e_kp.public().serialize().to_vec(),
|
||||||
server_e_sk: server_e_kp.private().serialize().to_vec(),
|
server_e_sk: server_e_kp.private().serialize().to_vec(),
|
||||||
fake_sk,
|
dummy_client_pk: dummy_client_pk.to_vec(),
|
||||||
credential_identifier: credential_identifier.to_vec(),
|
credential_identifier: credential_identifier.to_vec(),
|
||||||
id_u: id_u.to_vec(),
|
id_u: id_u.to_vec(),
|
||||||
id_s: id_s.to_vec(),
|
id_s: id_s.to_vec(),
|
||||||
@@ -817,7 +823,7 @@ fn test_registration_response() -> Result<(), ProtocolError> {
|
|||||||
&[
|
&[
|
||||||
parameters.oprf_seed,
|
parameters.oprf_seed,
|
||||||
parameters.server_s_sk,
|
parameters.server_s_sk,
|
||||||
parameters.fake_sk,
|
parameters.dummy_client_pk,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)?;
|
)?;
|
||||||
@@ -984,7 +990,7 @@ fn test_credential_response() -> Result<(), ProtocolError> {
|
|||||||
&[
|
&[
|
||||||
parameters.oprf_seed,
|
parameters.oprf_seed,
|
||||||
parameters.server_s_sk,
|
parameters.server_s_sk,
|
||||||
parameters.fake_sk,
|
parameters.dummy_client_pk,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
+3000
-3000
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ use crate::*;
|
|||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct OpaqueTestVectorParameters {
|
pub struct OpaqueTestVectorParameters {
|
||||||
pub dummy_private_key: Vec<u8>,
|
pub dummy_public_key: Vec<u8>,
|
||||||
pub dummy_masking_key: Vec<u8>,
|
pub dummy_masking_key: Vec<u8>,
|
||||||
pub context: Vec<u8>,
|
pub context: Vec<u8>,
|
||||||
#[allow(dead_code)] // client_private_key is not tested in the test vectors
|
#[allow(dead_code)] // client_private_key is not tested in the test vectors
|
||||||
@@ -97,10 +97,13 @@ fn populate_test_vectors<CS: CipherSuite>(values: &Value) -> OpaqueTestVectorPar
|
|||||||
let mut rng = OsRng;
|
let mut rng = OsRng;
|
||||||
|
|
||||||
OpaqueTestVectorParameters {
|
OpaqueTestVectorParameters {
|
||||||
dummy_private_key: {
|
dummy_public_key: {
|
||||||
match decode(values, "client_private_key") {
|
match decode(values, "client_public_key") {
|
||||||
Some(value) => value,
|
Some(value) => value,
|
||||||
None => KeGroup::<CS>::serialize_sk(KeGroup::<CS>::random_sk(&mut OsRng)).to_vec(),
|
None => KeGroup::<CS>::serialize_pk(KeGroup::<CS>::public_key(
|
||||||
|
KeGroup::<CS>::random_sk(&mut OsRng),
|
||||||
|
))
|
||||||
|
.to_vec(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dummy_masking_key: {
|
dummy_masking_key: {
|
||||||
@@ -328,7 +331,7 @@ where
|
|||||||
&[
|
&[
|
||||||
parameters.oprf_seed.as_slice(),
|
parameters.oprf_seed.as_slice(),
|
||||||
¶meters.server_private_key,
|
¶meters.server_private_key,
|
||||||
¶meters.dummy_private_key,
|
¶meters.dummy_public_key,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)?;
|
)?;
|
||||||
@@ -452,7 +455,7 @@ where
|
|||||||
&[
|
&[
|
||||||
parameters.oprf_seed.as_slice(),
|
parameters.oprf_seed.as_slice(),
|
||||||
¶meters.server_private_key,
|
¶meters.server_private_key,
|
||||||
¶meters.dummy_private_key,
|
¶meters.dummy_public_key,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)?;
|
)?;
|
||||||
@@ -575,7 +578,7 @@ where
|
|||||||
&[
|
&[
|
||||||
parameters.oprf_seed.as_slice(),
|
parameters.oprf_seed.as_slice(),
|
||||||
¶meters.server_private_key,
|
¶meters.server_private_key,
|
||||||
¶meters.dummy_private_key,
|
¶meters.dummy_public_key,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)?;
|
)?;
|
||||||
@@ -646,7 +649,7 @@ where
|
|||||||
&[
|
&[
|
||||||
parameters.oprf_seed.as_slice(),
|
parameters.oprf_seed.as_slice(),
|
||||||
¶meters.server_private_key,
|
¶meters.server_private_key,
|
||||||
¶meters.dummy_private_key,
|
¶meters.dummy_public_key,
|
||||||
]
|
]
|
||||||
.concat(),
|
.concat(),
|
||||||
)?;
|
)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user