nnathan / eccsnacks Goto Github PK
View Code? Open in Web Editor NEWReference implementation of Curve25519 and Curve448 as specified in RFC7748
License: Other
Reference implementation of Curve25519 and Curve448 as specified in RFC7748
License: Other
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.