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