Skip to content

Update "a**b" writting to "a^b" in diffie-hellman description #1933

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

Merged
merged 3 commits into from
Jan 29, 2022
Merged
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
6 changes: 3 additions & 3 deletions exercises/diffie-hellman/description.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ the same to pick a private key b.

Alice calculates a public key A.

A = g**a mod p
A = gᵃ mod p

Using the same p and g, Bob similarly calculates a public key B from his
private key b.
Expand All @@ -28,11 +28,11 @@ private key b.

Alice and Bob exchange public keys. Alice calculates secret key s.

s = B**a mod p
s = Bᵃ mod p

Bob calculates

s = A**b mod p
s = Aᵇ mod p

The calculations produce the same result! Alice and Bob now share
secret s.
Copy link
Member

Choose a reason for hiding this comment

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

I would like to suggest adding a note be added at the end of this document that mentions that in some programming languages ** is used as the method to indicate exponentiations instead of ^.

I think just replacing one form for another doesn't necessarily clear up the confusion for everyone, just shifts it.

Copy link
Contributor

@wolf99 wolf99 Jan 28, 2022

Choose a reason for hiding this comment

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

Might it be better to remove any implementation dependent form and instead use the mathematical form? (i.e. aᵇ).
That is what is being described after all.

Copy link
Member

Choose a reason for hiding this comment

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

Hard agree with @wolf99 comment. For example, in Python, ^ is used as a set operator, which is why ** is used for exponentiation. It varies widely by programming language.

Copy link
Member

Choose a reason for hiding this comment

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

@wolf99 I like your suggestion, however I worry about how the special character will translate for users. If there is no concern to worry about then 👍 from me too.

Copy link
Contributor Author

@Gautzilla Gautzilla Jan 29, 2022

Choose a reason for hiding this comment

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

I feel exactly like @rpottsoh : would aᵇ render properly in any IDE for people downloading the exercise through CLI?

I would like to suggest adding a note be added at the end of this document that mentions that in some programming languages ** is used as the method to indicate exponentiations instead of ^.

The note might just mention that a^b means "a raised to the power of b", or "aaa*...*a" b times", so that the description only uses mathematics and no programming conventions?

Copy link
Contributor

@SaschaMann SaschaMann Jan 29, 2022

Choose a reason for hiding this comment

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

We have other exercises that use them. If an IDE can't display standard characters like that, it's most likely a deliberate choice by the student to use an archaic IDE and make their life hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thus, I see no reason not to use this notation. I'll make a new commit.

Copy link
Member

Choose a reason for hiding this comment

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

deliberate choice by the student to use archaic IDE

I use ed (not always) and it displays it, so I wonder if you mean "IDE that sucks" rather than archaic.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of trying to abstract it away:

s = (A to the power of b) mod p