Serialize bridgedb and its public key to files.
This commit is contained in:
parent
b945051c47
commit
cf066b1937
|
@ -6,5 +6,6 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lox = { git = "https://git-crysp.uwaterloo.ca/iang/lox.git" }
|
lox = { git = "https://git-crysp.uwaterloo.ca/iang/lox.git", branch = "vvecna/lox_test" }
|
||||||
ed25519-dalek = "1"
|
serde = "1"
|
||||||
|
serde_json = "1.0"
|
||||||
|
|
|
@ -6,10 +6,20 @@ fn main() {
|
||||||
// create new bridgedb (implicitly generates keys)
|
// create new bridgedb (implicitly generates keys)
|
||||||
let bridgedb = BridgeDb::new();
|
let bridgedb = BridgeDb::new();
|
||||||
|
|
||||||
// output public key to new file
|
// output full serialized bridgedb
|
||||||
let pubkey_bytes = bridgedb.pubkey.to_bytes();
|
let mut bridgedb_outfile =
|
||||||
let mut outfile =
|
File::create("bridgedb.json").expect("Failed to create bridgedb.json");
|
||||||
File::create("bridgedb_pubkey").expect("Failed to create pubkey file");
|
let bridgedb_outfile_json = serde_json::to_string(&bridgedb).unwrap();
|
||||||
outfile.write_all(&pubkey_bytes)
|
write!(bridgedb_outfile, "{}", bridgedb_outfile_json)
|
||||||
.expect("Failed to write pubkey");
|
.expect("Failed to write to bridgedb.json");
|
||||||
|
|
||||||
|
// output bridgedb public key
|
||||||
|
let mut bridgedb_pubkey_outfile =
|
||||||
|
File::create("bridgedb_pubkey.json").expect("Failed to create bridgedb_pubkey.json");
|
||||||
|
write!(
|
||||||
|
bridgedb_pubkey_outfile,
|
||||||
|
"{}",
|
||||||
|
serde_json::to_string(&bridgedb.pubkey).unwrap()
|
||||||
|
)
|
||||||
|
.expect("Failed to write to bridgedb_pubkey.json");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue