Files
Denozordec 4905c06b9b
Publish mtproxy_checker Docker image / test (push) Successful in 19s
Publish mtproxy_checker Docker image / build-and-push (push) Successful in 48s
init
2026-04-11 00:38:22 +07:00

28 lines
696 B
Go

package faketls
import (
crand "crypto/rand"
"golang.org/x/crypto/curve25519"
)
// GenX25519PublicKey returns a valid X25519 public key (32 bytes) for the ClientHello key_share extension.
// Some MTProxy builds validate the point; a random quadratic residue mod P (older telethon-faketls trick) is rejected.
func GenX25519PublicKey() ([]byte, error) {
var priv, pub [32]byte
if _, err := crand.Read(priv[:]); err != nil {
return nil, err
}
curve25519.ScalarBaseMult(&pub, &priv)
return pub[:], nil
}
// Rand32 returns 32 random bytes (session id).
func Rand32() ([]byte, error) {
b := make([]byte, 32)
if _, err := crand.Read(b); err != nil {
return nil, err
}
return b, nil
}