diff --git a/coins/monero/build.rs b/coins/monero/build.rs index a54a3f2d3..db15c1cfd 100644 --- a/coins/monero/build.rs +++ b/coins/monero/build.rs @@ -44,10 +44,10 @@ fn generators(prefix: &'static str, path: &str) { pub(crate) static GENERATORS_CELL: OnceLock = OnceLock::new(); pub fn GENERATORS() -> &'static Generators {{ GENERATORS_CELL.get_or_init(|| Generators {{ - G: [ + G: vec![ {G_str} ], - H: [ + H: vec![ {H_str} ], }}) diff --git a/coins/monero/generators/src/lib.rs b/coins/monero/generators/src/lib.rs index 7f630f36e..e0377dca7 100644 --- a/coins/monero/generators/src/lib.rs +++ b/coins/monero/generators/src/lib.rs @@ -5,7 +5,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -use std_shims::sync::OnceLock; +use std_shims::{sync::OnceLock, vec::Vec}; use sha3::{Digest, Keccak256}; @@ -56,14 +56,13 @@ const MAX_MN: usize = MAX_M * N; /// Container struct for Bulletproofs(+) generators. #[allow(non_snake_case)] pub struct Generators { - pub G: [EdwardsPoint; MAX_MN], - pub H: [EdwardsPoint; MAX_MN], + pub G: Vec, + pub H: Vec, } /// Generate generators as needed for Bulletproofs(+), as Monero does. pub fn bulletproofs_generators(dst: &'static [u8]) -> Generators { - let mut res = - Generators { G: [EdwardsPoint::identity(); MAX_MN], H: [EdwardsPoint::identity(); MAX_MN] }; + let mut res = Generators { G: Vec::with_capacity(MAX_MN), H: Vec::with_capacity(MAX_MN) }; for i in 0 .. MAX_MN { let i = 2 * i; @@ -73,8 +72,8 @@ pub fn bulletproofs_generators(dst: &'static [u8]) -> Generators { write_varint(&i.try_into().unwrap(), &mut even).unwrap(); write_varint(&(i + 1).try_into().unwrap(), &mut odd).unwrap(); - res.H[i / 2] = EdwardsPoint(hash_to_point(hash(&even))); - res.G[i / 2] = EdwardsPoint(hash_to_point(hash(&odd))); + res.H.push(EdwardsPoint(hash_to_point(hash(&even)))); + res.G.push(EdwardsPoint(hash_to_point(hash(&odd)))); } res }