Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion bn254/src/pairing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,37 @@ pub fn alt_bn128_pairing_be(input: &[u8]) -> Result<Vec<u8>, AltBn128Error> {
}

#[deprecated(since = "3.1.0", note = "Please use `alt_bn128_pairing_be` instead")]
#[allow(deprecated)]
#[inline(always)]
pub fn alt_bn128_pairing(input: &[u8]) -> Result<Vec<u8>, AltBn128Error> {
alt_bn128_pairing_be(input)
#[cfg(not(target_os = "solana"))]
{
alt_bn128_versioned_pairing(VersionedPairing::V0, input, Endianness::BE)
}
#[cfg(target_os = "solana")]
{
if input
.len()
.checked_rem(ALT_BN128_PAIRING_ELEMENT_LEN)
.is_none()
{
return Err(AltBn128Error::InvalidInputData);
}
let mut result_buffer = [0u8; 32];
let result = unsafe {
syscalls::sol_alt_bn128_group_op(
ALT_BN128_PAIRING,
input as *const _ as *const u8,
input.len() as u64,
&mut result_buffer as *mut _ as *mut u8,
)
};

match result {
0 => Ok(result_buffer.to_vec()),
_ => Err(AltBn128Error::UnexpectedError),
}
}
}

#[inline(always)]
Expand Down