Beginnings of bridge_auth
This commit is contained in:
parent
e40a383dc9
commit
aa7fae385c
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "bridge_auth"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
lox = { git = "https://git-crysp.uwaterloo.ca/iang/lox.git" }
|
||||
ed25519-dalek = "1"
|
|
@ -0,0 +1,37 @@
|
|||
use ed25519_dalek::PublicKey;
|
||||
use lox::BridgeAuth;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::Read;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
// import bridgedb pubkey
|
||||
// note: currently no checks for valid data
|
||||
let infile = std::fs::File::open("../pubkeys/bridgedb_pubkey").unwrap();
|
||||
let mut reader = BufReader::new(infile);
|
||||
let mut buffer = Vec::new();
|
||||
reader
|
||||
.read_to_end(&mut buffer)
|
||||
.expect("Failed to read pubkey from file");
|
||||
let bridgedb_pubkey = PublicKey::from_bytes(&buffer).unwrap();
|
||||
|
||||
// create new bridge authority (implicitly generates keys)
|
||||
let bridge_auth = BridgeAuth::new(bridgedb_pubkey);
|
||||
|
||||
// output public keys to new files
|
||||
// I think this approach is too hacky because it requires multiple
|
||||
// files, one per key...
|
||||
let mut count = 0;
|
||||
// TODO: Figure out how to deal with X being private
|
||||
for pubkey in bridge_auth.lox_pub.X {
|
||||
count += 1;
|
||||
let pubkey_bytes = pubkey.compress().to_bytes();
|
||||
// Is this the proper way to concatenate an integer and a string?
|
||||
let mut outfile = File::create(format!("{}{}", "../pubkeys/bridge_auth_pubkey_", count))
|
||||
.expect("Failed to create pubkey file");
|
||||
outfile
|
||||
.write_all(&pubkey_bytes)
|
||||
.expect("Failed to write pubkey");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue