Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ pub trait SignatureScheme {
message: &[u8; MESSAGE_LENGTH],
sig: &Self::Signature,
) -> bool;

/// Get public key corresponding to given secret key.
///
/// ### Parameters
/// * `sk`: A reference to the secret key.
///
/// ### Returns
/// Public key corresponding to given secret key.
fn get_public_key(sk: &Self::SecretKey) -> Self::PublicKey;
}

pub mod generalized_xmss;
Expand Down
10 changes: 8 additions & 2 deletions src/signature/generalized_xmss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,8 @@ where
&parameter,
roots_of_bottom_trees,
);
let root = top_tree.root();

// assemble public key and secret key
let pk = GeneralizedXMSSPublicKey { root, parameter };
let sk = GeneralizedXMSSSecretKey {
prf_key,
parameter,
Expand All @@ -841,6 +839,7 @@ where
right_bottom_tree,
_encoding_type: PhantomData,
};
let pk = Self::get_public_key(&sk);

(pk, sk)
}
Expand Down Expand Up @@ -1003,6 +1002,13 @@ where
&sig.path,
)
}

fn get_public_key(sk: &Self::SecretKey) -> Self::PublicKey {
Self::PublicKey {
root: sk.top_tree.root(),
parameter: sk.parameter,
}
}
}

impl<TH: TweakableHash> Encode for GeneralizedXMSSPublicKey<TH> {
Expand Down
Loading