mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-17 09:27:36 +00:00
a66994aade
* Add in an implementation of BP+ based off the paper, intended for clarity and review This was done as part of my work on FCMPs from Monero, and is copied from https://github.com/kayabaNerve/full-chain-membership-proofs * Remove crate structure of BP+ * Remove arithmetic circuit code * Remove AC/VC generators code * Remove generator transcript Monero uses non-transcripted static generators. * Further trimming of generators * Remove the single range proof It's unused by Monero and accordingly unhelpful. * Work on getting BP+ to compile in its new env * Correct BP+ folder name * Further tweaks to get closer to compiling * Remove the ScalarMatrix file It's only used for AC proofs * Compiles, with tests passing * Lock BP+ to Ed25519 instead of the generic Ciphersuite * Resolve most warnings in BP+ * Make existing bulletproofs test easier to read * Further strip generators * Swap G/H as Monero did * Replace RangeCommitment with Commitment * Hard-code BP+ h to Ed25519's generator * Use pub(crate) for BP+, not pub * Replace initial_transcript with hash_plus * Rename hash_plus to initial_transcript * Finish integrating the FCMP BP+ impl * Move BP+ folder * Correct no-std support * Rename "long_n" to eta * Add note on non-prime order dfg points
67 lines
1.6 KiB
Rust
67 lines
1.6 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!(
|
|
"
|
|
pub(crate) static GENERATORS_CELL: OnceLock<Generators> = OnceLock::new();
|
|
pub fn GENERATORS() -> &'static Generators {{
|
|
GENERATORS_CELL.get_or_init(|| Generators {{
|
|
G: [
|
|
{G_str}
|
|
],
|
|
H: [
|
|
{H_str}
|
|
],
|
|
}})
|
|
}}
|
|
",
|
|
)
|
|
.as_bytes(),
|
|
)
|
|
.unwrap();
|
|
}
|
|
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=build.rs");
|
|
|
|
generators("bulletproof", "generators.rs");
|
|
generators("bulletproof_plus", "generators_plus.rs");
|
|
}
|