ab_riscv_benchmarks/
lib.rs1#![cfg_attr(target_env = "abundance", no_std)]
2
3#[cfg(not(target_env = "abundance"))]
4pub mod host_utils;
5
6use ab_blake3::{CHUNK_LEN, OUT_LEN, single_chunk_hash};
7use ab_contracts_macros::contract;
8use ab_core_primitives::ed25519::{Ed25519PublicKey, Ed25519Signature};
9use ab_io_type::trivial_type::TrivialType;
10
11#[derive(Debug, Copy, Clone, TrivialType)]
12#[repr(C)]
13pub struct Benchmarks;
14
15#[contract]
16impl Benchmarks {
17 #[view]
19 pub fn blake3_hash_chunk(#[input] chunk: &[u8; CHUNK_LEN]) -> [u8; OUT_LEN] {
20 single_chunk_hash(chunk).expect("Exactly one chunk; qed")
21 }
22
23 #[view]
25 pub fn ed25519_verify(
26 #[input] public_key: &Ed25519PublicKey,
27 #[input] signature: &Ed25519Signature,
28 #[input] message: &[u8; OUT_LEN],
29 ) -> bool {
30 public_key.verify(signature, message).is_ok()
31 }
32}