Skip to content

Document the maximum length in EcdhPrivateKey.deriveBits for each curve #130

Description

@jonasfj

Documentation for EcdhPrivateKey.deriveBits could have bullet point list mentining the maximum length of bits that can be derived from each curve.

Example

[length] specifies the length of the derived secret in bits. The maximum length depends on the [EllipticCurve] used in the keys:
...
 * [EllipticCurve.p521] can provide up to 528 bits.

See:

/// Derive a shared secret from two ECDH key pairs using the private key from one pair
/// and the public key from another.
///
/// The shared secret is identical whether using A's private key and B's public key,
/// or B's private key and A's public key, enabling secure key exchange between the
/// two parties.
///
/// [length] specifies the length of the derived secret in bits.
/// [publicKey] is [EcdhPublicKey] from the other party's ECDH key pair.
///
/// Returns a [Uint8List] containing the derived shared secret.
///
/// {@macro EcdhPrivateKey:example}
// Note some webcrypto implementations (chrome, not firefox) supports passing
// null for length (in this primitive). However, you can always know the right
// length from the curve. Note p512 can provide up to: 528 bits!!!
//
// See: https://tools.ietf.org/html/rfc6090#section-4
// Notice that this is not uniformly distributed, see also:
// https://tools.ietf.org/html/rfc6090#appendix-B
Future<Uint8List> deriveBits(int length, EcdhPublicKey publicKey);


  • Find maximum length for each curve.
  • Add tests for each curve + maximum length in deriveBits.
  • Document maximum length that can be derived for each curve.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions