|
@@ -120,6 +120,7 @@ impl BridgeLine {
|
|
|
/// Encode a bucket to a byte array, including a Bucket Reachability
|
|
|
/// credential if appropriate
|
|
|
pub fn bucket_encode(
|
|
|
+ rng: &mut (impl CryptoRng + RngCore),
|
|
|
bucket: &[BridgeLine; MAX_BRIDGES_PER_BUCKET],
|
|
|
reachable: &HashMap<BridgeLine, Vec<(u32, usize)>>,
|
|
|
today: u32,
|
|
@@ -140,18 +141,10 @@ impl BridgeLine {
|
|
|
// Construct a Bucket Reachability credential for this
|
|
|
// bucket and today's date
|
|
|
let today_attr: Scalar = today.into();
|
|
|
- //let mut rng = rand::rngs::OsRng;
|
|
|
let mut B = BucketReachability::using_privkey(reachability_priv);
|
|
|
B.date = Some(today_attr);
|
|
|
B.bucket = Some(*bucket_attr);
|
|
|
- //let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE;
|
|
|
- // let b = Scalar::random(&mut rng);
|
|
|
- // let P = &b * Btable;
|
|
|
- // let Q = &(b
|
|
|
- // * (reachability_priv.x[0]
|
|
|
- // + reachability_priv.x[1] * today_attr
|
|
|
- // + reachability_priv.x[2] * bucket_attr))
|
|
|
- // * Btable;
|
|
|
+ let _ = B.create_MAC(rng, reachability_priv);
|
|
|
res[pos..pos + 4].copy_from_slice(&today.to_le_bytes());
|
|
|
res[pos + 4..pos + 36].copy_from_slice(B.MAC.P.compress().as_bytes());
|
|
|
res[pos + 36..].copy_from_slice(B.MAC.Q.compress().as_bytes());
|
|
@@ -317,12 +310,13 @@ impl BridgeTable {
|
|
|
/// are reachable.
|
|
|
#[cfg(any(feature = "bridgeauth", test))]
|
|
|
pub fn encrypt_table(&mut self, today: u32, reachability_priv: &CMZPrivkey<G>) {
|
|
|
- let mut rng = rand::rngs::OsRng;
|
|
|
+ let rng = &mut rand::thread_rng();
|
|
|
self.encbuckets.clear();
|
|
|
for (uid, key) in self.keys.iter() {
|
|
|
let bucket = self.buckets.get(uid).unwrap();
|
|
|
let mut encbucket: [u8; ENC_BUCKET_BYTES] = [0; ENC_BUCKET_BYTES];
|
|
|
let plainbucket: [u8; BUCKET_BYTES] = BridgeLine::bucket_encode(
|
|
|
+ rng,
|
|
|
bucket,
|
|
|
&self.reachable,
|
|
|
today,
|