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::bool::Bool;
10use ab_io_type::trivial_type::TrivialType;
11
12#[derive(Debug, Copy, Clone, TrivialType)]
13#[repr(C)]
14pub struct Benchmarks;
15
16#[contract]
17impl Benchmarks {
18 #[view]
20 pub fn blake3_hash_chunk(#[input] chunk: &[u8; CHUNK_LEN]) -> [u8; OUT_LEN] {
21 single_chunk_hash(chunk).expect("Exactly one chunk; qed")
22 }
23
24 #[view]
26 pub fn ed25519_verify(
27 #[input] public_key: &Ed25519PublicKey,
28 #[input] signature: &Ed25519Signature,
29 #[input] message: &[u8; OUT_LEN],
30 ) -> Bool {
31 Bool::new(public_key.verify(signature, message).is_ok())
32 }
33}