/* * Copyright (c) 2026 Kaiy Ragur * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package utils import ( "crypto/ed25519" "crypto/sha512" "filippo.io/edwards25519" ) func PubEd25519ToX25519(pub ed25519.PublicKey) ([]byte, error) { point, err := edwards25519.NewIdentityPoint().SetBytes(pub) if err != nil { return nil, err } x25519Pub := point.BytesMontgomery() return x25519Pub, nil } func PrivEd25519ToX25519(priv ed25519.PrivateKey) ([]byte, error) { seed := priv.Seed() h := sha512.Sum512(seed) x25519Priv := h[:32] return x25519Priv, nil }