mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-29 15:09:22 +00:00
8b0f0a3713
* Label the version as an alpha * Add versions to Cargo.tomls * Update to Zeroize 1.5 * Drop patch versions from monero-serai Cargo.toml * Add a repository field * Move generators to OUT_DIR IIRC, I didn't do this originally as it constantly re-generated them. Unfortunately, since cargo is complaining about .generators, we have to. * Remove Timelock::fee_weight Transaction::fee_weight's has a comment, "Assumes Timelock::None since this library won't let you create a TX with a timelock". Accordingly, this is dead code.
67 lines
1.5 KiB
Rust
67 lines
1.5 KiB
Rust
use std::{
|
|
io::Write,
|
|
env,
|
|
path::Path,
|
|
fs::{File, remove_file},
|
|
};
|
|
|
|
use dalek_ff_group::EdwardsPoint;
|
|
|
|
use monero_generators::bulletproofs_generators;
|
|
|
|
fn serialize(generators_string: &mut String, points: &[EdwardsPoint]) {
|
|
for generator in points {
|
|
generators_string.extend(
|
|
format!(
|
|
"
|
|
dalek_ff_group::EdwardsPoint(
|
|
curve25519_dalek::edwards::CompressedEdwardsY({:?}).decompress().unwrap()
|
|
),
|
|
",
|
|
generator.compress().to_bytes()
|
|
)
|
|
.chars(),
|
|
);
|
|
}
|
|
}
|
|
|
|
fn generators(prefix: &'static str, path: &str) {
|
|
let generators = bulletproofs_generators(prefix.as_bytes());
|
|
#[allow(non_snake_case)]
|
|
let mut G_str = "".to_string();
|
|
serialize(&mut G_str, &generators.G);
|
|
#[allow(non_snake_case)]
|
|
let mut H_str = "".to_string();
|
|
serialize(&mut H_str, &generators.H);
|
|
|
|
let path = Path::new(&env::var("OUT_DIR").unwrap()).join(path);
|
|
let _ = remove_file(&path);
|
|
File::create(&path)
|
|
.unwrap()
|
|
.write_all(
|
|
format!(
|
|
"
|
|
lazy_static! {{
|
|
pub static ref GENERATORS: Generators = Generators {{
|
|
G: [
|
|
{}
|
|
],
|
|
H: [
|
|
{}
|
|
],
|
|
}};
|
|
}}
|
|
",
|
|
G_str, H_str,
|
|
)
|
|
.as_bytes(),
|
|
)
|
|
.unwrap();
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
generators("bulletproof", "generators.rs");
|
|
generators("bulletproof_plus", "generators_plus.rs");
|
|
}
|