Comments (5)
Hi @heartsucker!
I'm sorry that I don't know anything about that OID but I am guessing that what they mean by "append the X and Y coordinates to each other" what they actually are referring to is the x- and y-coordinates in affine coordinates (assuming a Weierstrass model???). The points within an ed25519_dalek::PublicKey
are curve25519_dalek::curve::ExtendedPoints
, so in extended homogeneous twisted Edwards representation, which is projective. (Otherwise appending x and y makes no sense, as it wouldn't add any additional information.)
There's the FieldElement.to_bytes()
method, would that work for your use case to do FieldElement.to_bytes().as_ref()
or such? The internal representation of a FieldElement is implementation specific though, and as such likely not portable.
from curve25519-dalek.
I think they really are just appending the coordinates to each other. This is the method from ECPoint.java.
public byte[] getEncoded(boolean compressed)
{
if (this.isInfinity())
{
return new byte[1];
}
ECPoint normed = normalize();
byte[] X = normed.getXCoord().getEncoded();
if (compressed)
{
byte[] PO = new byte[X.length + 1];
PO[0] = (byte)(normed.getCompressionYTilde() ? 0x03 : 0x02);
System.arraycopy(X, 0, PO, 1, X.length);
return PO;
}
byte[] Y = normed.getYCoord().getEncoded();
byte[] PO = new byte[X.length + Y.length + 1];
PO[0] = 0x04;
System.arraycopy(X, 0, PO, 1, X.length);
System.arraycopy(Y, 0, PO, X.length + 1, Y.length);
return PO;
}
Otherwise appending x and y makes no sense, as it wouldn't add any additional information.
Yes, this is true. However this OID is for generic elliptic curves, so I think the idea was to split it into the x and y coordinates to make it use the same format for all keys for all curves. But the actual why isn't so important as that's what I have to deal with.
It also looks like there's only FieldElement32::to_bytes
, but not the same function for the generic sized FieldElement
. Since the docs on FieldElement32::to_bytes
say that the bytes are canonical, would it be possible to add an Info<FieldElement32> for FieldElement
to allow someone to get that representation. Or am I a missing a compiler flag or some intermediate step?
from curve25519-dalek.
Got back to the office and realized FieldElement
is just an alias for FieldElement32
. Closing this as resolved.
from curve25519-dalek.
However this OID is for generic elliptic curves
Please don't make software that uses that encoding of Ed25519/X25519 public keys. We intentionally standardized the alternate, now-standard, encoding, and nobody wants to support the generic encoding.
from curve25519-dalek.
I agree. I'm interfacing with an application that uses this encoding, so that's what I'm stuck using.
from curve25519-dalek.
Related Issues (20)
- Elliptic curve discrete logarithm problem (decoding RistrettoPoints) HOT 5
- benchmark selection on the command line seems partially broken
- Ed25519: should compare and hash use uncompressed points? HOT 2
- Pointer width detection in `build.rs` may break for obscure platforms HOT 1
- ed25519_dalek No generate function HOT 2
- Split up crates so end users can get faster compile times HOT 9
- `curve25519_dalek::SubgroupPoint`: missing traits
- Build fails on nightly-2024-02-05 HOT 2
- Crate fails with `nightly-2024-02-06` HOT 3
- How to check a VerifyingKey point is within the prime order subgroup HOT 3
- Support NIST validation criteria for Edwards points HOT 2
- ed25519: support PKCS#8 v1 (for OpenSSL interop)? HOT 2
- Use of unstable library feature 'stdsimd HOT 6
- Use of unstable library feature 'stdsimd' HOT 3
- Incorrect use of cfg to import dependency HOT 1
- docs.rs homepage examples use `rand_core` crate option, but do not mention its existence HOT 2
- [docs request] how to serialize a public key in the format compatible with `~/.ssh/authorized_keys`? HOT 2
- AVX512-IFMA & AVX10 status
- curve25519: nightly CI seems borked w/ warn(unused_imports)
- Impl std::num_traits::{One, Zero} for Scalar types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from curve25519-dalek.