Skip to content

Comments

feat: intialize cargo features in post-quantum to use signature schemes based on feature#791

Merged
KolbyML merged 6 commits intoReamLabs:masterfrom
shariqnaiyer:feature/shariqnaiyer/modular-hashsig
Sep 19, 2025
Merged

feat: intialize cargo features in post-quantum to use signature schemes based on feature#791
KolbyML merged 6 commits intoReamLabs:masterfrom
shariqnaiyer:feature/shariqnaiyer/modular-hashsig

Conversation

@shariqnaiyer
Copy link
Contributor

What was wrong?

Fixes: #771

How was it fixed?

I initially tried using an enum to select the signature scheme and then trying to use a config.rs file to set a PROD or TEST or some other config.

I found those to be unclean solutions so I then moved to looking into cargo features. I found that to be a pretty clean solution to making hash-sig configurable.

I am looking for input for this approach from @syjn99 and @KolbyML. I shall add some more documentation if this is good.

To-Do

Comment on lines 12 to 47
const LOG_LIFETIME: usize = 8;
const DIMENSION: usize = 16;
const BASE: usize = 4;
const FINAL_LAYER: usize = 24;
const TARGET_SUM: usize = 24;

const PARAMETER_LEN: usize = 5;
const TWEAK_LEN_FE: usize = 2;
const MSG_LEN_FE: usize = 9;
const RAND_LEN_FE: usize = 7;
const HASH_LEN_FE: usize = 8;

const CAPACITY: usize = 9;

const POS_OUTPUT_LEN_PER_INV_FE: usize = 15;
const POS_INVOCATIONS: usize = 1;
const POS_OUTPUT_LEN_FE: usize = POS_OUTPUT_LEN_PER_INV_FE * POS_INVOCATIONS;

type MH = TopLevelPoseidonMessageHash<
POS_OUTPUT_LEN_PER_INV_FE,
POS_INVOCATIONS,
POS_OUTPUT_LEN_FE,
DIMENSION,
BASE,
FINAL_LAYER,
TWEAK_LEN_FE,
MSG_LEN_FE,
PARAMETER_LEN,
RAND_LEN_FE,
>;
type TH = PoseidonTweakHash<PARAMETER_LEN, HASH_LEN_FE, TWEAK_LEN_FE, CAPACITY, DIMENSION>;

#[allow(clippy::upper_case_acronyms)]
type PRF = ShakePRFtoF<HASH_LEN_FE>;

type IE = TargetSumEncoding<MH, TARGET_SUM>;
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to use more descriptive const and type names

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks better now.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO it seems better to follow what hash-sig does: https://github.com/b-wagn/hash-sig/blob/84dd4564a17383c154d0e4c25a248c601a1b8914/src/signature/generalized_xmss/instantiations_poseidon_top_level.rs#L11-L47

crate/crypto/post_quantum/src/hashsig is totally dependent on hash-sig library, which means if we use different notation, it might be confusing.

Copy link
Contributor

@KolbyML KolbyML Sep 19, 2025

Choose a reason for hiding this comment

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

I don't know why we would follow naming paradigms decided on by researchers (often not known for readable names). what is confusing is seeing FE, what does it stand for Fan Edition? https://www.samsung.com/uk/mobile-phone-buying-guide/what-is-samsung-fe/

I don't see how using more descriptive names would make it more confusing

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't want to read a math proof etc etc, leave the x,y,z's for the papers

Copy link
Contributor

@KolbyML KolbyML Sep 19, 2025

Choose a reason for hiding this comment

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

IE = internet explorer?, etc

Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: looks good

@KolbyML KolbyML enabled auto-merge September 19, 2025 16:35
@KolbyML KolbyML added this pull request to the merge queue Sep 19, 2025
Merged via the queue into ReamLabs:master with commit e04d438 Sep 19, 2025
14 checks passed
@syjn99 syjn99 added the Lean label Sep 25, 2025
@shariqnaiyer shariqnaiyer deleted the feature/shariqnaiyer/modular-hashsig branch October 16, 2025 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make HashSigScheme configurable & Match with current leanSpec

3 participants