mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-23 12:09:37 +00:00
Update visibility of various items in Monero
This commit is contained in:
parent
60d93c4b2d
commit
d596eeee6e
9 changed files with 34 additions and 35 deletions
|
@ -42,7 +42,7 @@ fn generators(prefix: &'static str, path: &str) {
|
||||||
format!(
|
format!(
|
||||||
"
|
"
|
||||||
lazy_static! {{
|
lazy_static! {{
|
||||||
static ref GENERATORS: Generators = Generators {{
|
pub static ref GENERATORS: Generators = Generators {{
|
||||||
G: [
|
G: [
|
||||||
{}
|
{}
|
||||||
],
|
],
|
||||||
|
|
|
@ -14,7 +14,9 @@ pub(crate) mod core;
|
||||||
use self::core::LOG_N;
|
use self::core::LOG_N;
|
||||||
|
|
||||||
pub(crate) mod original;
|
pub(crate) mod original;
|
||||||
|
pub use original::GENERATORS as BULLETPROOFS_GENERATORS;
|
||||||
pub(crate) mod plus;
|
pub(crate) mod plus;
|
||||||
|
pub use plus::GENERATORS as BULLETPROOFS_PLUS_GENERATORS;
|
||||||
|
|
||||||
pub(crate) use self::original::OriginalStruct;
|
pub(crate) use self::original::OriginalStruct;
|
||||||
pub(crate) use self::plus::PlusStruct;
|
pub(crate) use self::plus::PlusStruct;
|
||||||
|
@ -118,7 +120,7 @@ impl Bulletproofs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signature_serialize<W: std::io::Write>(&self, w: &mut W) -> std::io::Result<()> {
|
pub(crate) fn signature_serialize<W: std::io::Write>(&self, w: &mut W) -> std::io::Result<()> {
|
||||||
self.serialize_core(w, |points, w| write_raw_vec(write_point, points, w))
|
self.serialize_core(w, |points, w| write_raw_vec(write_point, points, w))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,9 +51,9 @@ pub enum ClsagError {
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Zeroize, ZeroizeOnDrop)]
|
#[derive(Clone, PartialEq, Eq, Debug, Zeroize, ZeroizeOnDrop)]
|
||||||
pub struct ClsagInput {
|
pub struct ClsagInput {
|
||||||
// The actual commitment for the true spend
|
// The actual commitment for the true spend
|
||||||
pub commitment: Commitment,
|
pub(crate) commitment: Commitment,
|
||||||
// True spend index, offsets, and ring
|
// True spend index, offsets, and ring
|
||||||
pub decoys: Decoys,
|
pub(crate) decoys: Decoys,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClsagInput {
|
impl ClsagInput {
|
||||||
|
|
|
@ -55,13 +55,13 @@ impl ClsagInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Zeroize, ZeroizeOnDrop)]
|
#[derive(Clone, Debug, Zeroize, ZeroizeOnDrop)]
|
||||||
pub struct ClsagDetails {
|
pub(crate) struct ClsagDetails {
|
||||||
input: ClsagInput,
|
input: ClsagInput,
|
||||||
mask: Scalar,
|
mask: Scalar,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClsagDetails {
|
impl ClsagDetails {
|
||||||
pub fn new(input: ClsagInput, mask: Scalar) -> ClsagDetails {
|
pub(crate) fn new(input: ClsagInput, mask: Scalar) -> ClsagDetails {
|
||||||
ClsagDetails { input, mask }
|
ClsagDetails { input, mask }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,10 +111,6 @@ impl ClsagMultisig {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const fn serialized_len() -> usize {
|
|
||||||
32 + (2 * 32)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn input(&self) -> ClsagInput {
|
fn input(&self) -> ClsagInput {
|
||||||
(*self.details.read().unwrap()).as_ref().unwrap().input.clone()
|
(*self.details.read().unwrap()).as_ref().unwrap().input.clone()
|
||||||
}
|
}
|
||||||
|
@ -137,7 +133,7 @@ impl Algorithm<Ed25519> for ClsagMultisig {
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
view: &FrostView<Ed25519>,
|
view: &FrostView<Ed25519>,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
let mut serialized = Vec::with_capacity(Self::serialized_len());
|
let mut serialized = Vec::with_capacity(32 + (2 * 32));
|
||||||
serialized.extend((view.secret_share().0 * self.H).compress().to_bytes());
|
serialized.extend((view.secret_share().0 * self.H).compress().to_bytes());
|
||||||
serialized.extend(write_dleq(rng, self.H, view.secret_share().0));
|
serialized.extend(write_dleq(rng, self.H, view.secret_share().0));
|
||||||
serialized
|
serialized
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use curve25519_dalek::edwards::EdwardsPoint;
|
use curve25519_dalek::edwards::EdwardsPoint;
|
||||||
|
|
||||||
pub(crate) use monero_generators::{hash_to_point as raw_hash_to_point};
|
pub use monero_generators::{hash_to_point as raw_hash_to_point};
|
||||||
|
|
||||||
pub fn hash_to_point(key: EdwardsPoint) -> EdwardsPoint {
|
pub fn hash_to_point(key: EdwardsPoint) -> EdwardsPoint {
|
||||||
raw_hash_to_point(key.compress().to_bytes())
|
raw_hash_to_point(key.compress().to_bytes())
|
||||||
|
|
|
@ -3,7 +3,7 @@ use zeroize::Zeroize;
|
||||||
use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, scalar::Scalar, edwards::EdwardsPoint};
|
use curve25519_dalek::{constants::ED25519_BASEPOINT_TABLE, scalar::Scalar, edwards::EdwardsPoint};
|
||||||
|
|
||||||
pub(crate) mod hash_to_point;
|
pub(crate) mod hash_to_point;
|
||||||
pub use hash_to_point::hash_to_point;
|
pub use hash_to_point::{raw_hash_to_point, hash_to_point};
|
||||||
|
|
||||||
pub mod clsag;
|
pub mod clsag;
|
||||||
pub mod bulletproofs;
|
pub mod bulletproofs;
|
||||||
|
@ -127,7 +127,7 @@ impl RctPrunable {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signature_serialize<W: std::io::Write>(&self, w: &mut W) -> std::io::Result<()> {
|
pub(crate) fn signature_serialize<W: std::io::Write>(&self, w: &mut W) -> std::io::Result<()> {
|
||||||
match self {
|
match self {
|
||||||
RctPrunable::Null => panic!("Serializing RctPrunable::Null for a signature"),
|
RctPrunable::Null => panic!("Serializing RctPrunable::Null for a signature"),
|
||||||
RctPrunable::Clsag { bulletproofs, .. } => {
|
RctPrunable::Clsag { bulletproofs, .. } => {
|
||||||
|
|
|
@ -17,9 +17,9 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct EmptyResponse {}
|
struct EmptyResponse {}
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct JsonRpcResponse<T> {
|
struct JsonRpcResponse<T> {
|
||||||
result: T,
|
result: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,6 +205,7 @@ impl Rpc {
|
||||||
txs.iter().cloned().collect::<Result<_, _>>()
|
txs.iter().cloned().collect::<Result<_, _>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove with https://github.com/serai-dex/serai/issues/25
|
||||||
pub async fn get_transactions_possible(
|
pub async fn get_transactions_possible(
|
||||||
&self,
|
&self,
|
||||||
hashes: &[[u8; 32]],
|
hashes: &[[u8; 32]],
|
||||||
|
@ -297,7 +298,7 @@ impl Rpc {
|
||||||
) -> Result<Vec<u64>, RpcError> {
|
) -> Result<Vec<u64>, RpcError> {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Distribution {
|
struct Distribution {
|
||||||
distribution: Vec<u64>,
|
distribution: Vec<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +333,7 @@ impl Rpc {
|
||||||
height: usize,
|
height: usize,
|
||||||
) -> Result<Vec<Option<[EdwardsPoint; 2]>>, RpcError> {
|
) -> Result<Vec<Option<[EdwardsPoint; 2]>>, RpcError> {
|
||||||
#[derive(Deserialize, Debug)]
|
#[derive(Deserialize, Debug)]
|
||||||
pub struct Out {
|
struct Out {
|
||||||
key: String,
|
key: String,
|
||||||
mask: String,
|
mask: String,
|
||||||
txid: String,
|
txid: String,
|
||||||
|
|
|
@ -5,17 +5,17 @@ use curve25519_dalek::{
|
||||||
edwards::{EdwardsPoint, CompressedEdwardsY},
|
edwards::{EdwardsPoint, CompressedEdwardsY},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const VARINT_CONTINUATION_MASK: u8 = 0b1000_0000;
|
const VARINT_CONTINUATION_MASK: u8 = 0b1000_0000;
|
||||||
|
|
||||||
pub fn varint_len(varint: usize) -> usize {
|
fn varint_len(varint: usize) -> usize {
|
||||||
((usize::try_from(usize::BITS - varint.leading_zeros()).unwrap().saturating_sub(1)) / 7) + 1
|
((usize::try_from(usize::BITS - varint.leading_zeros()).unwrap().saturating_sub(1)) / 7) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_byte<W: io::Write>(byte: &u8, w: &mut W) -> io::Result<()> {
|
pub(crate) fn write_byte<W: io::Write>(byte: &u8, w: &mut W) -> io::Result<()> {
|
||||||
w.write_all(&[*byte])
|
w.write_all(&[*byte])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_varint<W: io::Write>(varint: &u64, w: &mut W) -> io::Result<()> {
|
pub(crate) fn write_varint<W: io::Write>(varint: &u64, w: &mut W) -> io::Result<()> {
|
||||||
let mut varint = *varint;
|
let mut varint = *varint;
|
||||||
while {
|
while {
|
||||||
let mut b = u8::try_from(varint & u64::from(!VARINT_CONTINUATION_MASK)).unwrap();
|
let mut b = u8::try_from(varint & u64::from(!VARINT_CONTINUATION_MASK)).unwrap();
|
||||||
|
@ -29,15 +29,15 @@ pub fn write_varint<W: io::Write>(varint: &u64, w: &mut W) -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_scalar<W: io::Write>(scalar: &Scalar, w: &mut W) -> io::Result<()> {
|
pub(crate) fn write_scalar<W: io::Write>(scalar: &Scalar, w: &mut W) -> io::Result<()> {
|
||||||
w.write_all(&scalar.to_bytes())
|
w.write_all(&scalar.to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_point<W: io::Write>(point: &EdwardsPoint, w: &mut W) -> io::Result<()> {
|
pub(crate) fn write_point<W: io::Write>(point: &EdwardsPoint, w: &mut W) -> io::Result<()> {
|
||||||
w.write_all(&point.compress().to_bytes())
|
w.write_all(&point.compress().to_bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_raw_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
pub(crate) fn write_raw_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
||||||
f: F,
|
f: F,
|
||||||
values: &[T],
|
values: &[T],
|
||||||
w: &mut W,
|
w: &mut W,
|
||||||
|
@ -48,7 +48,7 @@ pub fn write_raw_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
pub(crate) fn write_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
||||||
f: F,
|
f: F,
|
||||||
values: &[T],
|
values: &[T],
|
||||||
w: &mut W,
|
w: &mut W,
|
||||||
|
@ -57,21 +57,21 @@ pub fn write_vec<T, W: io::Write, F: Fn(&T, &mut W) -> io::Result<()>>(
|
||||||
write_raw_vec(f, values, w)
|
write_raw_vec(f, values, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_bytes<R: io::Read, const N: usize>(r: &mut R) -> io::Result<[u8; N]> {
|
pub(crate) fn read_bytes<R: io::Read, const N: usize>(r: &mut R) -> io::Result<[u8; N]> {
|
||||||
let mut res = [0; N];
|
let mut res = [0; N];
|
||||||
r.read_exact(&mut res)?;
|
r.read_exact(&mut res)?;
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_byte<R: io::Read>(r: &mut R) -> io::Result<u8> {
|
pub(crate) fn read_byte<R: io::Read>(r: &mut R) -> io::Result<u8> {
|
||||||
Ok(read_bytes::<_, 1>(r)?[0])
|
Ok(read_bytes::<_, 1>(r)?[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_u64<R: io::Read>(r: &mut R) -> io::Result<u64> {
|
pub(crate) fn read_u64<R: io::Read>(r: &mut R) -> io::Result<u64> {
|
||||||
read_bytes(r).map(u64::from_le_bytes)
|
read_bytes(r).map(u64::from_le_bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_varint<R: io::Read>(r: &mut R) -> io::Result<u64> {
|
pub(crate) fn read_varint<R: io::Read>(r: &mut R) -> io::Result<u64> {
|
||||||
let mut bits = 0;
|
let mut bits = 0;
|
||||||
let mut res = 0;
|
let mut res = 0;
|
||||||
while {
|
while {
|
||||||
|
@ -91,12 +91,12 @@ pub fn read_varint<R: io::Read>(r: &mut R) -> io::Result<u64> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: https://github.com/serai-dex/serai/issues/25
|
// TODO: https://github.com/serai-dex/serai/issues/25
|
||||||
pub fn read_scalar<R: io::Read>(r: &mut R) -> io::Result<Scalar> {
|
pub(crate) fn read_scalar<R: io::Read>(r: &mut R) -> io::Result<Scalar> {
|
||||||
Scalar::from_canonical_bytes(read_bytes(r)?)
|
Scalar::from_canonical_bytes(read_bytes(r)?)
|
||||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "unreduced scalar"))
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "unreduced scalar"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_point<R: io::Read>(r: &mut R) -> io::Result<EdwardsPoint> {
|
pub(crate) fn read_point<R: io::Read>(r: &mut R) -> io::Result<EdwardsPoint> {
|
||||||
let bytes = read_bytes(r)?;
|
let bytes = read_bytes(r)?;
|
||||||
CompressedEdwardsY(bytes)
|
CompressedEdwardsY(bytes)
|
||||||
.decompress()
|
.decompress()
|
||||||
|
@ -105,7 +105,7 @@ pub fn read_point<R: io::Read>(r: &mut R) -> io::Result<EdwardsPoint> {
|
||||||
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point"))
|
.ok_or_else(|| io::Error::new(io::ErrorKind::Other, "invalid point"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_raw_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
pub(crate) fn read_raw_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
||||||
f: F,
|
f: F,
|
||||||
len: usize,
|
len: usize,
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
|
@ -117,7 +117,7 @@ pub fn read_raw_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
pub(crate) fn read_vec<R: io::Read, T, F: Fn(&mut R) -> io::Result<T>>(
|
||||||
f: F,
|
f: F,
|
||||||
r: &mut R,
|
r: &mut R,
|
||||||
) -> io::Result<Vec<T>> {
|
) -> io::Result<Vec<T>> {
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl Decoys {
|
||||||
self.offsets.len()
|
self.offsets.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn select<R: RngCore + CryptoRng>(
|
pub async fn select<R: RngCore + CryptoRng>(
|
||||||
rng: &mut R,
|
rng: &mut R,
|
||||||
rpc: &Rpc,
|
rpc: &Rpc,
|
||||||
ring_len: usize,
|
ring_len: usize,
|
||||||
|
|
Loading…
Reference in a new issue