EndGame v3

This commit is contained in:
Aksh 2024-10-23 20:50:14 +05:30
commit 9e36ba54ee
646 changed files with 271674 additions and 0 deletions

View file

@ -0,0 +1,40 @@
package gobpk
import (
"crypto/ed25519"
"gobalance/pkg/onionbalance/hs_v3/ext"
)
// gobpk == gobalance private key
// PrivateKey wrapper around ed25519 private key to handle both tor format or normal
type PrivateKey struct {
isPrivKeyInTorFormat bool
privateKey ed25519.PrivateKey
}
// Public returns the public key bytes
func (k PrivateKey) Public() ed25519.PublicKey {
if k.isPrivKeyInTorFormat {
return ext.PublickeyFromESK(k.privateKey)
}
return k.privateKey.Public().(ed25519.PublicKey)
}
// Seed returns the underlying ed25519 private key seed
func (k PrivateKey) Seed() []byte {
return k.privateKey.Seed()
}
// IsPrivKeyInTorFormat returns either or not the private key is in tor format
func (k PrivateKey) IsPrivKeyInTorFormat() bool {
return k.isPrivKeyInTorFormat
}
// New created a new PrivateKey
func New(privateKey ed25519.PrivateKey, isPrivKeyInTorFormat bool) PrivateKey {
return PrivateKey{
privateKey: privateKey,
isPrivKeyInTorFormat: isPrivKeyInTorFormat,
}
}