Initial commit

This commit is contained in:
2022-04-20 22:01:27 +02:00
parent 1a785ea628
commit 8561698bc3
13 changed files with 249 additions and 0 deletions

34
keymgmt/keymgmt.go Normal file
View File

@@ -0,0 +1,34 @@
package keymgmt
import (
"crypto/rand"
"crypto/rsa"
"encoding/base64"
"golang.org/x/crypto/sha3"
"log"
"math/big"
)
type Address struct {
pubkey int
privkey *rsa.PrivateKey
mod *big.Int
}
func GenerateAddress() *Address {
key, err := rsa.GenerateKey(rand.Reader, 1024)
if err != nil {
log.Fatal(err)
}
newAddress := Address{pubkey: key.E, privkey: key, mod: key.N}
return &newAddress
}
func (a Address) GetAddress() string {
hasher := sha3.New224()
hash := hasher.Sum(a.privkey.N.Bytes())
b64 := "!MBPA#" + base64.StdEncoding.EncodeToString(hash)[:64]
return b64
}