-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Implementation Guidance to Recommend Compressed Point Encoding #117
Conversation
Signed-off-by: Frank Hinek <[email protected]>
Signed-off-by: Frank Hinek <[email protected]>
Signed-off-by: Frank Hinek <[email protected]>
Signed-off-by: Frank Hinek <[email protected]>
Co-authored-by: Moe Jangda <[email protected]>
Signed-off-by: Frank Hinek <[email protected]>
- DID Document representations ****SHOULD**** always use fully qualified identifiers (e.g. `did:dht:uodqi99wuzxsz6yx445zxkp8ddwj9q54ocbcg8yifsqru45x63kj#0` as opposed to `0` or `#0`) | ||
- [[ref:DID Document]] representations of elliptic curve (EC) keys ****MUST**** include the x- and y-coordinate pair. | ||
To conserve space in the DNS packet representation, compressed point encoding ****MUST**** be used to transmit the | ||
x-coordinate and a sign bit for the y-coordinate. This practice reduces each public key's size from 65 to 33 bytes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this true for all key types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@decentralgabe it is true for all EC
key types. In terms of current key types in the DID DHT Registry, that includes secp256k1
and secp256r1
.
It is not relevant for OKP
keys such as Ed25519
since compressed encoding (only the 32-byte x-coordinate) is always used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two small ones feel free to merge
Summary
This PR will:
Context
Elliptic-curve points (e.g.,
secp256k1
,secp256r1
) can be encoded as either the x-coordinate and y-coordinate or the x-coordinate and a sign bit for the y-coordinate. The latter encoding, called compressed point encoding, can be used to shrink the size of the DNS packet encoded representation of a DID DHT document by nearly half (65
->33
bytes). It also serves to align the payload size of Ed25519 (32
bytes) and secp256k1/secp256r1 (33
bytes) keys.It's also worth noting that the public keys are unpadded Base64URL-encoded such that the each uncompressed secp256k1/secp256r1 key actually consumes
87
bytes in the DNS packet. Using compressed point encoding decreases the size to44
bytes.The added note includes guidance that the DID Document representation must include the x- and y-coordinate pair for all
EC
JWKs. As noted in RFC 8812:Prior Art
Compressed point encoding has also been used in:
Additional References