-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbn254.go
More file actions
28 lines (22 loc) · 867 Bytes
/
bn254.go
File metadata and controls
28 lines (22 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2025 Erigon Technologies AG.
// SPDX-License-Identifier: Apache-2.0
// Package evmone wraps the evmone precompiles.
package evmone
/*
#cgo CXXFLAGS: -std=c++20
#cgo CXXFLAGS: -I./intx/include
#cgo CXXFLAGS: -I./evmone/include
#cgo CXXFLAGS: -I./evmone/lib/evmone_precompiles
#include "capi.h"
*/
import "C"
import "unsafe"
// EcAdd performs point addition on the elliptic curve alt_bn128.
// See EIP-196: Precompiled contracts for addition and scalar multiplication on the elliptic curve alt_bn128.
// Return true if the addition was successful an false otherwise (an input point was invalid).
func EcAdd(out *[64]byte, x *[64]byte, y *[64]byte) bool {
outData := (*C.uchar)(unsafe.Pointer(&out[0]))
xData := (*C.uchar)(unsafe.Pointer(&x[0]))
yData := (*C.uchar)(unsafe.Pointer(&y[0]))
return C.evmone_capi_ec_add(outData, xData, yData) != 0
}