Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

domain separation #139

Merged
merged 9 commits into from
Jul 4, 2019
Merged

domain separation #139

merged 9 commits into from
Jul 4, 2019

Conversation

kwantam
Copy link
Collaborator

@kwantam kwantam commented Jul 3, 2019

This essentially captures what's in #124:

  • add "HASH-TO-CURVE" literal in hash_to_base for H() separation

  • change ctr argument in encode_to_curve for free separation from hash_to_curve

  • add a new section in roadmap with requirements for domain separation

  • add a new definition for domain separation

Note that this does not comprehend #137. I think we can treat that as a separate question for now.

@kwantam kwantam requested review from chris-wood, armfazh and samscott89 and removed request for chris-wood July 3, 2019 06:30
This is used to efficiently create independent
instances of hash_to_base (see discussion above).

Output: u, an element in F.

Steps:
1. m' = H(msg) || I2OSP(ctr, 1)
1. m' = "HASH-TO-CURVE" || H(msg) || I2OSP(ctr, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we consider making HASH-TO-CURVE shorter (e..g "H2C"/ "HTC"), and potentially truncating H(msg) such that we can fit m' into a single block in the loop below?

E.g. the input to the hash in the loop becomes "H2C" || H(msg)[..len(H) - 6] || I2OSP(ctr, 1) || I2OSP(i, 1) || I2OSP(j, 1)?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps in a separate issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we'd have to truncate a reasonable amount to avoid going past one block, because SHA-256 adds at least 65 bits of padding to the end of the message. Specifically, the padding is

  • append a single '1' bit
  • append k '0' bits where 0 <= k < 512 and bitlen(msg) + 1 + k + 64 is divisible by 512
  • append a 64-bit representation of bitlen(msg)

so it would have to be something like H(msg)[..len(H) - 15], which is pretty extreme.

Also, we might want to resolve #137 first, since that would moot this discussion.

Copy link
Collaborator

@chris-wood chris-wood left a comment

Choose a reason for hiding this comment

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

The initial text looks good to me. I think some more clarity and examples would help drive the point home, so approving for now. Thanks, @kwantam!

draft-irtf-cfrg-hash-to-curve.md Outdated Show resolved Hide resolved
draft-irtf-cfrg-hash-to-curve.md Outdated Show resolved Hide resolved
by that protocol.
In practice, this assumption may not hold: commonly, two or more protocols
may model the same hash function as a random oracle, which violates the above
assumption if both protocols compute the hash of the same value.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps add:

That is, let R() be a random oracle used by protocols P1 and P2. If P1 and P2 ever query R with the same value x, the assumption above is violated.

And maybe then show how P1 and P2 would use R1 and R2 (as defined below) to address this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I think the first paragraph is unclear in a couple ways. I'll try to address and incorporate the above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, I think.

draft-irtf-cfrg-hash-to-curve.md Outdated Show resolved Hide resolved
draft-irtf-cfrg-hash-to-curve.md Outdated Show resolved Hide resolved
({{term-domain-separation}}) to avoid interfering with other protocols
that also use the hash\_to\_curve functionality.
In addition, any protocol that uses two or more hash\_to\_curve functions
targeting different elliptic curves MUST enforce domain separation between
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the expectation that if one had two hash-to-curve functions H1 and H2 targeting the same curve, then H1 = H2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, unless they're explicitly separated. I suppose I should clarify this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I pushed an edit to address this.

({{term-domain-separation}}) to avoid interfering with other protocols
that also use the hash\_to\_curve functionality.
In addition, any protocol that uses two or more hash\_to\_curve functions
targeting different elliptic curves MUST enforce domain separation between
Copy link
Collaborator

Choose a reason for hiding this comment

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

It'd be good to clarify why this requirement is needed. (That is, to avoid overlapping hash2base output IIUC.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I pushed an edit to address this.


As an example, consider a fictional key exchange protocol named Quux.
A reasonable choice of tag might be "QUUX-V\<xx\>-CS\<yy\>", where \<xx\> and \<yy\>
are two-digit numbers indicating the version and ciphersuite, respectively.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it help to give an example of a protocol that needs domain separation internally, too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I pushed an edit to address this.

draft-irtf-cfrg-hash-to-curve.md Show resolved Hide resolved
This is used to efficiently create independent
instances of hash_to_base (see discussion above).

Output: u, an element in F.

Steps:
1. m' = H(msg) || I2OSP(ctr, 1)
1. m' = "HASH-TO-CURVE" || H(msg) || I2OSP(ctr, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps in a separate issue?

Copy link
Collaborator

@armfazh armfazh left a comment

Choose a reason for hiding this comment

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

LGTM,

@kwantam kwantam force-pushed the domain_separation branch from 0400920 to b500bff Compare July 3, 2019 21:53
@chris-wood chris-wood merged commit f764a27 into cfrg:master Jul 4, 2019
@kwantam kwantam deleted the domain_separation branch July 4, 2019 23:58
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.

4 participants