Skip to content

Commit 150885e

Browse files
authored
Merge pull request #277 from KiraCore/release/v0.3.54
2 parents 2cb94fb + 341f346 commit 150885e

File tree

14 files changed

+653
-270
lines changed

14 files changed

+653
-270
lines changed

.github/workflows/main.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
build-amd64:
1010
name: AMD64 - Repo Test & Build
11-
runs-on: [ self-hosted, github-actions-amd64-runner-2 ]
11+
runs-on: [ self-hosted, X64 ]
1212
permissions:
1313
contents: read
1414
packages: write
@@ -99,7 +99,7 @@ jobs:
9999
path: ./tools-bin-amd64.tar.gz
100100
build-arm64:
101101
name: ARM64 - Repo Test & Build
102-
runs-on: [ self-hosted, github-actions-arm64-runner-1 ]
102+
runs-on: [ self-hosted, ARM64 ]
103103
needs: [build-amd64]
104104
permissions:
105105
contents: read
@@ -227,9 +227,9 @@ jobs:
227227
id-token: write
228228
pull-requests: write
229229
steps:
230-
# ref.: https://github.com/sigstore/cosign-installer, v3.0.1
230+
# ref.: https://github.com/sigstore/cosign-installer, v3.2.0
231231
- name: Install cosign
232-
uses: sigstore/cosign-installer@c3667d99424e7e6047999fb6246c0da843953c65
232+
uses: sigstore/cosign-installer@1fc5bd396d372bee37d608f955b336615edf79c8
233233
with:
234234
cosign-release: 'v2.0.0'
235235
- name: Download AMD64 artifacts
@@ -419,4 +419,4 @@ jobs:
419419
env:
420420
MERGE_LABELS: "automerge"
421421
GITHUB_TOKEN: "${{ secrets.REPO_ACCESS }}"
422-
LOG: "TRACE"
422+
LOG: "TRACE"

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Cosign requires simple initial setup of the signer keys described more precisely
99

1010
```bash
1111
# install cosign
12-
COSIGN_VERSION="v2.0.0" && \
12+
COSIGN_VERSION="v2.2.3" && \
1313
if [[ "$(uname -m)" == *"ar"* ]] ; then ARCH="arm64"; else ARCH="amd64" ; fi && echo $ARCH && \
1414
PLATFORM=$(uname) && FILE=$(echo "cosign-${PLATFORM}-${ARCH}" | tr '[:upper:]' '[:lower:]') && \
1515
wget https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/$FILE && chmod +x -v ./$FILE && \
@@ -37,7 +37,7 @@ KIRA bash-utils (BU) is a general purpose tool for simplifying scripts & command
3737

3838
```bash
3939
# one line install
40-
TOOLS_VERSION="v0.3.40" && cd /tmp && FILE_NAME="bash-utils.sh" && \
40+
TOOLS_VERSION="v0.3.54" && cd /tmp && FILE_NAME="bash-utils.sh" && \
4141
wget "https://github.com/KiraCore/tools/releases/download/$TOOLS_VERSION/${FILE_NAME}" -O ./$FILE_NAME && \
4242
wget "https://github.com/KiraCore/tools/releases/download/$TOOLS_VERSION/${FILE_NAME}.sig" -O ./${FILE_NAME}.sig && \
4343
cosign verify-blob --key="$KIRA_COSIGN_PUB" --signature=./${FILE_NAME}.sig ./$FILE_NAME --insecure-ignore-tlog && \
@@ -52,12 +52,12 @@ A simple and secure bip39 words generator that is able to mix computer and human
5252
```bash
5353
# once BU is installed, you can easily and securely install all tools for a relevant architecture and platform
5454
# one line install with verification of IPFS CID referencing a public key used to sign the release
55-
TOOLS_VERSION="v0.3.40" && TOOL_NAME="bip39gen" && cd /tmp && \
55+
TOOLS_VERSION="v0.3.54" && TOOL_NAME="bip39gen" && cd /tmp && \
5656
bu safeWget ./${TOOL_NAME}.deb "https://github.com/KiraCore/tools/releases/download/$TOOLS_VERSION/${TOOL_NAME}-$(getPlatform)-$(getArch).deb" \
5757
"QmeqFDLGfwoWgCy2ZEFXerVC5XW8c5xgRyhK5bLArBr2ue" && rm -rfv ./$TOOL_NAME&& dpkg-deb -x ./${TOOL_NAME}.deb ./$TOOL_NAME && \
5858
cp -fv ./$TOOL_NAME/bin/$TOOL_NAME /usr/local/bin/$TOOL_NAME && chmod +x "/usr/local/bin/$TOOL_NAME" && \
5959
rm -rfv ./$TOOL_NAME ./${TOOL_NAME}.deb
6060

6161
# Check bip39gen version
6262
bip39gen version
63-
```
63+
```

RELEASE.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
Features:
2-
* bu: add curl check
2+
* Refactor: validator-key-gen refactored for package usage
3+
* Add: new mnemonic to set - PrivKeyMnemonic
4+
* Fix: toml parser in bu
5+
* Cidi: change label for self-hosted runners
6+

bash-utils/bash-utils.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function bashUtilsVersion() {
2626
# this is default installation script for utils
2727
# ./bash-utils.sh bashUtilsSetup "/var/kiraglob"
2828
function bashUtilsSetup() {
29-
local BASH_UTILS_VERSION="v0.3.46"
29+
local BASH_UTILS_VERSION="v0.3.54"
3030
local COSIGN_VERSION="v2.0.0"
3131
if [ "$1" == "version" ] ; then
3232
echo "$BASH_UTILS_VERSION"
@@ -1929,7 +1929,8 @@ function getTomlVarNames() {
19291929
elif [ -z "$line" ] || [[ $line = \#* ]] ; then
19301930
continue
19311931
elif [[ $line = *=* ]] ; then
1932-
name=$(echo "$line" | cut -d= -f1 | xargs)
1932+
local name=$(echo "$line" | cut -d= -f1 | xargs)
1933+
name=$(echo "$name" | tr '.' '_') # Fix: replace dots with undescore
19331934
[ ! -z "$name" ] && echo "$tag $name"
19341935
fi
19351936
done
@@ -2322,3 +2323,7 @@ fi
23222323

23232324

23242325

2326+
2327+
2328+
2329+

bip39gen/cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9-
const Bip39GenVersion = "v0.3.46"
9+
const Bip39GenVersion = "v0.3.54"
1010

1111
func cmdVersion(cmd *cobra.Command, args []string) error {
1212
fmt.Println(Bip39GenVersion)

build-tools/update_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
import sys
33

4-
version = "v0.3.46"
4+
version = "v0.3.54"
55

66
if len(sys.argv) != 2:
77
print("Usage: python3 update_version.py <new_release>")

ipfs-api/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A command-line interface (CLI) for interacting with the IPFS API, providing func
55
To install the CLI, clone the repository and build the project using Go.= or dowload from existing release
66

77
```
8-
TOOLS_VERSION="v0.3.46" && rm -rfv /tmp/ipfs-api && \
8+
TOOLS_VERSION="v0.3.54" && rm -rfv /tmp/ipfs-api && \
99
safeWget /tmp/ipfs-api.deb "https://github.com/KiraCore/tools/releases/download/$TOOLS_VERSION/ipfs-api-$(getPlatform)-$(getArch).deb" "QmeqFDLGfwoWgCy2ZEFXerVC5XW8c5xgRyhK5bLArBr2ue" && \
1010
dpkg-deb -x /tmp/ipfs-api.deb /tmp/ipfs-api && cp -fv "/tmp/ipfs-api/bin/ipfs-api" /usr/local/bin/ipfs-api && chmod -v 755 /usr/local/bin/ipfs-api && \
1111
ipfs-api version

ipfs-api/types/constants.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package types
22

33
const (
4-
IpfsApiVersion = "v0.3.46"
4+
IpfsApiVersion = "v0.3.54"
55

66
// Pinata v1 constants
77
BASE_URL = "https://api.pinata.cloud"

scripts/version.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
echo "v0.3.46"
3+
echo "v0.3.54"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
package mnemonicsgenerator
2+
3+
import (
4+
"crypto/sha256"
5+
"encoding/hex"
6+
"fmt"
7+
"os"
8+
"strings"
9+
10+
valkeygen "github.com/KiraCore/tools/validator-key-gen/ValKeyGen"
11+
"github.com/cosmos/go-bip39"
12+
"github.com/tendermint/tendermint/crypto/ed25519"
13+
"github.com/tendermint/tendermint/p2p"
14+
)
15+
16+
const (
17+
DefaultValidatorNodeKeyFileName string = "validator_node_key.json"
18+
DefaultPrivValidatorKeyFileName string = "priv_validator_key.json"
19+
DefaultValidatorNodeIdFileName string = "validator_node_id.key"
20+
21+
DefaultPrefix string = "kira"
22+
DefaultPath string = "44'/118'/0'/0/0"
23+
)
24+
25+
type MasterMnemonicSet struct {
26+
ValidatorAddrMnemonic []byte
27+
ValidatorValMnemonic []byte
28+
SignerAddrMnemonic []byte
29+
ValidatorNodeMnemonic []byte
30+
ValidatorNodeId []byte
31+
PrivKeyMnemonic []byte
32+
}
33+
34+
// returns nodeId from mnemonic
35+
func generateNodeIdFromMnemonic(mnemonic string) []byte {
36+
if err := valkeygen.CheckMnemonic(mnemonic); err != nil {
37+
fmt.Fprintln(os.Stderr, err)
38+
os.Exit(1)
39+
}
40+
41+
tmPrivKey := ed25519.GenPrivKeyFromSecret([]byte(mnemonic))
42+
filenodekey := p2p.NodeKey{
43+
PrivKey: tmPrivKey,
44+
}
45+
nodeId := []byte(filenodekey.ID())
46+
return nodeId
47+
}
48+
49+
func createMnemonicsFile(path string, mnemonicData []byte) error {
50+
file, err := os.Create(path)
51+
if err != nil {
52+
fmt.Printf("Error creating %s file: %s", path, err)
53+
return err
54+
}
55+
defer file.Close()
56+
_, err = file.WriteString(string(mnemonicData))
57+
if err != nil {
58+
fmt.Printf("Error creating %s file: %s", path, err)
59+
return err
60+
}
61+
return nil
62+
}
63+
64+
// accepts name and typeOfMnemonic as salt and mnemonic, for example MnemonicGenerator --name="validator" --type="addr" - validator address
65+
func generateFromMasterMnemonic(name, typeOfMnemonic string, masterMnemonic []byte) ([]byte, error) {
66+
stringToHash := strings.ToLower(fmt.Sprintf("%s ; %s %s", masterMnemonic, name, typeOfMnemonic))
67+
stringToHash = strings.ReplaceAll(stringToHash, " ", "")
68+
69+
hasher := sha256.New()
70+
hasher.Write([]byte(stringToHash))
71+
entropyHex := hex.EncodeToString(hasher.Sum(nil))
72+
73+
entropy, err := hex.DecodeString(entropyHex)
74+
if err != nil {
75+
return []byte{}, fmt.Errorf("error decoding hex string: %w", err)
76+
}
77+
78+
mnemonic, err := bip39.NewMnemonic(entropy)
79+
if err != nil {
80+
return []byte{}, fmt.Errorf("error generating mnemonic: %w", err)
81+
}
82+
83+
return []byte(mnemonic), nil
84+
}
85+
86+
// # Generates set of mnemonics from master mnemonic, accepts masterMnemonic string as byte
87+
//
88+
// Default function call MasterKeysGen([]byte("mnemonic string"), "", "", "./path")
89+
//
90+
// go run .\main.go --mnemonic "want vanish frown filter resemble purchase trial baby equal never cinnamon claim wrap cash snake cable head tray few daring shine clip loyal series" --masterkeys .\test\ --master
91+
//
92+
// # FOR PACKAGE USAGE
93+
//
94+
// defaultPrefix: "kira"
95+
//
96+
// defaultPath: "44'/118'/0'/0/0"
97+
func MasterKeysGen(masterMnemonic []byte, defaultPrefix, defaultPath, masterkeys string) (mnemonicSet MasterMnemonicSet, err error) {
98+
err = valkeygen.CheckMnemonic(string(masterMnemonic))
99+
if err != nil {
100+
fmt.Fprintln(os.Stderr, err)
101+
return mnemonicSet, err
102+
}
103+
104+
ok, err := valkeygen.CheckPath([]string{masterkeys})
105+
if err != nil {
106+
fmt.Fprintln(os.Stderr, err)
107+
fmt.Println(ok, masterkeys)
108+
return mnemonicSet, err
109+
}
110+
111+
if ok {
112+
// VALIDATOR_NODE_MNEMONIC
113+
mnemonicSet.ValidatorNodeMnemonic, err = generateFromMasterMnemonic("validator", "node", masterMnemonic)
114+
if err != nil {
115+
fmt.Fprintln(os.Stderr, err)
116+
return mnemonicSet, err
117+
}
118+
119+
// VALIDATOR_NODE_ID
120+
mnemonicSet.ValidatorNodeId = generateNodeIdFromMnemonic(string(mnemonicSet.ValidatorNodeMnemonic))
121+
122+
// VALIDATOR_ADDR_MNEMONIC
123+
mnemonicSet.ValidatorAddrMnemonic, err = generateFromMasterMnemonic("validator", "addr", masterMnemonic)
124+
if err != nil {
125+
fmt.Fprintln(os.Stderr, err)
126+
return mnemonicSet, err
127+
}
128+
129+
// VALIDATOR_VAL_MNEMONIC
130+
mnemonicSet.ValidatorValMnemonic, err = generateFromMasterMnemonic("validator", "val", masterMnemonic)
131+
if err != nil {
132+
fmt.Fprintln(os.Stderr, err)
133+
return mnemonicSet, err
134+
}
135+
136+
// SIGNER_ADDR_MNEMONIC
137+
mnemonicSet.SignerAddrMnemonic, err = generateFromMasterMnemonic("signer", "addr", masterMnemonic)
138+
if err != nil {
139+
fmt.Fprintln(os.Stderr, err)
140+
return mnemonicSet, err
141+
}
142+
143+
// privKey mnemonic
144+
mnemonicSet.PrivKeyMnemonic, err = DerivePrivKeyMnemonicFromMasterMnemonic(masterMnemonic)
145+
if err != nil {
146+
fmt.Fprintln(os.Stderr, err)
147+
return mnemonicSet, err
148+
}
149+
150+
if masterkeys != "" {
151+
// validator_node_key.json validator_node_id.key" files
152+
valkeygen.ValKeyGen(string(mnemonicSet.ValidatorNodeMnemonic), defaultPrefix, defaultPath, "",
153+
fmt.Sprintf("%s/%s", masterkeys, DefaultValidatorNodeKeyFileName),
154+
fmt.Sprintf("%s/%s", masterkeys, DefaultValidatorNodeIdFileName),
155+
false, false, false)
156+
157+
// priv_validator_key.json files
158+
valkeygen.ValKeyGen(string(mnemonicSet.ValidatorValMnemonic), defaultPrefix, defaultPath, fmt.Sprintf("%s/%s", masterkeys, DefaultPrivValidatorKeyFileName), "", "", false, false, false)
159+
160+
// mnemonics.env file
161+
dataToWrite := []byte(fmt.Sprintf("MASTER_MNEMONIC=%s\nVALIDATOR_ADDR_MNEMONIC=%s\nVALIDATOR_NODE_MNEMONIC=%s\nVALIDATOR_NODE_ID=%s\nVALIDATOR_VAL_MNEMONIC=%s\nSIGNER_ADDR_MNEMONIC=%s\n ", masterMnemonic, mnemonicSet.ValidatorAddrMnemonic, mnemonicSet.ValidatorNodeMnemonic, mnemonicSet.ValidatorNodeId, mnemonicSet.ValidatorValMnemonic, mnemonicSet.SignerAddrMnemonic))
162+
163+
err = createMnemonicsFile(fmt.Sprintf("%s/mnemonics.env", masterkeys), dataToWrite)
164+
if err != nil {
165+
fmt.Fprintln(os.Stderr, err)
166+
return mnemonicSet, err
167+
}
168+
dataToWrite = []byte{}
169+
170+
}
171+
172+
}
173+
return mnemonicSet, nil
174+
}
175+
176+
// Accepts parent mnemonic as masterMnemonic and derives from it a PrivKeyMnemonic using generateFromMasterMnemonic func
177+
// salt is name and typeOfMnemonic hardcoded as const
178+
//
179+
// Constants:
180+
// name=priv,
181+
// typeOfMnemonic=key.
182+
func DerivePrivKeyMnemonicFromMasterMnemonic(masterMnemonic []byte) (privKey []byte, err error) {
183+
const name string = "priv"
184+
const typeOfMnemonic string = "key"
185+
err = valkeygen.CheckMnemonic(string(masterMnemonic))
186+
if err != nil {
187+
return nil, err
188+
}
189+
privKey, err = generateFromMasterMnemonic(name, typeOfMnemonic, masterMnemonic)
190+
if err != nil {
191+
return nil, fmt.Errorf("error while generating ")
192+
}
193+
return
194+
}

0 commit comments

Comments
 (0)