Remove unactivated ristretto syscall (#16727)
This commit is contained in:
@ -1,21 +0,0 @@
|
||||
[package]
|
||||
name = "solana-bpf-rust-ristretto"
|
||||
version = "1.7.0"
|
||||
description = "Solana BPF test program written in Rust"
|
||||
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
|
||||
repository = "https://github.com/solana-labs/solana"
|
||||
license = "Apache-2.0"
|
||||
homepage = "https://solana.com/"
|
||||
documentation = "https://docs.rs/solana-bpf-rust-ristretto"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
curve25519-dalek = "3"
|
||||
getrandom = { version = "0.1.14", features = ["dummy"] }
|
||||
solana-program = { path = "../../../../sdk/program", version = "=1.7.0" }
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
@ -1,46 +0,0 @@
|
||||
//! @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();
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
use curve25519_dalek::{ristretto::RistrettoPoint, scalar::Scalar};
|
||||
use solana_program::program_error::ProgramError;
|
||||
|
||||
/// Multiply a ristretto point with a scalar
|
||||
///
|
||||
/// @param point - Ristretto point
|
||||
/// @param scalar - Scalar to mulitply against
|
||||
/// @return - result of the multiplication
|
||||
#[inline]
|
||||
pub fn ristretto_mul(
|
||||
point: &RistrettoPoint,
|
||||
scalar: &Scalar,
|
||||
) -> Result<RistrettoPoint, ProgramError> {
|
||||
// Perform the calculation inline, calling this from within a program is
|
||||
// not supported
|
||||
#[cfg(not(target_arch = "bpf"))]
|
||||
{
|
||||
Ok(point * scalar)
|
||||
}
|
||||
// Call via a system call to perform the calculation
|
||||
#[cfg(target_arch = "bpf")]
|
||||
{
|
||||
extern "C" {
|
||||
fn sol_ristretto_mul(
|
||||
point_addr: *const u8,
|
||||
scalar_addr: *const u8,
|
||||
result_addr: *mut u8,
|
||||
) -> u64;
|
||||
}
|
||||
|
||||
let mut result = RistrettoPoint::default();
|
||||
let status = unsafe {
|
||||
sol_ristretto_mul(
|
||||
point as *const _ as *const u8,
|
||||
scalar as *const _ as *const u8,
|
||||
&mut result as *const _ as *mut u8,
|
||||
)
|
||||
};
|
||||
match status {
|
||||
solana_program::entrypoint::SUCCESS => Ok(result),
|
||||
_ => Err(status.into()),
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user