1
1
extern crate ethereum_bn128;
2
- extern crate parity_bytes as bytes;
3
2
extern crate rustc_hex;
4
3
5
4
use std:: ffi:: CStr ;
@@ -8,16 +7,14 @@ use std::os::raw::c_char;
8
7
use rustc_hex:: FromHex ;
9
8
use rustc_hex:: ToHex ;
10
9
11
- use bytes:: BytesRef ;
12
-
13
10
#[ no_mangle]
14
11
pub fn ec_mul ( input_hex_ptr : * const c_char ) -> * const c_char {
15
12
let input_hex = unsafe { CStr :: from_ptr ( input_hex_ptr) } ;
16
13
let input_str: & str = input_hex. to_str ( ) . unwrap ( ) ;
17
14
let input_parsed = FromHex :: from_hex ( input_str) . unwrap ( ) ;
18
15
19
- let mut output = vec ! [ 0u8 ; 64 ] ;
20
- match ethereum_bn128:: bn128_mul ( & input_parsed[ ..] , & mut BytesRef :: Fixed ( & mut output[ .. ] ) ) {
16
+ let mut output = [ 0u8 ; 64 ] ;
17
+ match ethereum_bn128:: bn128_mul ( & input_parsed[ ..] , & mut output) {
21
18
Ok ( _) => {
22
19
let mut output_hex = output. to_hex ( ) ;
23
20
output_hex. push_str ( "\0 " ) ;
@@ -33,8 +30,8 @@ pub fn ec_add(input_hex_ptr: *const c_char) -> *const c_char {
33
30
let input_str: & str = input_hex. to_str ( ) . unwrap ( ) ;
34
31
let input_parsed = FromHex :: from_hex ( input_str) . unwrap ( ) ;
35
32
36
- let mut output = vec ! [ 0u8 ; 64 ] ;
37
- match ethereum_bn128:: bn128_add ( & input_parsed[ ..] , & mut BytesRef :: Fixed ( & mut output[ .. ] ) ) {
33
+ let mut output = [ 0u8 ; 64 ] ;
34
+ match ethereum_bn128:: bn128_add ( & input_parsed[ ..] , & mut output) {
38
35
Ok ( _) => {
39
36
let mut output_hex = output. to_hex ( ) ;
40
37
output_hex. push_str ( "\0 " ) ;
@@ -50,8 +47,8 @@ pub fn ec_pairing(input_hex_ptr: *const c_char) -> *const c_char {
50
47
let input_str: & str = input_hex. to_str ( ) . unwrap ( ) ;
51
48
let input_parsed = FromHex :: from_hex ( input_str) . unwrap ( ) ;
52
49
53
- let mut output = vec ! [ 0u8 ; 32 ] ;
54
- match ethereum_bn128:: bn128_pairing ( & input_parsed[ ..] , & mut BytesRef :: Fixed ( & mut output[ .. ] ) ) {
50
+ let mut output = [ 0u8 ; 32 ] ;
51
+ match ethereum_bn128:: bn128_pairing ( & input_parsed[ ..] , & mut output) {
55
52
Ok ( _) => {
56
53
let mut output_hex = output. to_hex ( ) ;
57
54
output_hex. push_str ( "\0 " ) ;
0 commit comments