Skip to content

Commit

Permalink
Add Taskprov support for Prio3SumVecField64MultiproofHmacSha256Aes128 (
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave committed Feb 8, 2024
1 parent 3c721e1 commit 00e4c54
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
18 changes: 18 additions & 0 deletions core/src/vdaf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ impl TryFrom<&taskprov::VdafType> for VdafInstance {
taskprov::VdafType::Prio3Sum { bits } => Ok(Self::Prio3Sum {
bits: *bits as usize,
}),
taskprov::VdafType::Prio3SumVec {
bits,
length,
chunk_length,
} => Ok(Self::Prio3SumVec {
bits: *bits as usize,
length: *length as usize,
chunk_length: *chunk_length as usize,
}),
taskprov::VdafType::Prio3SumVecField64MultiproofHmacSha256Aes128 {
bits,
length,
chunk_length,
} => Ok(Self::Prio3SumVecField64MultiproofHmacSha256Aes128 {
bits: *bits as usize,
length: *length as usize,
chunk_length: *chunk_length as usize,
}),
taskprov::VdafType::Prio3Histogram {
length,
chunk_length,
Expand Down
67 changes: 67 additions & 0 deletions messages/src/taskprov.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,14 @@ pub enum VdafType {
/// Size of each proof chunk.
chunk_length: u32,
},
Prio3SumVecField64MultiproofHmacSha256Aes128 {
/// Bit length of each summand.
bits: u8,
/// Number of summands.
length: u32,
/// Size of each proof chunk.
chunk_length: u32,
},
Prio3Histogram {
/// Number of buckets.
length: u32,
Expand All @@ -349,13 +357,17 @@ impl VdafType {
const PRIO3SUM: u32 = 0x00000001;
const PRIO3SUMVEC: u32 = 0x00000002;
const PRIO3HISTOGRAM: u32 = 0x00000003;
const PRIO3SUMVECFIELD64MULTIPROOFHMACSHA256AES128: u32 = 0xFFFF1003;
const POPLAR1: u32 = 0x00001000;

fn vdaf_type_code(&self) -> u32 {
match self {
Self::Prio3Count => Self::PRIO3COUNT,
Self::Prio3Sum { .. } => Self::PRIO3SUM,
Self::Prio3SumVec { .. } => Self::PRIO3SUMVEC,
Self::Prio3SumVecField64MultiproofHmacSha256Aes128 { .. } => {
Self::PRIO3SUMVECFIELD64MULTIPROOFHMACSHA256AES128
}
Self::Prio3Histogram { .. } => Self::PRIO3HISTOGRAM,
Self::Poplar1 { .. } => Self::POPLAR1,
}
Expand All @@ -379,6 +391,15 @@ impl Encode for VdafType {
length.encode(bytes)?;
chunk_length.encode(bytes)?;
}
Self::Prio3SumVecField64MultiproofHmacSha256Aes128 {
bits,
length,
chunk_length,
} => {
bits.encode(bytes)?;
length.encode(bytes)?;
chunk_length.encode(bytes)?;
}
Self::Prio3Histogram {
length,
chunk_length,
Expand All @@ -399,6 +420,7 @@ impl Encode for VdafType {
Self::Prio3Count => 0,
Self::Prio3Sum { .. } => 1,
Self::Prio3SumVec { .. } => 9,
Self::Prio3SumVecField64MultiproofHmacSha256Aes128 { .. } => 9,
Self::Prio3Histogram { .. } => 8,
Self::Poplar1 { .. } => 2,
},
Expand All @@ -419,6 +441,13 @@ impl Decode for VdafType {
length: u32::decode(bytes)?,
chunk_length: u32::decode(bytes)?,
},
Self::PRIO3SUMVECFIELD64MULTIPROOFHMACSHA256AES128 => {
Self::Prio3SumVecField64MultiproofHmacSha256Aes128 {
bits: u8::decode(bytes)?,
length: u32::decode(bytes)?,
chunk_length: u32::decode(bytes)?,
}
}
Self::PRIO3HISTOGRAM => Self::Prio3Histogram {
length: u32::decode(bytes)?,
chunk_length: u32::decode(bytes)?,
Expand Down Expand Up @@ -585,6 +614,19 @@ mod tests {
"0000000E" // chunk_length
),
),
(
VdafType::Prio3SumVecField64MultiproofHmacSha256Aes128 {
bits: 8,
length: 12,
chunk_length: 14,
},
concat!(
"FFFF1003", // vdaf_type_code
"08", // bits
"0000000C", // length
"0000000E" // chunk_length
),
),
(
VdafType::Prio3Histogram {
length: 256,
Expand Down Expand Up @@ -681,6 +723,31 @@ mod tests {
)
),
),
(
VdafConfig::new(
DpConfig::new(DpMechanism::None),
VdafType::Prio3SumVecField64MultiproofHmacSha256Aes128 {
bits: 8,
length: 12,
chunk_length: 14,
},
)
.unwrap(),
concat!(
concat!(
// dp_config
"0001", // dp_config length
"01", // dp_mechanism
),
concat!(
// vdaf_type
"FFFF1003", // vdaf_type_code
"08", // bits
"0000000C", // length
"0000000E", // chunk_length
)
),
),
(
VdafConfig::new(
DpConfig::new(DpMechanism::None),
Expand Down

0 comments on commit 00e4c54

Please sign in to comment.