Add ristretto multiply syscall (#12699)

This commit is contained in:
Jack May
2020-10-06 23:52:13 -07:00
committed by GitHub
parent d0596ce9c8
commit 973f0965e1
12 changed files with 195 additions and 12 deletions

View File

@@ -0,0 +1,31 @@
//! @brief Example Rust-based BPF program that performs a ristretto multiply
pub mod ristretto;
extern crate solana_sdk;
use crate::ristretto::ristretto_mul;
use curve25519_dalek::{constants::RISTRETTO_BASEPOINT_POINT, scalar::Scalar};
use solana_sdk::{
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, info, pubkey::Pubkey,
};
entrypoint!(process_instruction);
fn process_instruction(
_program_id: &Pubkey,
_accounts: &[AccountInfo],
_instruction_data: &[u8],
) -> ProgramResult {
info!("Ristretto multiply");
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(())
}