Coder Social home page Coder Social logo

eccsnacks's People

Contributors

nnathan avatar pdxwebdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eccsnacks's Issues

`scalarmult_base` derives different public keys relative to other Curve25519 libraries.

Hi,

I'm using two Curve25519 libraries to implement the Signal protocol. This one provides the DH math (scalarmult), and the other provides message signing and verification. I'm running into issues with interoperability because the derived public keys differ between eccsnacks and the other library.

Here are my findings. The following script produces different results for the private key b"a" * 32. I am using Python 3.6.4:

import ed25519 as ec
from eccsnacks import curve25519

print("Creating keypair through ed25519.")
privateKey, publicKey = ec.create_keypair(entropy=lambda x: b'a' * x)

print("  Private key:", repr(privateKey.to_seed()))
print("  Public key: ", repr(publicKey.to_bytes()))
print("      Length: ", len(publicKey.to_bytes()))

print()
print("Deriving public key through eccsnacks.")

# Convert the bytestring to an equivalent regular string, aka py3 nonsense.
# Because eccsnacks expects a regular string for its `pack` and `unpack`.
toRawString = lambda b:  "".join(chr(c)          for c in b)
toBytes     = lambda s: b"".join(bytes([ord(c)]) for c in s)

privkeyStr = toRawString(privateKey.to_seed())
derivedPubkey = curve25519.scalarmult_base(privkeyStr)

print("  Public key:", repr(derivedPubkey))
print("   as bytes: ", toBytes(derivedPubkey))
print("      length:", len(toBytes(derivedPubkey)))

The resulting output is:

Creating keypair through ed25519.
  Private key: b'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
  Public key:  b'\xaf\x06\xa3\xe3)\x17\x14\xe4\xf3V\xc1\x9c\x9b\x15\xcd\x19Q\xecnfb\xaaw\xbe\x07T\x7f(\x93\x834\x1d'
    length:    32

Deriving public key through eccsnacks.
  Public key: "@IP-¹,¢4,?\x92ÚÅÖÞ|\x85Û]õ@z[I\x96Î9òï·è'"
    as bytes: b"@IP-\xb9,\xa24,?\x92\xda\xc5\xd6\xde|\x85\xdb]\xf5@z[I\x96\xce9\xf2\xef\xb7\xe8'"
    length:   32

Any thoughts on this? Of course, this could be the fault of the other library or simply user error so if my assumptions of equality are incorrect please let me know.

Upload 1.0.2 to PyPI

Just following up after doing a pip install on another machine and it pulled 1.0.1 which doesn't include the Python 3 update. Sorry to bug you about it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.