Compare commits
No commits in common. "548c94f83409ffa41fa3a95f447b92e3e4d6c620" and "9412817a6632dec511d377eae0db44eeb0722295" have entirely different histories.
548c94f834
...
9412817a66
|
@ -1,27 +0,0 @@
|
||||||
use curve25519_dalek::Scalar;
|
|
||||||
use ed25519_dalek::VerifyingKey;
|
|
||||||
use lox_library::bridge_table::BridgeLine;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
/// Information that needs to be known to verify a Troll Patrol report
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
|
||||||
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>,
|
|
||||||
|
|
||||||
/// Key used to verify bridge tokens
|
|
||||||
pub pubkey: Option<VerifyingKey>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BridgeInfo {
|
|
||||||
pub fn new(bl: BridgeLine) -> Self {
|
|
||||||
BridgeInfo {
|
|
||||||
bridge_line: bl,
|
|
||||||
bucket: None,
|
|
||||||
pubkey: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ use std::{
|
||||||
io::BufReader,
|
io::BufReader,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod bridge_info;
|
|
||||||
pub mod extra_info;
|
pub mod extra_info;
|
||||||
pub mod negative_report;
|
pub mod negative_report;
|
||||||
pub mod positive_report;
|
pub mod positive_report;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::{bridge_info::BridgeInfo, get_date, COUNTRY_CODES};
|
use crate::{get_date, COUNTRY_CODES};
|
||||||
|
|
||||||
use curve25519_dalek::scalar::Scalar;
|
use curve25519_dalek::scalar::Scalar;
|
||||||
use lox_library::{bridge_table::BridgeLine, cred::Lox};
|
use lox_library::{bridge_table::BridgeLine, cred::Lox};
|
||||||
|
@ -85,20 +85,25 @@ impl NegativeReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify the report
|
/// Verify report if proof of bridge knowledge is bridge line hash
|
||||||
pub fn verify(self, bridge_info: &BridgeInfo) -> bool {
|
pub fn verify_with_hash_of_bridge_line(self, bl: &BridgeLine) -> bool {
|
||||||
match self.bridge_pok {
|
match self.bridge_pok {
|
||||||
ProofOfBridgeKnowledge::HashOfBridgeLine(pok) => {
|
ProofOfBridgeKnowledge::HashOfBridgeLine(pok) => {
|
||||||
let hash = HashOfBridgeLine::new(&bridge_info.bridge_line);
|
let hash = HashOfBridgeLine::new(bl);
|
||||||
hash == pok
|
hash == pok
|
||||||
}
|
}
|
||||||
ProofOfBridgeKnowledge::HashOfBucket(pok) => match bridge_info.bucket {
|
_ => false,
|
||||||
Some(b) => {
|
}
|
||||||
let hash = HashOfBucket::new(&b);
|
}
|
||||||
hash == pok
|
|
||||||
}
|
/// Verify report if proof of bridge knowledge is bucket hash
|
||||||
None => false,
|
pub fn verify_with_hash_of_bucket(self, bucket: &Scalar) -> bool {
|
||||||
},
|
match self.bridge_pok {
|
||||||
|
ProofOfBridgeKnowledge::HashOfBucket(pok) => {
|
||||||
|
let hash = HashOfBucket::new(bucket);
|
||||||
|
hash == pok
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// For Lox-related code where points are uppercase and scalars are lowercase
|
// For Lox-related code where points are uppercase and scalars are lowercase
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use crate::{bridge_info::BridgeInfo, get_date, CONFIG, COUNTRY_CODES};
|
use crate::{get_date, CONFIG, COUNTRY_CODES};
|
||||||
|
|
||||||
use curve25519_dalek::ristretto::RistrettoBasepointTable;
|
use curve25519_dalek::{ristretto::RistrettoBasepointTable, Scalar};
|
||||||
use ed25519_dalek::{Signature, Signer, SigningKey, Verifier};
|
use ed25519_dalek::{Signature, Signer, SigningKey, Verifier, VerifyingKey};
|
||||||
use lox_library::{cred::Lox, proto::positive_report as lox_pr, BridgeAuth, IssuerPubKey};
|
use lox_library::{cred::Lox, proto::positive_report as lox_pr, IssuerPubKey};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sha1::{Digest, Sha1};
|
use sha1::{Digest, Sha1};
|
||||||
use std::option::Option;
|
use std::option::Option;
|
||||||
|
@ -102,17 +102,22 @@ impl PositiveReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verify report
|
/// Verify everything except the Lox proof.
|
||||||
pub fn verify(
|
/// Parameters:
|
||||||
|
/// - The bucket ID for the bucket containing this bridge
|
||||||
|
/// - A basepoint table for computing multiples of H
|
||||||
|
/// - The bridge verifying key for this bridge (if bridge token is required)
|
||||||
|
/// These parameters are assumed to be correct and are NOT checked against
|
||||||
|
/// the fingerprint listed in the report.
|
||||||
|
pub fn verify_excluding_lox_proof(
|
||||||
self,
|
self,
|
||||||
la: &mut BridgeAuth,
|
bucket: Scalar,
|
||||||
bridge_info: &BridgeInfo,
|
|
||||||
Htable: &RistrettoBasepointTable,
|
Htable: &RistrettoBasepointTable,
|
||||||
|
bridge_key: Option<VerifyingKey>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// Verify bridge token
|
// Verify bridge token
|
||||||
if CONFIG.require_bridge_token {
|
if CONFIG.require_bridge_token {
|
||||||
let bridge_token = self.bridge_token.unwrap();
|
let bridge_token = self.bridge_token.unwrap();
|
||||||
let bridge_key = bridge_info.pubkey;
|
|
||||||
if bridge_key.is_none() {
|
if bridge_key.is_none() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -128,13 +133,11 @@ impl PositiveReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Verify knowledge of bucket ID
|
// Verify knowledge of bucket ID
|
||||||
let bucket = bridge_info.bucket.unwrap();
|
|
||||||
let BP = self.lox_proof.BP;
|
let BP = self.lox_proof.BP;
|
||||||
if &bucket * Htable != BP {
|
if &bucket * Htable != BP {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Verify Lox proof
|
true
|
||||||
la.handle_positive_report(self.lox_proof, &Htable).is_ok()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue