blockchain sandbox: UTXO chain, p2p mining, attacker node

This commit is contained in:
2026-07-26 20:37:26 +03:00
commit 7ce39c8964
18 changed files with 2536 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
package chain
import (
"crypto/ed25519"
"crypto/rand"
"encoding/hex"
)
type Wallet struct {
PrivateKey ed25519.PrivateKey
PublicKey ed25519.PublicKey
}
func NewWallet() *Wallet {
pub, priv, _ := ed25519.GenerateKey(rand.Reader)
return &Wallet{PrivateKey: priv, PublicKey: pub}
}
func (w *Wallet) Address() string {
return hex.EncodeToString(w.PublicKey)
}
func (w *Wallet) ShortAddress() string {
return w.Address()[:7]
}