Generate Bulletproofs(+) generators at compile time

Creates a new monero-generators crate so the monero crate can run the 
code in question at build time.

Saves several seconds from running the tests.

Closes https://github.com/serai-dex/serai/issues/101.
This commit is contained in:
Luke Parker
2022-08-21 06:36:53 -04:00
parent 577fe99a08
commit 603a3f8c9f
19 changed files with 274 additions and 133 deletions

View File

@@ -7,7 +7,6 @@ use transcript::RecommendedTranscript;
use frost::{curve::Ed25519, FrostKeys};
use monero_serai::{
ringct::bulletproofs::Bulletproofs,
transaction::Transaction,
rpc::Rpc,
wallet::{
@@ -69,14 +68,7 @@ pub struct Monero {
impl Monero {
pub async fn new(url: String) -> Monero {
let view = view_key::<Monero>(0).0;
let res = Monero { rpc: Rpc::new(url), view };
// Initialize Bulletproofs now to prevent the first call from taking several seconds
// TODO: Do this for both, unless we're sure we're only working on a single protocol
Bulletproofs::init(res.rpc.get_protocol().await.unwrap().bp_plus());
res
Monero { rpc: Rpc::new(url), view: view_key::<Monero>(0).0 }
}
fn view_pair(&self, spend: dfg::EdwardsPoint) -> ViewPair {