Cleanup constants

This commit is contained in:
Greg Fitzgerald
2018-04-06 15:43:05 -06:00
parent 81e2b36d38
commit 6fd32fe850
2 changed files with 19 additions and 27 deletions

View File

@@ -1,27 +1,8 @@
// Cuda-only imports
#[cfg(feature = "cuda")]
use packet::PACKET_DATA_SIZE;
#[cfg(feature = "cuda")]
use packet::{Packet, SharedPackets};
use transaction::{PUB_KEY_OFFSET, SIGNED_DATA_OFFSET, SIG_OFFSET};
use std::mem::size_of;
// Non-cuda imports
#[cfg(not(feature = "cuda"))]
use rayon::prelude::*;
#[cfg(not(feature = "cuda"))]
use ring::signature;
#[cfg(not(feature = "cuda"))]
use untrusted;
// Shared imports
use packet::{Packet, SharedPackets};
pub const TX_OFFSET: usize = 4;
pub const SIGNED_DATA_OFFSET: usize = 112;
pub const SIG_OFFSET: usize = 8;
pub const PUB_KEY_OFFSET: usize = 80;
pub const SIG_SIZE: usize = 64;
pub const PUB_KEY_SIZE: usize = 32;
#[cfg(feature = "cuda")]
#[repr(C)]
@@ -47,11 +28,15 @@ extern "C" {
#[cfg(not(feature = "cuda"))]
fn verify_packet(packet: &Packet) -> u8 {
use ring::signature;
use untrusted;
use signature::{PublicKey, Signature};
let msg_start = TX_OFFSET + SIGNED_DATA_OFFSET;
let sig_start = TX_OFFSET + SIG_OFFSET;
let sig_end = sig_start + SIG_SIZE;
let sig_end = sig_start + size_of::<Signature>();
let pub_key_start = TX_OFFSET + PUB_KEY_OFFSET;
let pub_key_end = pub_key_start + PUB_KEY_SIZE;
let pub_key_end = pub_key_start + size_of::<PublicKey>();
if packet.meta.size <= msg_start {
return 0;
@@ -68,6 +53,8 @@ fn verify_packet(packet: &Packet) -> u8 {
#[cfg(not(feature = "cuda"))]
pub fn ed25519_verify(batches: &Vec<SharedPackets>) -> Vec<Vec<u8>> {
use rayon::prelude::*;
batches
.into_par_iter()
.map(|p| {
@@ -83,6 +70,8 @@ pub fn ed25519_verify(batches: &Vec<SharedPackets>) -> Vec<Vec<u8>> {
#[cfg(feature = "cuda")]
pub fn ed25519_verify(batches: &Vec<SharedPackets>) -> Vec<Vec<u8>> {
use packet::PACKET_DATA_SIZE;
let mut out = Vec::new();
let mut elems = Vec::new();
let mut locks = Vec::new();