mirror of
https://github.com/RustCrypto/signatures
synced 2026-06-21 13:45:42 +00:00
ml-dsa: updates for module_lattice::{encoding, utils} (#1191)
These were renamed in RustCrypto/KEMs#221
This commit is contained in:
Generated
+1
-1
@@ -725,7 +725,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "module-lattice"
|
||||
version = "0.1.0-pre.0"
|
||||
source = "git+https://github.com/RustCrypto/KEMs#5a2b2ae2003bd6c6f5ff5944ef07b3cd84a4d252"
|
||||
source = "git+https://github.com/RustCrypto/KEMs#c3b485d4a6e4ea70b60b18bccca038772ef1981b"
|
||||
dependencies = [
|
||||
"hybrid-array",
|
||||
"num-traits",
|
||||
|
||||
@@ -2,7 +2,7 @@ use hybrid_array::{
|
||||
ArraySize,
|
||||
typenum::{Shleft, U1, U13, Unsigned},
|
||||
};
|
||||
pub(crate) use module_lattice::{algebra::Field, util::Truncate};
|
||||
pub(crate) use module_lattice::{algebra::Field, utils::Truncate};
|
||||
|
||||
use module_lattice::{algebra, define_field};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use sha3::{
|
||||
digest::{ExtendableOutput, XofReader},
|
||||
};
|
||||
|
||||
use module_lattice::encode::ArraySize;
|
||||
use module_lattice::encoding::ArraySize;
|
||||
|
||||
pub(crate) enum ShakeState<Shake: ExtendableOutput> {
|
||||
Absorbing(Shake),
|
||||
@@ -63,7 +63,7 @@ pub(crate) type H = ShakeState<Shake256>;
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::util::B32;
|
||||
use crate::B32;
|
||||
use hex_literal::hex;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -3,7 +3,7 @@ use hybrid_array::{
|
||||
Array,
|
||||
typenum::{Len, Length, Sum, Unsigned},
|
||||
};
|
||||
use module_lattice::encode::{ArraySize, Encode, EncodingSize, VectorEncodingSize};
|
||||
use module_lattice::encoding::{ArraySize, Encode, EncodingSize, VectorEncodingSize};
|
||||
|
||||
use crate::algebra::{Elem, Polynomial, Vector};
|
||||
|
||||
@@ -119,7 +119,7 @@ pub(crate) mod test {
|
||||
marker_traits::Zero,
|
||||
operator_aliases::{Diff, Mod, Shleft},
|
||||
};
|
||||
use module_lattice::encode::*;
|
||||
use module_lattice::encoding::*;
|
||||
|
||||
// A helper trait to construct larger arrays by repeating smaller ones
|
||||
trait Repeat<T: Clone, D: ArraySize> {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ use hybrid_array::{
|
||||
Array,
|
||||
typenum::{U256, Unsigned},
|
||||
};
|
||||
use module_lattice::util::Truncate;
|
||||
use module_lattice::utils::Truncate;
|
||||
|
||||
use crate::algebra::{AlgebraExt, BaseField, Decompose, Elem, Field, Polynomial, Vector};
|
||||
use crate::param::{EncodedHint, SignatureParams};
|
||||
|
||||
+15
-12
@@ -44,7 +44,9 @@ mod ntt;
|
||||
mod param;
|
||||
mod pkcs8;
|
||||
mod sampling;
|
||||
mod util;
|
||||
|
||||
pub use crate::param::{EncodedSignature, EncodedVerifyingKey, ExpandedSigningKey, MlDsaParams};
|
||||
pub use signature::{self, Error};
|
||||
|
||||
use core::convert::{AsRef, TryFrom, TryInto};
|
||||
use hybrid_array::{
|
||||
@@ -57,6 +59,14 @@ use hybrid_array::{
|
||||
use sha3::Shake256;
|
||||
use signature::{DigestSigner, DigestVerifier, MultipartSigner, MultipartVerifier, Signer};
|
||||
|
||||
use crate::algebra::{AlgebraExt, Elem, NttMatrix, NttVector, Truncate, Vector};
|
||||
use crate::crypto::H;
|
||||
use crate::hint::Hint;
|
||||
use crate::ntt::{Ntt, NttInverse};
|
||||
use crate::param::{ParameterSet, QMinus1, SamplingSize, SpecQ};
|
||||
use crate::sampling::{expand_a, expand_mask, expand_s, sample_in_ball};
|
||||
use core::fmt;
|
||||
|
||||
#[cfg(feature = "rand_core")]
|
||||
use {
|
||||
rand_core::{CryptoRng, TryCryptoRng},
|
||||
@@ -66,18 +76,11 @@ use {
|
||||
#[cfg(feature = "zeroize")]
|
||||
use zeroize::{Zeroize, ZeroizeOnDrop};
|
||||
|
||||
use crate::algebra::{AlgebraExt, Elem, NttMatrix, NttVector, Truncate, Vector};
|
||||
use crate::crypto::H;
|
||||
use crate::hint::Hint;
|
||||
use crate::ntt::{Ntt, NttInverse};
|
||||
use crate::param::{ParameterSet, QMinus1, SamplingSize, SpecQ};
|
||||
use crate::sampling::{expand_a, expand_mask, expand_s, sample_in_ball};
|
||||
use crate::util::B64;
|
||||
use core::fmt;
|
||||
/// A 32-byte array, defined here for brevity because it is used several times
|
||||
pub type B32 = Array<u8, U32>;
|
||||
|
||||
pub use crate::param::{EncodedSignature, EncodedVerifyingKey, ExpandedSigningKey, MlDsaParams};
|
||||
pub use crate::util::B32;
|
||||
pub use signature::{self, Error};
|
||||
/// A 64-byte array, defined here for brevity because it is used several times
|
||||
pub(crate) type B64 = Array<u8, U64>;
|
||||
|
||||
/// ML-DSA seeds are signing (private) keys, which are consistently 32-bytes across all security
|
||||
/// levels, and are the preferred serialization for representing such keys.
|
||||
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
use module_lattice::{
|
||||
algebra::{Field, MultiplyNtt},
|
||||
encode::ArraySize,
|
||||
encoding::ArraySize,
|
||||
};
|
||||
|
||||
use crate::algebra::{BaseField, Elem, NttPolynomial, NttVector, Polynomial, Vector};
|
||||
|
||||
// Since the powers of zeta used in the NTT and MultiplyNTTs are fixed, we use pre-computed tables
|
||||
// to avoid the need to compute the exponetiations at runtime.
|
||||
// to avoid the need to compute the exponentiations at runtime.
|
||||
//
|
||||
// ZETA_POW_BITREV[i] = zeta^{BitRev_8(i)}
|
||||
//
|
||||
|
||||
+2
-2
@@ -9,9 +9,9 @@
|
||||
//! that the size of an encoded vector is `K` times the size of an encoded polynomial.
|
||||
|
||||
use crate::{
|
||||
B32, B64,
|
||||
algebra::{Polynomial, Vector},
|
||||
encode::{BitPack, RangeEncodedPolynomialSize, RangeEncodedVectorSize, RangeEncodingSize},
|
||||
util::{B32, B64},
|
||||
};
|
||||
use core::{
|
||||
fmt::Debug,
|
||||
@@ -24,7 +24,7 @@ use hybrid_array::{
|
||||
Unsigned,
|
||||
},
|
||||
};
|
||||
use module_lattice::encode::{
|
||||
use module_lattice::encoding::{
|
||||
ArraySize, Encode, EncodedPolynomialSize, EncodedVectorSize, EncodingSize,
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::{
|
||||
param::{Eta, MaskSamplingSize},
|
||||
};
|
||||
use hybrid_array::Array;
|
||||
use module_lattice::{encode::ArraySize, util::Truncate};
|
||||
use module_lattice::{encoding::ArraySize, utils::Truncate};
|
||||
|
||||
// Algorithm 13 BytesToBits
|
||||
fn bit_set(z: &[u8], i: usize) -> bool {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
use hybrid_array::{
|
||||
Array,
|
||||
typenum::{U32, U64},
|
||||
};
|
||||
|
||||
/// A 32-byte array, defined here for brevity because it is used several times
|
||||
pub type B32 = Array<u8, U32>;
|
||||
|
||||
/// A 64-byte array, defined here for brevity because it is used several times
|
||||
pub(crate) type B64 = Array<u8, U64>;
|
||||
@@ -87,7 +87,10 @@ macro_rules! mldsa_sign_seed_test {
|
||||
|
||||
match test.result {
|
||||
ExpectedResult::Valid => {
|
||||
assert_eq!(&*result.unwrap().to_bytes(), test.sig.as_slice())
|
||||
assert_eq!(
|
||||
&*result.expect("should be valid").to_bytes(),
|
||||
test.sig.as_slice()
|
||||
)
|
||||
}
|
||||
ExpectedResult::Invalid => {
|
||||
assert!(result.is_err())
|
||||
|
||||
Reference in New Issue
Block a user