Skip to content

Commit 0ccadec

Browse files
committed
use "view" functions (unmutable ref) instead of exposing the fields completely in GeneralizedXMSSSignature / GeneralizedXMSSPublicKey
1 parent 8fc5879 commit 0ccadec

File tree

2 files changed

+31
-9
lines changed

2 files changed

+31
-9
lines changed

src/signature/generalized_xmss.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,23 @@ pub struct GeneralizedXMSSSignatureScheme<
4343
#[derive(Serialize, Deserialize, Clone)]
4444
#[serde(bound = "")]
4545
pub struct GeneralizedXMSSSignature<IE: IncomparableEncoding, TH: TweakableHash> {
46-
pub path: HashTreeOpening<TH>,
47-
pub rho: IE::Randomness,
48-
pub hashes: Vec<TH::Domain>,
46+
path: HashTreeOpening<TH>,
47+
rho: IE::Randomness,
48+
hashes: Vec<TH::Domain>,
49+
}
50+
51+
impl<IE: IncomparableEncoding, TH: TweakableHash> GeneralizedXMSSSignature<IE, TH> {
52+
pub const fn path(&self) -> &HashTreeOpening<TH> {
53+
&self.path
54+
}
55+
56+
pub const fn rho(&self) -> &IE::Randomness {
57+
&self.rho
58+
}
59+
60+
pub const fn hashes(&self) -> &Vec<TH::Domain> {
61+
&self.hashes
62+
}
4963
}
5064

5165
impl<IE: IncomparableEncoding, TH: TweakableHash> Encode for GeneralizedXMSSSignature<IE, TH> {
@@ -176,8 +190,18 @@ impl<IE: IncomparableEncoding, TH: TweakableHash> Decode for GeneralizedXMSSSign
176190
/// It contains a Merkle root and a parameter for the tweakable hash
177191
#[derive(Serialize, Deserialize, Clone)]
178192
pub struct GeneralizedXMSSPublicKey<TH: TweakableHash> {
179-
pub root: TH::Domain,
180-
pub parameter: TH::Parameter,
193+
root: TH::Domain,
194+
parameter: TH::Parameter,
195+
}
196+
197+
impl<TH: TweakableHash> GeneralizedXMSSPublicKey<TH> {
198+
pub const fn root(&self) -> &TH::Domain {
199+
&self.root
200+
}
201+
202+
pub const fn parameter(&self) -> &TH::Parameter {
203+
&self.parameter
204+
}
181205
}
182206

183207
/// Secret key for GeneralizedXMSSSignatureScheme

src/symmetric/tweak_hash.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::fmt::Debug;
2-
31
use rand::Rng;
42

53
use crate::serialization::Serializable;
@@ -22,10 +20,10 @@ pub trait TweakableHash {
2220
type Parameter: Copy + Send + Sync + Serializable;
2321

2422
/// Tweak type for domain separation
25-
type Tweak: Debug;
23+
type Tweak;
2624

2725
/// Domain element type (defines output and input types to the hash)
28-
type Domain: Copy + PartialEq + Send + Sync + Serializable + Debug;
26+
type Domain: Copy + PartialEq + Send + Sync + Serializable;
2927

3028
/// Generates a random public parameter.
3129
fn rand_parameter<R: Rng>(rng: &mut R) -> Self::Parameter;

0 commit comments

Comments
 (0)