Module ecc_compact

Utility module for checking whether NIST P-256 (secp256r1) ECC keys can be compressed to only their X coordinate.

Description

Utility module for checking whether NIST P-256 (secp256r1) ECC keys can be compressed to only their X coordinate. This implementation implements the strategy described in https://tools.ietf.org/html/draft-jivsov-ecc-compact-05 and is based on a 1986 publication by Victor Miller in 'CRYPTO 85'. This method is believed to be unpatentable. See https://cr.yp.to/ecdh/patents.html for more details.

The implementation is done as a NIF linked against the system's libcrypto.

Data Types

compact_key()

compact_key() = coordinate()

coordinate()

coordinate() = <<_:256>>

point()

point() = <<_:520>>

private_key()

private_key() = #'ECPrivateKey'{}

public_key()

public_key() = {#'ECPoint'{}, {namedCurve, '?secp256r1'}}

Function Index

generate_key/0Generate a NIST p-256 key that is compliant with the compactness restrictions.
is_compact/1Returns whether a given key is compliant with the compactness restrictions.
recover_key/1Given the X coordinate of a public key from a compliant point on the curve, return the public key.

Function Details

generate_key/0

generate_key() -> {ok, private_key(), compact_key()}

Generate a NIST p-256 key that is compliant with the compactness restrictions.

is_compact/1

is_compact(PubKey::private_key() | public_key() | point()) -> {true, compact_key()} | false

Returns whether a given key is compliant with the compactness restrictions. In the case that the key is compliant, also return the bare X coordinate.

recover_key/1

recover_key(X::compact_key()) -> public_key()

Given the X coordinate of a public key from a compliant point on the curve, return the public key.


Generated by EDoc