Skip to content

Commit 3831574

Browse files
committed
Update upstream ethereum-bn128
1 parent 8ac7be0 commit 3831574

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@ authors = ["holgerd77 <[email protected]>",
77
publish = false
88

99
[dependencies]
10-
ethereum-bn128 = { git = "https://github.com/ewasm/ethereum-bn128.rs" }
11-
parity-bytes = { git = "https://github.com/paritytech/parity-common" }
10+
ethereum-bn128 = { git = "https://github.com/ewasm/ethereum-bn128.rs", version = "0.1.0" }
1211
rustc-hex = "1.0"

src/main.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
extern crate ethereum_bn128;
2-
extern crate parity_bytes as bytes;
32
extern crate rustc_hex;
43

54
use std::ffi::CStr;
@@ -8,16 +7,14 @@ use std::os::raw::c_char;
87
use rustc_hex::FromHex;
98
use rustc_hex::ToHex;
109

11-
use bytes::BytesRef;
12-
1310
#[no_mangle]
1411
pub fn ec_mul(input_hex_ptr: *const c_char) -> *const c_char {
1512
let input_hex = unsafe { CStr::from_ptr(input_hex_ptr) };
1613
let input_str: &str = input_hex.to_str().unwrap();
1714
let input_parsed = FromHex::from_hex(input_str).unwrap();
1815

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) {
2118
Ok(_) => {
2219
let mut output_hex = output.to_hex();
2320
output_hex.push_str("\0");
@@ -33,8 +30,8 @@ pub fn ec_add(input_hex_ptr: *const c_char) -> *const c_char {
3330
let input_str: &str = input_hex.to_str().unwrap();
3431
let input_parsed = FromHex::from_hex(input_str).unwrap();
3532

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) {
3835
Ok(_) => {
3936
let mut output_hex = output.to_hex();
4037
output_hex.push_str("\0");
@@ -50,8 +47,8 @@ pub fn ec_pairing(input_hex_ptr: *const c_char) -> *const c_char {
5047
let input_str: &str = input_hex.to_str().unwrap();
5148
let input_parsed = FromHex::from_hex(input_str).unwrap();
5249

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) {
5552
Ok(_) => {
5653
let mut output_hex = output.to_hex();
5754
output_hex.push_str("\0");

0 commit comments

Comments
 (0)