// Generated by Lisette bindgen
// Source: crypto/ecdh (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.20

import "go:crypto"
import "go:io"

pub fn P256() -> Curve

pub fn P384() -> Curve

pub fn P521() -> Curve

pub fn X25519() -> Curve

pub interface Curve {
  fn GenerateKey(rand: io.Reader) -> Result<Ref<PrivateKey>, error>
  fn NewPrivateKey(key: Slice<uint8>) -> Result<Ref<PrivateKey>, error>
  fn NewPublicKey(key: Slice<uint8>) -> Result<Ref<PublicKey>, error>
}

/// PrivateKey is an ECDH private key, usually kept secret.
/// 
/// These keys can be parsed with [crypto/x509.ParsePKCS8PrivateKey] and encoded
/// with [crypto/x509.MarshalPKCS8PrivateKey]. For NIST curves, they then need to
/// be converted with [crypto/ecdsa.PrivateKey.ECDH] after parsing.
pub type PrivateKey

/// PublicKey is an ECDH public key, usually a peer's ECDH share sent over the wire.
/// 
/// These keys can be parsed with [crypto/x509.ParsePKIXPublicKey] and encoded
/// with [crypto/x509.MarshalPKIXPublicKey]. For NIST curves, they then need to
/// be converted with [crypto/ecdsa.PublicKey.ECDH] after parsing.
pub type PublicKey

impl PrivateKey {
  /// Bytes returns a copy of the encoding of the private key.
  fn Bytes(self: Ref<PrivateKey>) -> Slice<uint8>

  fn Curve(self: Ref<PrivateKey>) -> Curve

  /// ECDH performs an ECDH exchange and returns the shared secret. The [PrivateKey]
  /// and [PublicKey] must use the same curve.
  /// 
  /// For NIST curves, this performs ECDH as specified in SEC 1, Version 2.0,
  /// Section 3.3.1, and returns the x-coordinate encoded according to SEC 1,
  /// Version 2.0, Section 2.3.5. The result is never the point at infinity.
  /// This is also known as the Shared Secret Computation of the Ephemeral Unified
  /// Model scheme specified in NIST SP 800-56A Rev. 3, Section 6.1.2.2.
  /// 
  /// For [X25519], this performs ECDH as specified in RFC 7748, Section 6.1. If
  /// the result is the all-zero value, ECDH returns an error.
  fn ECDH(self: Ref<PrivateKey>, remote: Ref<PublicKey>) -> Result<Slice<uint8>, error>

  /// Equal returns whether x represents the same private key as k.
  /// 
  /// Note that there can be equivalent private keys with different encodings which
  /// would return false from this check but behave the same way as inputs to [ECDH].
  /// 
  /// This check is performed in constant time as long as the key types and their
  /// curve match.
  fn Equal(self: Ref<PrivateKey>, x: crypto.PrivateKey) -> bool

  /// Public implements the implicit interface of all standard library private
  /// keys. See the docs of [crypto.PrivateKey].
  fn Public(self: Ref<PrivateKey>) -> crypto.PublicKey

  fn PublicKey(self: Ref<PrivateKey>) -> Ref<PublicKey>
}

impl PublicKey {
  /// Bytes returns a copy of the encoding of the public key.
  fn Bytes(self: Ref<PublicKey>) -> Slice<uint8>

  fn Curve(self: Ref<PublicKey>) -> Curve

  /// Equal returns whether x represents the same public key as k.
  /// 
  /// Note that there can be equivalent public keys with different encodings which
  /// would return false from this check but behave the same way as inputs to ECDH.
  /// 
  /// This check is performed in constant time as long as the key types and their
  /// curve match.
  fn Equal(self: Ref<PublicKey>, x: crypto.PublicKey) -> bool
}
