mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-12 05:59:23 +00:00
* 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
51 lines
1.2 KiB
Rust
51 lines
1.2 KiB
Rust
use core::ops::{Index, IndexMut};
|
|
use std_shims::vec::Vec;
|
|
|
|
use zeroize::{Zeroize, ZeroizeOnDrop};
|
|
|
|
use dalek_ff_group::EdwardsPoint;
|
|
|
|
#[cfg(test)]
|
|
use multiexp::multiexp;
|
|
#[cfg(test)]
|
|
use crate::ringct::bulletproofs::plus::ScalarVector;
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, Zeroize, ZeroizeOnDrop)]
|
|
pub(crate) struct PointVector(pub(crate) Vec<EdwardsPoint>);
|
|
|
|
impl Index<usize> for PointVector {
|
|
type Output = EdwardsPoint;
|
|
fn index(&self, index: usize) -> &EdwardsPoint {
|
|
&self.0[index]
|
|
}
|
|
}
|
|
|
|
impl IndexMut<usize> for PointVector {
|
|
fn index_mut(&mut self, index: usize) -> &mut EdwardsPoint {
|
|
&mut self.0[index]
|
|
}
|
|
}
|
|
|
|
impl PointVector {
|
|
#[cfg(test)]
|
|
pub(crate) fn multiexp(&self, vector: &ScalarVector) -> EdwardsPoint {
|
|
debug_assert_eq!(self.len(), vector.len());
|
|
let mut res = Vec::with_capacity(self.len());
|
|
for (point, scalar) in self.0.iter().copied().zip(vector.0.iter().copied()) {
|
|
res.push((scalar, point));
|
|
}
|
|
multiexp(&res)
|
|
}
|
|
|
|
pub(crate) fn len(&self) -> usize {
|
|
self.0.len()
|
|
}
|
|
|
|
pub(crate) fn split(mut self) -> (Self, Self) {
|
|
debug_assert!(self.len() > 1);
|
|
let r = self.0.split_off(self.0.len() / 2);
|
|
debug_assert_eq!(self.len(), r.len());
|
|
(self, PointVector(r))
|
|
}
|
|
}
|