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