Files
solana/programs/bpf/rust/ristretto/src/lib.rs
mergify[bot] 3955778cb6 Add msg! macro for program logging, deprecate info! macro (#13885)
(cherry picked from commit 6705b5a98c)

Co-authored-by: Michael Vines <mvines@gmail.com>
2020-12-01 06:05:31 +00:00

47 lines
1.0 KiB
Rust

//! @brief Example Rust-based BPF program that performs a ristretto multiply
pub mod ristretto;
use crate::ristretto::ristretto_mul;
use curve25519_dalek::{constants::RISTRETTO_BASEPOINT_POINT, scalar::Scalar};
use solana_program::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, msg, pubkey::Pubkey,
};
fn test_ristretto_mul() -> ProgramResult {
let point = RISTRETTO_BASEPOINT_POINT;
let scalar = Scalar::zero();
let result = ristretto_mul(&point, &scalar)?;
assert_ne!(point, result);
let point = RISTRETTO_BASEPOINT_POINT;
let scalar = Scalar::one();
let result = ristretto_mul(&point, &scalar)?;
assert_eq!(point, result);
Ok(())
}
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> ProgramResult {
msg!("Ristretto multiply");
test_ristretto_mul()?;
Ok(())
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_ristretto() {
test_ristretto_mul().unwrap();
}
}