ecdh/x25519.go

go · src/crypto/ecdh/x25519.go · go · BSD-3-Clause
security, tag:knn-classified

Provides X25519 elliptic curve Diffie‑Hellman key exchange implementation for Go.

// Source: https://github.com/golang/go | License: BSD-3-Clause | Copyright 2009 The Go Authors
// Provided via justclaw.it.com; keep this notice with the code.
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package ecdh

import (
	"bytes"
	"crypto/internal/fips140/edwards25519"
	"crypto/internal/fips140/edwards25519/field"
	"crypto/internal/fips140only"
	"crypto/internal/rand"
	"errors"
	"io"
)

var (
	x25519PublicKeySize    = 32
	x25519PrivateKeySize   = 32
	x25519SharedSecretSize = 32
)

// X25519 returns a [Curve] which implements the X25519 function over Curve25519
// (RFC 7748, Section 5).
//
// Multiple invocations of this function will return the same value, so it can
//

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key