Documentation
¶
Overview ¶
Package common provides shared cryptographic primitives and utilities for OpenADP.
Package noise provides Noise-NK protocol implementation for OpenADP.
Index ¶
- Variables
- func DebugLog(message string)
- func DeriveEncKey(p *Point4D) []byte
- func GenerateKeypair() (noise.DHKey, error)
- func GetDeterministicEphemeralSecret() []byte
- func IsDebugModeEnabled() bool
- func IsValidPoint(p *Point4D) bool
- func PointCompress(p *Point4D) []byte
- func PointEqual(p1, p2 *Point4D) bool
- func SecretExpand(secret []byte) (*big.Int, error)
- func SecretToPublic(secret []byte) ([]byte, error)
- func SetDebugMode(enabled bool)
- func Sha256Hash(data []byte) []byte
- func TestNoiseNK() error
- func X25519DH(privateKey, publicKey []byte) ([]byte, error)
- func X25519GenerateKeypair() ([]byte, []byte, error)
- func X25519PublicKeyFromPrivate(privateKey []byte) ([]byte, error)
- type DebugRandomReader
- type NoiseNK
- func (nk *NoiseNK) Decrypt(ciphertext []byte, associatedData []byte) ([]byte, error)
- func (nk *NoiseNK) Encrypt(plaintext []byte, associatedData []byte) ([]byte, error)
- func (nk *NoiseNK) GetHandshakeHash() []byte
- func (nk *NoiseNK) GetPublicKey() []byte
- func (nk *NoiseNK) GetTransportKeys() ([]byte, []byte)
- func (nk *NoiseNK) IsHandshakeComplete() bool
- func (nk *NoiseNK) ReadHandshakeMessage(message []byte) ([]byte, error)
- func (nk *NoiseNK) SetRemotePublicKey(remotePublicKey []byte) error
- func (nk *NoiseNK) WriteHandshakeMessage(payload []byte) ([]byte, error)
- type Point2D
- type Point4D
Constants ¶
This section is empty.
Variables ¶
var ( // Base field Z_p where p = 2^255 - 19 P = new(big.Int) // Curve constant d = -121665 * inv(121666) mod p D = new(big.Int) // Group order q = 2^252 + 27742317777372353535851937790883648493 Q = new(big.Int) // Base point G G = &Point4D{} // Zero point (neutral element) ZeroPoint = &Point4D{} // Square root of -1 mod p ModpSqrtM1 = new(big.Int) )
Constants for Ed25519 curve
Functions ¶
func DebugLog ¶ added in v0.1.2
func DebugLog(message string)
DebugLog prints a debug message if debug mode is enabled
func DeriveEncKey ¶
DeriveEncKey derives an encryption key from a point
func GenerateKeypair ¶
GenerateKeypair generates a new X25519 keypair for Noise-NK
func GetDeterministicEphemeralSecret ¶ added in v0.1.2
func GetDeterministicEphemeralSecret() []byte
GetDeterministicEphemeralSecret returns a fixed ephemeral secret for reproducible Noise handshakes
func IsDebugModeEnabled ¶ added in v0.1.2
func IsDebugModeEnabled() bool
IsDebugModeEnabled returns whether debug mode is currently enabled
func IsValidPoint ¶
IsValidPoint checks if a point is valid using Ed25519 cofactor clearing
func PointCompress ¶
PointCompress compresses a point to 32 bytes
func PointEqual ¶
PointEqual checks if two points are equal in projective coordinates
func SecretExpand ¶
SecretExpand expands a 32-byte secret key to a scalar
func SecretToPublic ¶
SecretToPublic converts a private key to its corresponding public key
func SetDebugMode ¶ added in v0.1.2
func SetDebugMode(enabled bool)
SetDebugMode enables or disables debug mode for Noise-NK operations
func Sha256Hash ¶
Sha256Hash computes SHA-256 hash of input bytes
func TestNoiseNK ¶
func TestNoiseNK() error
TestNoiseNK runs a basic test of the Noise-NK implementation
func X25519GenerateKeypair ¶
X25519GenerateKeypair generates a X25519 keypair
func X25519PublicKeyFromPrivate ¶
X25519PublicKeyFromPrivate derives public key from private key
Types ¶
type DebugRandomReader ¶ added in v0.1.2
type DebugRandomReader struct {
// contains filtered or unexported fields
}
DebugRandomReader provides deterministic randomness for debug mode
type NoiseNK ¶
type NoiseNK struct {
// contains filtered or unexported fields
}
NoiseNK represents a Noise-NK protocol handler
func NewNoiseNK ¶
func NewNoiseNK(role string, localStaticKey *noise.DHKey, remoteStaticKey []byte, prologue []byte) (*NoiseNK, error)
NewNoiseNK creates a new Noise-NK endpoint
func (*NoiseNK) GetHandshakeHash ¶
GetHandshakeHash returns the handshake hash for channel binding
func (*NoiseNK) GetPublicKey ¶
GetPublicKey returns this party's static public key as bytes
func (*NoiseNK) GetTransportKeys ¶ added in v0.1.2
GetTransportKeys returns the actual transport keys for debugging
func (*NoiseNK) IsHandshakeComplete ¶
IsHandshakeComplete returns whether the handshake is complete
func (*NoiseNK) ReadHandshakeMessage ¶
ReadHandshakeMessage reads and processes a handshake message from the other party
func (*NoiseNK) SetRemotePublicKey ¶
SetRemotePublicKey sets the remote party's static public key and reinitializes handshake
type Point4D ¶
Point4D represents extended coordinates (X, Y, Z, T)
func PointDecompress ¶
PointDecompress decompresses 32 bytes to a point