Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 100557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:36:08+00:00 2026-05-11T00:36:08+00:00

Back in the ITAR era, there was a popular sig that performed Diffie-Hellman key

  • 0

Back in the ITAR era, there was a popular sig that performed Diffie-Hellman key exchange:

#!/usr/bin/perl -- -export-a-crypto-system-sig Diffie-Hellman-2-lines ($g,$e,$m)=@ARGV,$m||die'$0 gen exp mod\n';print`echo '16dio1[d2%Sa2/d0<X+d *La1=z\U$m%0]SX$e'[$g*]\EszlXx+p|dc` 

With a modern dc, this can be reduced quite a bit to:

dc -e '16dio???|p' 

While the modern dc form with the modular exponentiation command (‘|’ computes g^e % m via efficient exponential doubling) is likely unbeatable other than perhaps APL, can the original form be improved upon? Keep in mind that the e and m values will be very large; they will both be on the order of 1024 bits each for cryptographic security.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:36:09+00:00Added an answer on May 11, 2026 at 12:36 am

    For those unfamiliar with Diffie-Hellman or dc (or Perl): all the program does, if you run it as "program g x m", is output gx(mod m), where g, x, and m are given in hexadecimal. E.g.

    ./dh.pl 10 2 9 4 

    because 10 is sixteen and 102 is two-hundred-and-fifty-six, which is 4 mod 9.

    And the dc command 16dio???|p says:

    • push sixteen onto the stack,
    • duplicate it,
    • set input radix (base) to the result of popping the stack (16, hex),
    • set output radix to the result of popping the stack (16),
    • get three lines of input and execute them (so if the three lines are three numbers g, x, m, they get pushed onto the stack),
    • do the exponentiation gx(mod m),
    • print it.

    Given that dc has a one-character command "|" for computing "gx(mod m)" which is precisely the problem, I find it highly unlikely that it can be improved upon in any programming language. dc just happens to be a tool for exactly this problem; it’s no contest comparing a programming language to the right tool. (E.g. any common programming language will take more than two characters to list files in a directory, while "ls" is only 2.)

    That said, I note that dc -e '16dio???|p' seems to want me to input the numbers in three different lines (at least on the dc I have here), so it can be improved to something that can handle them all on the same line 🙂

    dc -e '16dio?|p'

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.