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 ed25519_dalek::VerifyingKey;
|
||||||
use lox_library::bridge_table::BridgeLine;
|
use lox_library::bridge_table::BridgeLine;
|
||||||
use serde::{Deserialize, Serialize};
|
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
|
/// Information that needs to be known to verify a Troll Patrol report
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
@ -9,8 +12,8 @@ pub struct BridgeInfo {
|
||||||
/// BridgeLine for this bridge
|
/// BridgeLine for this bridge
|
||||||
pub bridge_line: BridgeLine,
|
pub bridge_line: BridgeLine,
|
||||||
|
|
||||||
/// Bucket for this bridge if this bridge is a Lox bridge
|
/// Buckets containing this bridge if this bridge is a Lox bridge
|
||||||
pub bucket: Option<Scalar>,
|
pub buckets: HashSet<Scalar>,
|
||||||
|
|
||||||
/// Key used to verify bridge tokens
|
/// Key used to verify bridge tokens
|
||||||
pub pubkey: Option<VerifyingKey>,
|
pub pubkey: Option<VerifyingKey>,
|
||||||
|
@ -20,7 +23,7 @@ impl BridgeInfo {
|
||||||
pub fn new(bl: BridgeLine) -> Self {
|
pub fn new(bl: BridgeLine) -> Self {
|
||||||
BridgeInfo {
|
BridgeInfo {
|
||||||
bridge_line: bl,
|
bridge_line: bl,
|
||||||
bucket: None,
|
buckets: HashSet::<Scalar>::new(),
|
||||||
pubkey: None,
|
pubkey: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,13 +107,15 @@ impl NegativeReport {
|
||||||
let hash = HashOfBridgeLine::new(&bridge_info.bridge_line);
|
let hash = HashOfBridgeLine::new(&bridge_info.bridge_line);
|
||||||
hash == pok
|
hash == pok
|
||||||
}
|
}
|
||||||
ProofOfBridgeKnowledge::HashOfBucket(pok) => match bridge_info.bucket {
|
ProofOfBridgeKnowledge::HashOfBucket(pok) => {
|
||||||
Some(b) => {
|
for b in &bridge_info.buckets {
|
||||||
let hash = HashOfBucket::new(&b);
|
let hash = HashOfBucket::new(&b);
|
||||||
hash == pok
|
if hash == pok {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
}
|
}
|
||||||
None => false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,13 +128,14 @@ impl PositiveReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Verify knowledge of bucket ID
|
// Verify knowledge of bucket ID
|
||||||
let bucket = bridge_info.bucket.unwrap();
|
let buckets = &bridge_info.buckets;
|
||||||
let BP = self.lox_proof.BP;
|
let BP = self.lox_proof.BP;
|
||||||
if &bucket * Htable != BP {
|
for bucket in buckets {
|
||||||
return false;
|
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