#svm #sha-256 #hash #solana #no-std #u8

solana-nostd-sha256

A more efficient implementation of Sha256 for SVM

4 releases

0.1.3 Sep 12, 2024
0.1.2 Sep 12, 2024
0.1.1 Sep 12, 2024
0.1.0 Sep 12, 2024

#21 in #svm

Download history 175/week @ 2024-09-08 71/week @ 2024-09-15 9/week @ 2024-09-22 47/week @ 2024-09-29 1/week @ 2024-10-06 8/week @ 2024-10-13 39/week @ 2024-10-20 33/week @ 2024-10-27 33/week @ 2024-11-03 62/week @ 2024-11-10 225/week @ 2024-11-17 262/week @ 2024-11-24 311/week @ 2024-12-01 396/week @ 2024-12-08

1,198 downloads per month
Used in 5 crates (3 directly)

MIT license

5KB
63 lines

Solana NoStd Sha256

A more efficient implementation of Sha256 for SVM.

Installation

cargo add solana-nostd-sha256

Features

  • Adds hash_ref which takes in any type that implements <AsRef<[u8]>>
  • No Hash struct. Returns [u8;32] directly.
  • Makes use of MaybeUninit to skip zero allocations
  • Adds hash_into to let you hash directly into a mutable buffer.

Performance

library function CU cost
nostd-sha256 hashv(&[b"test"]) 100
nostd-sha256 hash(b"test") 105
nostd-sha256 hash_ref("test") 105
solana-program hashv(&[b"test"]) 120
solana-program hash(b"test") 123

Dependencies

~445KB
~10K SLoC