mirror of
https://github.com/Egida/EndGame0.git
synced 2025-08-04 20:34:27 -04:00
22 lines
553 B
Go
22 lines
553 B
Go
package onionbalance
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/ed25519"
|
|
)
|
|
|
|
// LoadTorKeyFromDisk load a private identity key from little-t-tor.
|
|
func LoadTorKeyFromDisk(keyBytes []byte) ed25519.PrivateKey {
|
|
if !bytes.Equal(keyBytes[:29], []byte("== ed25519v1-secret: type0 ==")) {
|
|
panic("Tor key does not start with Tor header")
|
|
}
|
|
expandedSk := keyBytes[32:]
|
|
|
|
// The rest should be 64 bytes (a,h):
|
|
// 32 bytes for secret scalar 'a'
|
|
// 32 bytes for PRF key 'h'
|
|
if len(expandedSk) != 64 {
|
|
panic("Tor private key has the wrong length")
|
|
}
|
|
return expandedSk
|
|
}
|