Skip to content

Commit

Permalink
Merge branch 'master' into farhad/clarify-HashOp-KeccaK
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhad-Shabani committed Nov 22, 2023
2 parents 819c71f + d583e12 commit 9b441a9
Show file tree
Hide file tree
Showing 31 changed files with 735 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ jobs:
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5.3.0
- uses: amannn/action-semantic-pull-request@v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/proto-register.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.27.2
- uses: bufbuild/buf-setup-action@v1.28.1
- uses: bufbuild/buf-push-action@v1
with:
input: "proto"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.27.2
- uses: bufbuild/buf-setup-action@v1.28.1
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
Expand All @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.27.2
- uses: bufbuild/buf-setup-action@v1.28.1
- uses: bufbuild/buf-breaking-action@v1
with:
input: "proto"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| ------------------ | ------------------------------------------------- | ---------------------------------------------- |
| [Go](./go) | [![Go Test][go-test-badge]][go-test-link] | [![Go Cov][go-cov-badge]][go-cov-link] |
| [Rust](./rust) | [![Rust Test][rust-test-badge]][rust-test-link] | [![Rust Cov][rust-cov-badge]][rust-cov-link] |
| [TypeScript](./ts) | [![TypeScript Test][ts-test-badge]][ts-test-link] | [![TypeScript Cov][ts-cov-badge]][ts-cov-link] |
| [TypeScript](./js) | [![TypeScript Test][ts-test-badge]][ts-test-link] | [![TypeScript Cov][ts-cov-badge]][ts-cov-link] |

[cosmos-link]: https://cosmos.network
[go-test-link]: https://github.com/cosmos/ics23/actions/workflows/go.yml
Expand Down
2 changes: 1 addition & 1 deletion go/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test:
go test .

.PHONY: test
.PHONY: test
##### Linting #####

golangci_lint_cmd=golangci-lint
Expand Down
3 changes: 2 additions & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ go 1.21

require (
github.com/cosmos/gogoproto v1.4.11
golang.org/x/crypto v0.14.0
golang.org/x/crypto v0.15.0
)

require (
github.com/google/go-cmp v0.5.9 // indirect
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb // indirect
golang.org/x/sys v0.14.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)

Expand Down
6 changes: 4 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA=
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
38 changes: 35 additions & 3 deletions go/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
_ "crypto/sha256"
// adds sha512 capability to crypto.SHA512
_ "crypto/sha512"
// adds blake2b capability to crypto.BLAKE2b_512
_ "golang.org/x/crypto/blake2b"
// adds blake2s capability to crypto.BLAKE2s_256
_ "golang.org/x/crypto/blake2s"
// adds ripemd160 capability to crypto.RIPEMD160
_ "golang.org/x/crypto/ripemd160" //nolint:staticcheck
)
Expand Down Expand Up @@ -181,6 +185,22 @@ func doHash(hashOp HashOp, preimage []byte) ([]byte, error) {
return nil, err
}
return shaHash.Sum(nil), nil
case HashOp_BLAKE2B_512:
blakeHash := crypto.BLAKE2b_512.New()
_, err := blakeHash.Write(preimage)
if err != nil {
return nil, err
}
return blakeHash.Sum(nil), nil
case HashOp_BLAKE2S_256:
blakeHash := crypto.BLAKE2s_256.New()
_, err := blakeHash.Write(preimage)
if err != nil {
return nil, err
}
return blakeHash.Sum(nil), nil
// TODO: there doesn't seem to be an "official" implementation of BLAKE3 in Go,
// so we are unable to support it for now
}
return nil, fmt.Errorf("unsupported hashop: %d", hashOp)
}
Expand Down Expand Up @@ -239,16 +259,28 @@ func doLengthOp(lengthOp LengthOp, data []byte) ([]byte, error) {
return nil, fmt.Errorf("data was %d bytes, not 64", len(data))
}
return data, nil
case LengthOp_FIXED32_BIG:
res := make([]byte, 4, 4+len(data))
binary.BigEndian.PutUint32(res[:4], uint32(len(data)))
res = append(res, data...)
return res, nil
case LengthOp_FIXED32_LITTLE:
res := make([]byte, 4, 4+len(data))
binary.LittleEndian.PutUint32(res[:4], uint32(len(data)))
res = append(res, data...)
return res, nil
case LengthOp_FIXED64_BIG:
res := make([]byte, 8, 8+len(data))
binary.BigEndian.PutUint64(res[:8], uint64(len(data)))
res = append(res, data...)
return res, nil
case LengthOp_FIXED64_LITTLE:
res := make([]byte, 8, 8+len(data))
binary.LittleEndian.PutUint64(res[:8], uint64(len(data)))
res = append(res, data...)
return res, nil
// TODO
// case LengthOp_VAR_RLP:
// case LengthOp_FIXED32_BIG:
// case LengthOp_FIXED64_BIG:
// case LengthOp_FIXED64_LITTLE:
}
return nil, fmt.Errorf("unsupported lengthop: %d", lengthOp)
}
Expand Down
170 changes: 90 additions & 80 deletions go/proofs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b441a9

Please sign in to comment.