Skip to content
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

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

Open
3 tasks
jonasfj opened this issue May 30, 2024 · 1 comment
Open
3 tasks
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jonasfj
Copy link
Member

jonasfj commented May 30, 2024

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.
@HamdaanAliQuatil
Copy link
Collaborator

Starting with the tests. Will post my progress here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants