One bridge may be in multiple buckets
This commit is contained in:
parent
4f5bec56ad
commit
68137981fc
|
@ -2,6 +2,9 @@ use curve25519_dalek::Scalar;
|
|||
use ed25519_dalek::VerifyingKey;
|
||||
use lox_library::bridge_table::BridgeLine;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
|
||||
// TODO: Rename this. We already have a different BridgeInfo in lib.rs.
|
||||
|
||||
/// Information that needs to be known to verify a Troll Patrol report
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -9,8 +12,8 @@ pub struct BridgeInfo {
|
|||
/// BridgeLine for this bridge
|
||||
pub bridge_line: BridgeLine,
|
||||
|
||||
/// Bucket for this bridge if this bridge is a Lox bridge
|
||||
pub bucket: Option<Scalar>,
|
||||
/// Buckets containing this bridge if this bridge is a Lox bridge
|
||||
pub buckets: HashSet<Scalar>,
|
||||
|
||||
/// Key used to verify bridge tokens
|
||||
pub pubkey: Option<VerifyingKey>,
|
||||
|
@ -20,7 +23,7 @@ impl BridgeInfo {
|
|||
pub fn new(bl: BridgeLine) -> Self {
|
||||
BridgeInfo {
|
||||
bridge_line: bl,
|
||||
bucket: None,
|
||||
buckets: HashSet::<Scalar>::new(),
|
||||
pubkey: None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,13 +107,15 @@ impl NegativeReport {
|
|||
let hash = HashOfBridgeLine::new(&bridge_info.bridge_line);
|
||||
hash == pok
|
||||
}
|
||||
ProofOfBridgeKnowledge::HashOfBucket(pok) => match bridge_info.bucket {
|
||||
Some(b) => {
|
||||
ProofOfBridgeKnowledge::HashOfBucket(pok) => {
|
||||
for b in &bridge_info.buckets {
|
||||
let hash = HashOfBucket::new(&b);
|
||||
hash == pok
|
||||
if hash == pok {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
None => false,
|
||||
},
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,13 +128,14 @@ impl PositiveReport {
|
|||
}
|
||||
}
|
||||
// Verify knowledge of bucket ID
|
||||
let bucket = bridge_info.bucket.unwrap();
|
||||
let buckets = &bridge_info.buckets;
|
||||
let BP = self.lox_proof.BP;
|
||||
if &bucket * Htable != BP {
|
||||
return false;
|
||||
for bucket in buckets {
|
||||
if bucket * Htable != BP {
|
||||
return la.handle_positive_report(self.lox_proof, &Htable).is_ok();
|
||||
}
|
||||
}
|
||||
// Verify Lox proof
|
||||
la.handle_positive_report(self.lox_proof, &Htable).is_ok()
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue