Skip to content

fix DomainSeparator IV derivation logic#149

Draft
mmaker wants to merge 2 commits into
mainfrom
codex/pr114-derive
Draft

fix DomainSeparator IV derivation logic#149
mmaker wants to merge 2 commits into
mainfrom
codex/pr114-derive

Conversation

@mmaker
Copy link
Copy Markdown
Member

@mmaker mmaker commented May 7, 2026

No description provided.

pub fn protocol_id() -> [u8; 64] {
protocol_id(core::format_args!("schnorr proof"))
pub fn protocol_id() -> Vec<u8> {
protocol_label(core::format_args!("schnorr proof"))
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified, remove protocol_label and format_args

@@ -1,227 +1,186 @@
//! Utilities for domain separation.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove the module documentation without replacing it with something meaningful

use crate::{DuplexSpongeInterface, Encoding, ProverState, StdHash};

/// Sponge / compilation info for [`domain_separator!`] when no explicit `sponge_info` is supplied.
pub const DOMAIN_SEPARATOR_MACRO_SPONGE_INFO: &[u8] = b"spongefish/domain_separator/macro/v1";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why is this constant exported?

///
/// domain_separator!("this will not compile").std_prover();
/// ```
///
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this example removed?

/// This type is used to make sure that the developer does not forget to add it.
///
/// ```compile_fail
/// # // a BAD EXAMPLE of instantiating a domain separator.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these lines, it's understood by compile_fail

fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("WithSession").field(&self.0).finish()
}
fn absorb_domain_field(sponge: &mut StdHash, field: &[u8]) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function can be inlined

Comment on lines +71 to 73
for field in [protocol_id, sponge_info, session] {
absorb_domain_field(&mut sponge, field);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please unroll this for loop, let's be clear about what happens

domsep
}

/// Domain separator for a Fiat--Shamir transformation.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the module documentation, let's try to preserve documentation information

Comment thread spongefish/src/tests.rs
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore DomainSeparator::session, that's not part of this immediate change.

I liked the idea of declaring a session after a protocol ID, since the session can be given at runtime.
I agree that we should make it mandatory to be declared if needed, but this check can be forced when running to_prover.
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants