Only store dummy public key (#374)

This commit is contained in:
daxpedda
2025-05-20 12:49:11 -07:00
committed by GitHub
parent fdf6a1103b
commit 3777ee680a
5 changed files with 3034 additions and 3025 deletions
+1 -1
View File
@@ -316,7 +316,7 @@ impl<CS: CipherSuite> RegistrationUpload<CS> {
Self {
envelope: Envelope::<CS>::dummy(),
masking_key,
client_s_pk: server_setup.fake_keypair.public().clone(),
client_s_pk: server_setup.dummy_pk.clone(),
}
}
}
+7 -7
View File
@@ -75,7 +75,7 @@ pub struct ServerSetup<
> {
oprf_seed: OS,
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
@@ -165,7 +165,7 @@ pub type ServerSetupLen<
CS: CipherSuite,
SK: PrivateKeySerialization<KeGroup<CS>>,
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> {
/// 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 {
oprf_seed,
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
SK: PrivateKeySerialization<KeGroup<CS>>,
OS: OprfSeedSerialization<OprfHash<CS>, SK::Error>,
// ServerSetup: Hash + KeSk + KeSk
// ServerSetup: Hash + KeSk + KePk
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>,
{
self.oprf_seed
.serialize()
.concat(SK::serialize_key_pair(&self.keypair))
.concat(self.fake_keypair.private().serialize())
.concat(self.dummy_pk.serialize())
}
/// Deserialization from bytes
@@ -223,7 +223,7 @@ impl<CS: CipherSuite, SK: Clone, OS: Clone> ServerSetup<CS, SK, OS> {
Ok(Self {
oprf_seed: OS::deserialize_take(&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)?,
})
}
+15 -9
View File
@@ -196,7 +196,7 @@ pub struct TestVectorParameters {
pub server_s_sk: Vec<u8>,
pub server_e_pk: 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 id_u: 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_e_pk: decode(values, "server_e_pk").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(),
id_u: decode(values, "id_u").unwrap(),
id_s: decode(values, "id_s").unwrap(),
@@ -331,7 +331,13 @@ fn stringify_test_vectors(p: &TestVectorParameters) -> String {
)
.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(
format!(
" \"credential_identifier\": \"{}\",\n",
@@ -523,7 +529,7 @@ where
let server_e_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 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 id_u = b"idU";
let id_s = b"idS";
@@ -546,12 +552,12 @@ where
let mut client_sig_rng = GenericArray::<u8, <KeGroup<CS> as Group>::SkLen>::default();
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(
&[
oprf_seed.as_ref(),
&server_s_kp.private().serialize(),
&fake_sk,
&dummy_client_pk,
]
.concat(),
)
@@ -676,7 +682,7 @@ where
server_s_sk: server_s_kp.private().serialize().to_vec(),
server_e_pk: server_e_kp.public().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(),
id_u: id_u.to_vec(),
id_s: id_s.to_vec(),
@@ -817,7 +823,7 @@ fn test_registration_response() -> Result<(), ProtocolError> {
&[
parameters.oprf_seed,
parameters.server_s_sk,
parameters.fake_sk,
parameters.dummy_client_pk,
]
.concat(),
)?;
@@ -984,7 +990,7 @@ fn test_credential_response() -> Result<(), ProtocolError> {
&[
parameters.oprf_seed,
parameters.server_s_sk,
parameters.fake_sk,
parameters.dummy_client_pk,
]
.concat(),
)?;
File diff suppressed because it is too large Load Diff
+11 -8
View File
@@ -38,7 +38,7 @@ use crate::*;
#[allow(non_snake_case)]
#[derive(Debug)]
pub struct OpaqueTestVectorParameters {
pub dummy_private_key: Vec<u8>,
pub dummy_public_key: Vec<u8>,
pub dummy_masking_key: Vec<u8>,
pub context: Vec<u8>,
#[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;
OpaqueTestVectorParameters {
dummy_private_key: {
match decode(values, "client_private_key") {
dummy_public_key: {
match decode(values, "client_public_key") {
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: {
@@ -328,7 +331,7 @@ where
&[
parameters.oprf_seed.as_slice(),
&parameters.server_private_key,
&parameters.dummy_private_key,
&parameters.dummy_public_key,
]
.concat(),
)?;
@@ -452,7 +455,7 @@ where
&[
parameters.oprf_seed.as_slice(),
&parameters.server_private_key,
&parameters.dummy_private_key,
&parameters.dummy_public_key,
]
.concat(),
)?;
@@ -575,7 +578,7 @@ where
&[
parameters.oprf_seed.as_slice(),
&parameters.server_private_key,
&parameters.dummy_private_key,
&parameters.dummy_public_key,
]
.concat(),
)?;
@@ -646,7 +649,7 @@ where
&[
parameters.oprf_seed.as_slice(),
&parameters.server_private_key,
&parameters.dummy_private_key,
&parameters.dummy_public_key,
]
.concat(),
)?;