Skip to content

ECDH and Diffie-Hellman #12

@username1565

Description

@username1565

Hello. I see there is ECDH functions in kbgpg.js.
I think Diffie-Hellman tab can be added in PGP Suite with the page.
For example, here: https://8gwifi.org/DHFunctions.jsp
after press button with defalut p, and g parameters,
I can see PGP format for the keys:


--------BEGIN ALICE KEYPAIR INFORMATION---------
----Public Key Information
Algo = DH
Format = X.509
Encoded = MGkwRwYJKoZIhvcNAQMBMDoCGwFT1dYXKttDBFtoro4d4QcLYTcAVobSnT1zpwIbCUlP7AlfO4Xu
KGVCs4NvyBpd0KA0m0wjndOHAx4AAhsBGZsRI6KBTepeFAG3JRXo89LoAKsawnipwz0=
----Private Key Information
Algo = DH
Format = PKCS#8
Encoded = MGsCAQAwRwYJKoZIhvcNAQMBMDoCGwFT1dYXKttDBFtoro4d4QcLYTcAVobSnT1zpwIbCUlP7Alf
O4XuKGVCs4NvyBpd0KA0m0wjndOHBB0CGwDnHlemsO7AoyTjzo7iZEo/XuKAUqeeEv2JZQ==
--------END ALICE KEYPAIR INFORMATION---------

--------BEGIN BOB KEYPAIR INFORMATION---------
----Public Key Information
Algo = DH
Format = X.509
Encoded = MGkwRwYJKoZIhvcNAQMBMDoCGwFT1dYXKttDBFtoro4d4QcLYTcAVobSnT1zpwIbCUlP7AlfO4Xu
KGVCs4NvyBpd0KA0m0wjndOHAx4AAhsAx61htj0th6/Ahslg08SYrNwVXr56Vl0TPZw=
----Private Key Information
Algo = DH
Format = PKCS#8
Encoded = MGsCAQAwRwYJKoZIhvcNAQMBMDoCGwFT1dYXKttDBFtoro4d4QcLYTcAVobSnT1zpwIbCUlP7Alf
O4XuKGVCs4NvyBpd0KA0m0wjndOHBB0CGwCNDj/0RYtjY303WWtwry+i18HLpvB9QYaPTQ==
--------End BOB KEYPAIR INFORMATION---------

aSharedSecret jRnOV7D8b4cLt0Stf0OEtxnDqVU=
bSharedSecret jRnOV7D8b4cLt0Stf0OEtxnDqVU=


last key can be used as key for AES encryption.

So if DH page will be added to PGP suite, this can
have content, like this:
http://www-cs-students.stanford.edu/~tjw/jsbn/ecdh.html

  • KEYS in PGP format... But... Here is ECDH, and this is Diffie-Hellman on elliptic curve.
    Last page is portable and all scripts is open source JS scripts.
    They can be working locally... But...
    This is DH on ELLIPTIC CURVES (and there is many curves available for selecting)...

And... What about real Diffie-Hellman key exchange, without any elliptic curve(s)?
I see in Wikipedia, there is need to generate p, and g (this is primitive root by module p).

And for do finding a primitive root by module p, need two parameters:

  1. φ(p) = p-1 for prime numbers,
  2. Need to gactorize φ(p) for do check (a^(φ(p)/prime_factors) === 1),
    like here: https://github.com/rsandor/number-theory/blob/master/lib/primitive_root.js
  3. Prime factorization for φ(p), if φ(p) is BigInteger, and have length 10^616 (2^2048)
    need fast factorization algorightm, like fermat test, pollard algorithm or monte-carlo algo.

Also, I don't see any DH example in the web. Best regards...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions