Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v0.3.56 -> master #280

Merged
merged 32 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
2cb94fb
Merge pull request #265 from KiraCore/release/v0.3.46
asmodat Apr 23, 2023
643914a
Refactored for package ussage
PeepoFrog Feb 24, 2024
1f1c521
Added tests for key generation
PeepoFrog Feb 24, 2024
32f448b
import fix
PeepoFrog Feb 24, 2024
b32839b
refactored for package ussage, now importing default path and name va…
PeepoFrog Feb 24, 2024
444b067
Bump release ver.
MrLutik Feb 25, 2024
4c61e5b
bump release ver
MrLutik Mar 12, 2024
3a71f8e
bump ver
MrLutik Mar 12, 2024
3db0773
Return to self-hosted runner
MrLutik Mar 13, 2024
29ca51d
bump release ver
MrLutik Mar 13, 2024
814fd53
bump all ver
MrLutik Mar 13, 2024
51b6df1
change cosign installer
MrLutik Mar 13, 2024
01ba194
More control over file key generation functions, also return error fr…
PeepoFrog Apr 3, 2024
1d30199
feat(bugfix): Fix toml parser
MrLutik Apr 11, 2024
4106c09
feat(upgrade): Tools upgrade and fix
MrLutik Apr 11, 2024
c032615
feat(cidi): Update cidi
MrLutik Apr 11, 2024
341f346
Merge pull request #275 from KiraCore/feature/cidi_fix
MrLutik Apr 11, 2024
150885e
Merge pull request #277 from KiraCore/release/v0.3.54
asmodat Apr 11, 2024
a0bccb1
Bump release ver.
MrLutik Feb 25, 2024
3f1a823
bump release ver
MrLutik Mar 12, 2024
0acb406
bump ver
MrLutik Mar 12, 2024
8937559
Return to self-hosted runner
MrLutik Mar 13, 2024
676ff61
bump release ver
MrLutik Mar 13, 2024
fa82b1d
bump all ver
MrLutik Mar 13, 2024
6da96ba
change cosign installer
MrLutik Mar 13, 2024
dabaf7a
feat(bugfix): Fix toml parser
MrLutik Apr 11, 2024
562d602
feat(upgrade): Tools upgrade and fix
MrLutik Apr 11, 2024
b223482
feat(cidi): Update cidi
MrLutik Apr 11, 2024
25ab35b
Bump release ver.
MrLutik May 2, 2024
d92b11c
Bump version
MrLutik May 2, 2024
c49d294
Merge pull request #279 from KiraCore/feature/modifiy_val_key_gen
MrLutik May 2, 2024
e16e9b7
Merge branch 'latest' into release/v0.3.56
MrLutik May 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build-amd64:
name: AMD64 - Repo Test & Build
runs-on: [ self-hosted, github-actions-amd64-runner-2 ]
runs-on: [ self-hosted, X64 ]
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -99,7 +99,7 @@ jobs:
path: ./tools-bin-amd64.tar.gz
build-arm64:
name: ARM64 - Repo Test & Build
runs-on: [ self-hosted, github-actions-arm64-runner-1 ]
runs-on: [ self-hosted, ARM64 ]
needs: [build-amd64]
permissions:
contents: read
Expand Down Expand Up @@ -227,9 +227,9 @@ jobs:
id-token: write
pull-requests: write
steps:
# ref.: https://github.com/sigstore/cosign-installer, v3.0.1
# ref.: https://github.com/sigstore/cosign-installer, v3.2.0
- name: Install cosign
uses: sigstore/cosign-installer@c3667d99424e7e6047999fb6246c0da843953c65
uses: sigstore/cosign-installer@1fc5bd396d372bee37d608f955b336615edf79c8
with:
cosign-release: 'v2.0.0'
- name: Download AMD64 artifacts
Expand Down Expand Up @@ -419,4 +419,4 @@ jobs:
env:
MERGE_LABELS: "automerge"
GITHUB_TOKEN: "${{ secrets.REPO_ACCESS }}"
LOG: "TRACE"
LOG: "TRACE"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Cosign requires simple initial setup of the signer keys described more precisely

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

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

# Check bip39gen version
bip39gen version
```
```
6 changes: 5 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
Features:
* bu: add curl check
* Refactor: validator-key-gen refactored for package usage
* Add: new mnemonic to set - PrivKeyMnemonic
* Fix: toml parser in bu
* Cidi: change label for self-hosted runners

11 changes: 9 additions & 2 deletions bash-utils/bash-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function bashUtilsVersion() {
# this is default installation script for utils
# ./bash-utils.sh bashUtilsSetup "/var/kiraglob"
function bashUtilsSetup() {
local BASH_UTILS_VERSION="v0.3.46"
local BASH_UTILS_VERSION="v0.3.56"
local COSIGN_VERSION="v2.0.0"
if [ "$1" == "version" ] ; then
echo "$BASH_UTILS_VERSION"
Expand Down Expand Up @@ -1929,7 +1929,8 @@ function getTomlVarNames() {
elif [ -z "$line" ] || [[ $line = \#* ]] ; then
continue
elif [[ $line = *=* ]] ; then
name=$(echo "$line" | cut -d= -f1 | xargs)
local name=$(echo "$line" | cut -d= -f1 | xargs)
name=$(echo "$name" | tr '.' '_') # Fix: replace dots with undescore
[ ! -z "$name" ] && echo "$tag $name"
fi
done
Expand Down Expand Up @@ -2322,3 +2323,9 @@ fi









2 changes: 1 addition & 1 deletion bip39gen/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
)

const Bip39GenVersion = "v0.3.46"
const Bip39GenVersion = "v0.3.56"

func cmdVersion(cmd *cobra.Command, args []string) error {
fmt.Println(Bip39GenVersion)
Expand Down
2 changes: 1 addition & 1 deletion build-tools/update_version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import sys

version = "v0.3.46"
version = "v0.3.56"

if len(sys.argv) != 2:
print("Usage: python3 update_version.py <new_release>")
Expand Down
2 changes: 1 addition & 1 deletion ipfs-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A command-line interface (CLI) for interacting with the IPFS API, providing func
To install the CLI, clone the repository and build the project using Go.= or dowload from existing release

```
TOOLS_VERSION="v0.3.46" && rm -rfv /tmp/ipfs-api && \
TOOLS_VERSION="v0.3.56" && rm -rfv /tmp/ipfs-api && \
safeWget /tmp/ipfs-api.deb "https://github.com/KiraCore/tools/releases/download/$TOOLS_VERSION/ipfs-api-$(getPlatform)-$(getArch).deb" "QmeqFDLGfwoWgCy2ZEFXerVC5XW8c5xgRyhK5bLArBr2ue" && \
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 && \
ipfs-api version
Expand Down
2 changes: 1 addition & 1 deletion ipfs-api/types/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package types

const (
IpfsApiVersion = "v0.3.46"
IpfsApiVersion = "v0.3.56"

// Pinata v1 constants
BASE_URL = "https://api.pinata.cloud"
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

echo "v0.3.46"
echo "v0.3.56"
241 changes: 241 additions & 0 deletions validator-key-gen/MnemonicsGenerator/mnemonicGenerator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
package mnemonicsgenerator

import (
"crypto/sha256"
"encoding/hex"
"fmt"
"os"
"strings"

valkeygen "github.com/KiraCore/tools/validator-key-gen/ValKeyGen"
"github.com/cosmos/go-bip39"
"github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/p2p"
)

const (
DefaultValidatorNodeKeyFileName string = "validator_node_key.json"
DefaultPrivValidatorKeyFileName string = "priv_validator_key.json"
DefaultValidatorNodeIdFileName string = "validator_node_id.key"

DefaultPrefix string = "kira"
DefaultPath string = "44'/118'/0'/0/0"
)

type MasterMnemonicSet struct {
ValidatorAddrMnemonic []byte
ValidatorValMnemonic []byte
SignerAddrMnemonic []byte
ValidatorNodeMnemonic []byte
ValidatorNodeId []byte
PrivKeyMnemonic []byte
}

// returns nodeId from mnemonic
func generateNodeIdFromMnemonic(mnemonic string) []byte {
if err := valkeygen.CheckMnemonic(mnemonic); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

tmPrivKey := ed25519.GenPrivKeyFromSecret([]byte(mnemonic))
filenodekey := p2p.NodeKey{
PrivKey: tmPrivKey,
}
nodeId := []byte(filenodekey.ID())
return nodeId
}

func createMnemonicsFile(path string, mnemonicData []byte) error {
file, err := os.Create(path)
if err != nil {
fmt.Printf("Error creating %s file: %s", path, err)
return err
}
defer file.Close()
_, err = file.WriteString(string(mnemonicData))
if err != nil {
fmt.Printf("Error creating %s file: %s", path, err)
return err
}
return nil
}

// accepts name and typeOfMnemonic as salt and mnemonic, for example MnemonicGenerator --name="validator" --type="addr" - validator address
func generateFromMasterMnemonic(name, typeOfMnemonic string, masterMnemonic []byte) ([]byte, error) {
stringToHash := strings.ToLower(fmt.Sprintf("%s ; %s %s", masterMnemonic, name, typeOfMnemonic))
stringToHash = strings.ReplaceAll(stringToHash, " ", "")

hasher := sha256.New()
hasher.Write([]byte(stringToHash))
entropyHex := hex.EncodeToString(hasher.Sum(nil))

entropy, err := hex.DecodeString(entropyHex)
if err != nil {
return []byte{}, fmt.Errorf("error decoding hex string: %w", err)
}

mnemonic, err := bip39.NewMnemonic(entropy)
if err != nil {
return []byte{}, fmt.Errorf("error generating mnemonic: %w", err)
}

return []byte(mnemonic), nil
}

// # Generates set of mnemonics from master mnemonic, accepts masterMnemonic string as byte
//
// Default function call MasterKeysGen([]byte("mnemonic string"), "", "", "./path")
//
// 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
//
// # FOR PACKAGE USAGE
//
// defaultPrefix: "kira"
//
// defaultPath: "44'/118'/0'/0/0"
func MasterKeysGen(masterMnemonic []byte, defaultPrefix, defaultPath, masterkeys string) (mnemonicSet MasterMnemonicSet, err error) {
err = valkeygen.CheckMnemonic(string(masterMnemonic))
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}

ok, err := valkeygen.CheckPath([]string{masterkeys})
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Println(ok, masterkeys)
return mnemonicSet, err
}

if ok {
// VALIDATOR_NODE_MNEMONIC
mnemonicSet.ValidatorNodeMnemonic, err = generateFromMasterMnemonic("validator", "node", masterMnemonic)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}

// VALIDATOR_NODE_ID
mnemonicSet.ValidatorNodeId = generateNodeIdFromMnemonic(string(mnemonicSet.ValidatorNodeMnemonic))

// VALIDATOR_ADDR_MNEMONIC
mnemonicSet.ValidatorAddrMnemonic, err = generateFromMasterMnemonic("validator", "addr", masterMnemonic)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}

// VALIDATOR_VAL_MNEMONIC
mnemonicSet.ValidatorValMnemonic, err = generateFromMasterMnemonic("validator", "val", masterMnemonic)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}

// SIGNER_ADDR_MNEMONIC
mnemonicSet.SignerAddrMnemonic, err = generateFromMasterMnemonic("signer", "addr", masterMnemonic)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}

// privKey mnemonic
mnemonicSet.PrivKeyMnemonic, err = DerivePrivKeyMnemonicFromMasterMnemonic(masterMnemonic)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}

if masterkeys != "" {
// validator_node_key.json validator_node_id.key" files
// valkeygen.ValKeyGen(string(mnemonicSet.ValidatorNodeMnemonic), defaultPrefix, defaultPath, "",
// fmt.Sprintf("%s/%s", masterkeys, DefaultValidatorNodeKeyFileName),
// fmt.Sprintf("%s/%s", masterkeys, DefaultValidatorNodeIdFileName),
// false, false, false)
// priv_validator_key.json file
// valkeygen.ValKeyGen(string(mnemonicSet.ValidatorValMnemonic), defaultPrefix, defaultPath, fmt.Sprintf("%s/%s", masterkeys, DefaultPrivValidatorKeyFileName), "", "", false, false, false)

// validator_node_key.json file
err = GenerateValidatorNodeKeyJson(mnemonicSet.ValidatorNodeMnemonic, fmt.Sprintf("%s/%s", masterkeys, DefaultValidatorNodeKeyFileName), defaultPrefix, defaultPath)
if err != nil {
return mnemonicSet, err
}
// validator_node_id.key" file
err = GenerateValidatorNodeIdFile(mnemonicSet.ValidatorNodeMnemonic, fmt.Sprintf("%s/%s", masterkeys, DefaultValidatorNodeIdFileName), defaultPrefix, defaultPath)
if err != nil {
return mnemonicSet, err
}
// priv_validator_key.json file
err = GeneratePrivValidatorKeyJson(mnemonicSet.ValidatorValMnemonic, fmt.Sprintf("%s/%s", masterkeys, DefaultPrivValidatorKeyFileName), defaultPrefix, defaultPath)
if err != nil {
return mnemonicSet, err
}
// mnemonics.env file
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))

err = createMnemonicsFile(fmt.Sprintf("%s/mnemonics.env", masterkeys), dataToWrite)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return mnemonicSet, err
}
dataToWrite = []byte{}

}

}
return mnemonicSet, nil
}

// Accepts parent mnemonic as masterMnemonic and derives from it a PrivKeyMnemonic using generateFromMasterMnemonic func
// salt is name and typeOfMnemonic hardcoded as const
//
// Constants:
// name=priv,
// typeOfMnemonic=key.
func DerivePrivKeyMnemonicFromMasterMnemonic(masterMnemonic []byte) (privKey []byte, err error) {
const name string = "priv"
const typeOfMnemonic string = "key"
err = valkeygen.CheckMnemonic(string(masterMnemonic))
if err != nil {
return nil, err
}
privKey, err = generateFromMasterMnemonic(name, typeOfMnemonic, masterMnemonic)
if err != nil {
return nil, fmt.Errorf("error while generating ")
}
return
}

func GenerateValidatorNodeKeyJson(validatorNodeMnemonic []byte, keyPath, defaultPrefix, defaultPath string) error {
// validator_node_key.json file
err := valkeygen.ValKeyGen(string(validatorNodeMnemonic), defaultPrefix, defaultPath, "",
keyPath,
"",
false, false, false)
if err != nil {
return err
}
return nil
}

func GenerateValidatorNodeIdFile(validatorNodeMnemonic []byte, keyPath, defaultPrefix, defaultPath string) error {
//validator_node_id.key" file
err := valkeygen.ValKeyGen(string(validatorNodeMnemonic), defaultPrefix, defaultPath, "",
"",
keyPath,
false, false, false)
if err != nil {
return err
}
return nil
}

func GeneratePrivValidatorKeyJson(validatorValMnemonic []byte, keyPath, defaultPrefix, defaultPath string) error {
// priv_validator_key.json file
err := valkeygen.ValKeyGen(string(validatorValMnemonic), defaultPrefix, defaultPath, keyPath, "", "", false, false, false)
if err != nil {
return err
}
return nil
}
Loading
Loading