Initial commit: AetherForge Linux (forge-mesh) v0.1.0-dev
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
This commit is contained in:
19
internal/forge/keys.go
Normal file
19
internal/forge/keys.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package forge
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// ParsePublicKeyHex decodes a hex-encoded ed25519 public key.
|
||||
func ParsePublicKeyHex(hexKey string) (ed25519.PublicKey, error) {
|
||||
raw, err := hex.DecodeString(hexKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("decode pubkey: %w", err)
|
||||
}
|
||||
if len(raw) != ed25519.PublicKeySize {
|
||||
return nil, fmt.Errorf("invalid pubkey size %d", len(raw))
|
||||
}
|
||||
return ed25519.PublicKey(raw), nil
|
||||
}
|
||||
Reference in New Issue
Block a user