# Gohashtree

**URL:** https://collective.flashbots.net/t/gohashtree/4795
**Category:** References
**Tags:** software
**Created:** [March 21, 2025, 3:51pm UTC](https://collective.flashbots.net/t/gohashtree/4795 "2025-03-21T15:51:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![guayabyte](https://collective.flashbots.net/user_avatar/collective.flashbots.net/guayabyte/32/4_2.png) [@guayabyte](https://collective.flashbots.net/u/guayabyte)
#### Post date: [March 21, 2025, 3:51pm UTC](https://collective.flashbots.net/t/gohashtree/4795/1 "2025-03-21T15:51:44Z")

</div>

> **[GitHub - prysmaticlabs/gohashtree: A Golang SHA256 library optimized for Merkle...](https://github.com/prysmaticlabs/gohashtree)**
>
> A Golang SHA256 library optimized for Merkle Trees

# RISC-V support

Status: runs a generic slow implementation

> <https://github.com/prysmaticlabs/gohashtree/issues/24>
>
> Please add support for an efficient implementation on RISC-V :D
> 
> I have been lea…rning about the crypto and vector RISC-V extensions and they look very nice.
> https://fprox.substack.com/p/risc-v-vector-cryptography-extensions
> 
> I found this implementation:
> https://kernel.googlesource.com/pub/scm/linux/kernel/git/wireless/wireless-testing/+/refs/tags/v6.11-rc1/arch/riscv/crypto/sha256-riscv64-zvknha\_or\_zvknhb-zvkb.S
> 
> Can it be used here?
> 
> I don't think there's a board available with these extensions yet. For now I can test and benchmark in qemu and FPGA. 
> 
> What this brings now, in my opinion, is a path towards decentralization in which local collectives, geographically grounded, can become the resilient foundation for the network with very efficient and transparent machines. We can start designing those machines.

---

<div class="post-metadata">

### Author: ![guayabyte](https://collective.flashbots.net/user_avatar/collective.flashbots.net/guayabyte/32/4_2.png) [@guayabyte](https://collective.flashbots.net/u/guayabyte)
#### Post date: [March 21, 2025, 3:58pm UTC](https://collective.flashbots.net/t/gohashtree/4795/2 "2025-03-21T15:58:53Z")

</div>

Install go in AMD64:

```auto
$ wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz

```

As root:

```auto
# rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz

```

Install go in RISC-V64:

```auto
$ wget https://go.dev/dl/go1.24.1.linux-riscv64.tar.gz

```

As root:

```auto
$ rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz

```

* * *

Make the go binary accessible:

```auto
$ export PATH=$PATH:/usr/local/go/bin

```

Get the source code:

```auto
$ git clone https://github.com/prysmaticlabs/gohashtree
$ cd gohashtree

```

Test:

```auto
$ go test .

```

Run the benchmarks in my Intel laptop:

```auto
$ go test . -bench=.
goos: linux
goarch: amd64
pkg: github.com/prysmaticlabs/gohashtree
cpu: 12th Gen Intel(R) Core(TM) i7-1280P
BenchmarkHash_1_minio-20 10918632 109.5 ns/op
BenchmarkHash_1-20 28387708 41.73 ns/op
BenchmarkHash_4_minio-20 2617243 447.8 ns/op
BenchmarkHash_4-20 7394364 160.6 ns/op
BenchmarkHash_8_minio-20 1286012 923.3 ns/op
BenchmarkHash_8-20 3253250 327.9 ns/op
BenchmarkHash_16_minio-20 574353 1862 ns/op
BenchmarkHash_16-20 1780053 651.1 ns/op
BenchmarkHashLargeList_minio-20 42 25348327 ns/op
BenchmarkHashList-20 130 8855663 ns/op
PASS
ok github.com/prysmaticlabs/gohashtree	15.235s

```

Run the tests in a [RISC-V qemu](https://collective.flashbots.net/t/risc-v-cheat-sheet/3820#p-8094-qemu-1):  
(This requires [Run in unsupported architectures by come-maiz · Pull Request #22 · prysmaticlabs/gohashtree · GitHub](https://github.com/prysmaticlabs/gohashtree/pull/22))

```auto
$ sudo apt install --yes qemu-user-static
$ GOARCH=riscv64 go test -v ./... -c -o test.riscv64
$ qemu-riscv64-static test.riscv64 -test.v

```

* * *

Sources:

- [Download and install - The Go Programming Language](https://go.dev/doc/install)
