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

feat(keys): Ed25519VerificationKey2020 full spec compliant & add 2018 support [DEV-2017] #497

Merged
merged 44 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
aadca47
Make VerificationMethod validation as in spec
Dec 30, 2022
2f59e96
Change generated jsons for unit upgrade tests
Dec 30, 2022
bb4e178
Makes linter happy
Dec 30, 2022
826e00f
Makes linter happy
Dec 30, 2022
9d35ffe
Makes linter happy
Dec 30, 2022
1fc2abf
Fix integration tests
Dec 31, 2022
b417a8d
Remove unused imports
Dec 31, 2022
875bbf4
Change comparision check
Dec 31, 2022
924cea9
Add changes for generated files
Dec 31, 2022
83bd84e
Merge branch 'develop' into dev-2017
ankurdotb Jan 3, 2023
59bc677
Merge branch 'develop' into dev-2017
Eengineer1 Jan 3, 2023
ae98ced
Added Ed25519VerificationKey2018 support & enhanced tests
Eengineer1 Jan 4, 2023
4c6f4d2
Fixed namings
Eengineer1 Jan 4, 2023
811dd30
Temp disabled
Eengineer1 Jan 4, 2023
f691d09
Temp disabled
Eengineer1 Jan 4, 2023
44f2955
Fixed deprecated print
Eengineer1 Jan 4, 2023
1984f5f
Removed bloat
Eengineer1 Jan 4, 2023
cd5fb79
Fixed shellcheck
Eengineer1 Jan 5, 2023
f8a2b6c
Fixed bash shellcheck & restored bash linters
Eengineer1 Jan 5, 2023
be9a356
Ignored `sed` extension
Eengineer1 Jan 5, 2023
dc2a343
Fixed widespread namings
Eengineer1 Jan 5, 2023
ba5d5ac
Ignored on legacy
Eengineer1 Jan 5, 2023
3cb2e9e
Update release.yml
ankurdotb Jan 6, 2023
26dd560
Update gen-network-config.sh
ankurdotb Jan 6, 2023
68b3301
Rename pubKeyMultibase to publicKeyMultibase
ankurdotb Jan 6, 2023
fd901a1
Fix SED_EXT shellcheck in legacy tests
ankurdotb Jan 6, 2023
4ef1f1a
Fix SED_EXT setting
ankurdotb Jan 6, 2023
d1a9fe1
Typo fixes
ankurdotb Jan 6, 2023
d37bbd8
Ignore files a bit differently
ankurdotb Jan 6, 2023
3624ffe
Fix lint checks
ankurdotb Jan 6, 2023
23ebbd9
Update .goreleaser.yml
ankurdotb Jan 6, 2023
73f8ba6
Update Dockerfile
ankurdotb Jan 6, 2023
bfe2af1
Update build.yml
ankurdotb Jan 6, 2023
88405b0
Update Golang linter settings
ankurdotb Jan 6, 2023
7aacd77
Remove gosec nolint
ankurdotb Jan 6, 2023
ab6437c
Remove unused comments
ankurdotb Jan 6, 2023
e4f13b5
Add TODO for nolint comments that need to be removed
ankurdotb Jan 6, 2023
9a1dd4b
Update buf.lock
ankurdotb Jan 6, 2023
b2c1b20
buf format
ankurdotb Jan 6, 2023
47500ce
Fix stylecheck
ankurdotb Jan 6, 2023
4640f8e
Fix alpine version
ankurdotb Jan 6, 2023
5421ca6
Update build.yml
ankurdotb Jan 6, 2023
f582931
Work super linter only on diffs
ankurdotb Jan 6, 2023
154d7f1
Lint all codebase on release
ankurdotb Jan 6, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
- name: Set release version number
id: set-version
run: |
RELEASE_VERSION=$( git describe --tags ${{ github.sha }})
echo ::set-output name=RELEASE_VERSION::"$RELEASE_VERSION"
RELEASE_VERSION=$( git describe --tags "${{ github.sha }}")
echo "RELEASE_VERSION=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"

# Push Protobufs to Buf.build registry
- uses: bufbuild/buf-push-action@v1
Expand Down
19 changes: 19 additions & 0 deletions app/migrations/helpers/protobuf.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package helpers

import (
"github.com/multiformats/go-multibase"
)

func GenerateEd25519VerificationKey2020VerificationMaterial(publicKey string) (string, error) {
encoding, publicKeyBytes, err := multibase.Decode(publicKey)
if encoding != multibase.Base58BTC {
panic("Only Base58BTC encoding is supported")
}
if err != nil {
return "", err
}
publicKeyMultibaseBytes := []byte{0xed, 0x01}
ankurdotb marked this conversation as resolved.
Show resolved Hide resolved
publicKeyMultibaseBytes = append(publicKeyMultibaseBytes, publicKeyBytes...)

return multibase.Encode(multibase.Base58BTC, publicKeyMultibaseBytes)
}
19 changes: 19 additions & 0 deletions app/migrations/helpers/protobuf_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package helpers
ankurdotb marked this conversation as resolved.
Show resolved Hide resolved

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = DescribeTable(
"Test GenerateEd25519VerificationKey2020VerificationMaterial",
func(v1PubKey string, v2PubKey string) {
key, err := GenerateEd25519VerificationKey2020VerificationMaterial(v1PubKey)
Expect(err).To(BeNil())
Expect(key).To(Equal(v2PubKey))
},

Entry("Valid: General conversion", "zDw21irq4wBfyTvxAG9L8PQj6b79iyTyzyV6XVj9SfyRR", "z6MksPH4K75WGjASaRnrwiHyEWH6QgRaPMEMfW1TL17TbCCo"),
// Mainnet case
Entry("Valid: Real case", "zF7rhDBfUt9d1gJPjx7s1JXfUY7oVWkYsWCo7fztHtepn", "z6Mkta7joRuvDh7UnoESdgpr9dDUMh5LvdoECDi3WGrJoscA"),
ankurdotb marked this conversation as resolved.
Show resolved Hide resolved
)
21 changes: 4 additions & 17 deletions app/migrations/migration_did_protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func MigrateDidDoc(oldDid *didtypesv1.Did) didtypes.DidDoc {
func MigrateType(t string) string {
switch t {
case didtypesv1.Ed25519VerificationKey2020:
return didtypes.Ed25519VerificationKey2020{}.Type()
return didtypes.Ed25519VerificationKey2020Type
case didtypesv1.JSONWebKey2020:
return didtypes.JSONWebKey2020{}.Type()
return didtypes.JSONWebKey2020Type
default:
panic("Unknown type")
}
Expand All @@ -159,28 +159,15 @@ func MigrateVerificationMaterial(vm *didtypesv1.VerificationMethod) string {
if err != nil {
panic(err)
}

jwk2020 := didtypes.JSONWebKey2020{
PublicKeyJwk: res,
}
res, err = json.Marshal(jwk2020)
if err != nil {
panic(err)
}

return string(res)

case didtypesv1.Ed25519VerificationKey2020:
pkMulti := didtypes.Ed25519VerificationKey2020{
PublicKeyMultibase: vm.PublicKeyMultibase,
}

res, err := json.Marshal(pkMulti)
pkMulti, err := helpers.GenerateEd25519VerificationKey2020VerificationMaterial(vm.PublicKeyMultibase)
if err != nil {
panic(err)
}

return string(res)
return pkMulti

default:
panic("Unknown type")
Expand Down
32 changes: 15 additions & 17 deletions docker/localnet/gen-network-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

set -euo pipefail

# sed in macos requires extra argument
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
SED_EXT=''
elif [[ "$OSTYPE" == "darwin"* ]]; then
SED_EXT='.orig'
# sed in MacOS requires extra argument
if [[ "$OSTYPE" == "darwin"* ]]; then
SED_EXT='.orig'
else
SED_EXT=''
fi

# Params
Expand Down Expand Up @@ -38,16 +38,14 @@ function configure_node() {
APP_TOML="${NODE_HOME}/config/app.toml"
CONFIG_TOML="${NODE_HOME}/config/config.toml"

sed -i $SED_EXT 's/minimum-gas-prices = ""/minimum-gas-prices = "25ncheq"/g' "${APP_TOML}"
sed -i $SED_EXT 's/enable = false/enable = true/g' "${APP_TOML}"

sed -i $SED_EXT 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}"
sed -i $SED_EXT 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}"

sed -i $SED_EXT 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}"
sed -i $SED_EXT 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}"
sed -i $SED_EXT 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}"
sed -i $SED_EXT 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}"
sed -i "$SED_EXT" 's/minimum-gas-prices = ""/minimum-gas-prices = "50ncheq"/g' "${APP_TOML}"
sed -i "$SED_EXT" 's/enable = false/enable = true/g' "${APP_TOML}"
sed -i "$SED_EXT" 's|laddr = "tcp://127.0.0.1:26657"|laddr = "tcp://0.0.0.0:26657"|g' "${CONFIG_TOML}"
sed -i "$SED_EXT" 's|addr_book_strict = true|addr_book_strict = false|g' "${CONFIG_TOML}"
sed -i "$SED_EXT" 's/timeout_propose = "3s"/timeout_propose = "500ms"/g' "${CONFIG_TOML}"
sed -i "$SED_EXT" 's/timeout_prevote = "1s"/timeout_prevote = "500ms"/g' "${CONFIG_TOML}"
sed -i "$SED_EXT" 's/timeout_precommit = "1s"/timeout_precommit = "500ms"/g' "${CONFIG_TOML}"
sed -i "$SED_EXT" 's/timeout_commit = "5s"/timeout_commit = "500ms"/g' "${CONFIG_TOML}"
}

function configure_genesis() {
Expand All @@ -60,10 +58,10 @@ function configure_genesis() {
GENESIS_TMP="${NODE_HOME}/config/genesis_tmp.json"

# Default denom
sed -i $SED_EXT 's/"stake"/"ncheq"/' "${GENESIS}"
sed -i "$SED_EXT" 's/"stake"/"ncheq"/' "${GENESIS}"

# Short voting period
sed -i $SED_EXT 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}"
sed -i "$SED_EXT" 's/"voting_period": "172800s"/"voting_period": "12s"/' "${GENESIS}"

# Test accounts
BASE_ACCOUNT_1="cheqd1rnr5jrt4exl0samwj0yegv99jeskl0hsxmcz96"
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var CLITxParams = []string{
"--yes",
}

var CLIGasParams = []string{
var CliGasParams = []string{
"--gas", Gas,
"--gas-adjustment", GasAdjustment,
"--gas-prices", GasPrices,
Expand Down
Loading