mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-09 12:49:23 +00:00
Refine from pedantic, remove erratic consts
This commit is contained in:
@@ -41,7 +41,7 @@ impl<G0: PrimeGroup, G1: PrimeGroup> Re<G0, G1> {
|
||||
Self::R(G0::identity(), G1::identity())
|
||||
}
|
||||
|
||||
pub(crate) const fn e_default() -> Self {
|
||||
pub(crate) fn e_default() -> Self {
|
||||
Self::e(G0::Scalar::ZERO)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ pub(crate) enum BitSignature {
|
||||
}
|
||||
|
||||
impl BitSignature {
|
||||
pub(crate) const fn to_u8(&self) -> u8 {
|
||||
pub(crate) fn to_u8(&self) -> u8 {
|
||||
match self {
|
||||
Self::ClassicLinear => 0,
|
||||
Self::ConciseLinear => 1,
|
||||
@@ -35,7 +35,7 @@ impl BitSignature {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn from(algorithm: u8) -> Self {
|
||||
pub(crate) fn from(algorithm: u8) -> Self {
|
||||
match algorithm {
|
||||
0 => Self::ClassicLinear,
|
||||
1 => Self::ConciseLinear,
|
||||
@@ -45,14 +45,14 @@ impl BitSignature {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn bits(&self) -> usize {
|
||||
pub(crate) fn bits(&self) -> usize {
|
||||
match self {
|
||||
Self::ClassicLinear | Self::EfficientLinear => 1,
|
||||
Self::ConciseLinear | Self::CompromiseLinear => 2,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const fn ring_len(&self) -> usize {
|
||||
pub(crate) fn ring_len(&self) -> usize {
|
||||
#[allow(clippy::as_conversions, clippy::cast_possible_truncation)] // Needed for const
|
||||
2_usize.pow(self.bits() as u32)
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ use core::ops::{Deref, DerefMut};
|
||||
#[cfg(feature = "serialize")]
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
use rand_core::{RngCore, CryptoRng};
|
||||
use thiserror::Error;
|
||||
|
||||
use zeroize::{Zeroize, Zeroizing};
|
||||
use rand_core::{RngCore, CryptoRng};
|
||||
|
||||
use digest::{Digest, HashMarker};
|
||||
|
||||
@@ -92,27 +93,21 @@ impl<G: PrimeGroup> Generators<G> {
|
||||
}
|
||||
|
||||
/// Error for cross-group DLEq proofs.
|
||||
#[allow(clippy::std_instead_of_core)]
|
||||
mod dleq_error {
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Error, PartialEq, Eq, Debug)]
|
||||
pub enum DLEqError {
|
||||
/// Invalid proof of knowledge.
|
||||
#[error("invalid proof of knowledge")]
|
||||
InvalidProofOfKnowledge,
|
||||
/// Invalid proof length.
|
||||
#[error("invalid proof length")]
|
||||
InvalidProofLength,
|
||||
/// Invalid challenge.
|
||||
#[error("invalid challenge")]
|
||||
InvalidChallenge,
|
||||
/// Invalid proof.
|
||||
#[error("invalid proof")]
|
||||
InvalidProof,
|
||||
}
|
||||
#[derive(Error, PartialEq, Eq, Debug)]
|
||||
pub enum DLEqError {
|
||||
/// Invalid proof of knowledge.
|
||||
#[error("invalid proof of knowledge")]
|
||||
InvalidProofOfKnowledge,
|
||||
/// Invalid proof length.
|
||||
#[error("invalid proof length")]
|
||||
InvalidProofLength,
|
||||
/// Invalid challenge.
|
||||
#[error("invalid challenge")]
|
||||
InvalidChallenge,
|
||||
/// Invalid proof.
|
||||
#[error("invalid proof")]
|
||||
InvalidProof,
|
||||
}
|
||||
pub use dleq_error::DLEqError;
|
||||
|
||||
// This should never be directly instantiated and uses a u8 to represent internal values
|
||||
// Any external usage is likely invalid
|
||||
|
||||
Reference in New Issue
Block a user