#sha-256 #svm #allocation

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

#10 in #svm

Download history 409/week @ 2024-12-09 353/week @ 2024-12-16 338/week @ 2024-12-23 215/week @ 2024-12-30 313/week @ 2025-01-06 335/week @ 2025-01-13 315/week @ 2025-01-20 43/week @ 2025-01-27 191/week @ 2025-02-03 277/week @ 2025-02-10 367/week @ 2025-02-17 231/week @ 2025-02-24 491/week @ 2025-03-03 619/week @ 2025-03-10 307/week @ 2025-03-17 376/week @ 2025-03-24

1,799 downloads per month
Used in 6 crates (4 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

~730KB
~18K SLoC