This commit is contained in:
Martin Ondejka 2023-04-05 23:28:30 +02:00
parent 1e9d4882ce
commit 55df11555c
4 changed files with 14 additions and 17 deletions

View file

@ -2,16 +2,16 @@
# with Go source code. If you know what GOPATH is then you probably # with Go source code. If you know what GOPATH is then you probably
# don't need to bother with make. # don't need to bother with make.
.PHONY: geth android ios evm all test clean .PHONY: geth android ios evm all test clean mina
GOBIN = ./build/bin GOBIN = ./build/bin
GO ?= latest GO ?= latest
GORUN = env GO111MODULE=on go run GORUN = env GO111MODULE=on go run
mina_lib: mina:
cd mina && cargo build --release cd mina && cargo build --release
geth: mina_lib geth: mina
$(GORUN) build/ci.go install ./cmd/geth $(GORUN) build/ci.go install ./cmd/geth
@echo "Done building." @echo "Done building."
@echo "Run \"$(GOBIN)/geth\" to launch geth." @echo "Run \"$(GOBIN)/geth\" to launch geth."

View file

@ -114,7 +114,7 @@ var (
PrecompiledAddressesIstanbul []common.Address PrecompiledAddressesIstanbul []common.Address
PrecompiledAddressesByzantium []common.Address PrecompiledAddressesByzantium []common.Address
PrecompiledAddressesHomestead []common.Address PrecompiledAddressesHomestead []common.Address
PrecompiledAddressesMina []common.Address PrecompiledAddressesMina []common.Address
) )
func init() { func init() {

View file

@ -34,8 +34,8 @@ func (c *MinaPoseidon) Run(input []byte) ([]byte, error) {
calldata := input[4:] calldata := input[4:]
unpacked, err := (abi.Arguments{{ unpacked, err := (abi.Arguments{{
Type: sol_uint8}, // networkId Type: sol_uint8}, // networkId
{Type: sol_bytes32Arr}, // fields {Type: sol_bytes32Arr}, // fields
}).Unpack(calldata) }).Unpack(calldata)
if err != nil { if err != nil {
@ -51,7 +51,7 @@ func (c *MinaPoseidon) Run(input []byte) ([]byte, error) {
output_buffer := [32]byte{} output_buffer := [32]byte{}
if !C.poseidon_hash( if !C.poseidon(
C.uint8_t(networkId), C.uint8_t(networkId),
(*C.uint8_t)(&fields[0][0]), (*C.uint8_t)(&fields[0][0]),
C.uintptr_t(len(fields)), C.uintptr_t(len(fields)),
@ -80,12 +80,12 @@ func (c *MinaSigner) Run(input []byte) ([]byte, error) {
calldata := input[4:] calldata := input[4:]
unpacked, err := (abi.Arguments{ unpacked, err := (abi.Arguments{
{Type: sol_uint8}, // networkId {Type: sol_uint8}, // networkId
{Type: sol_bytes32}, // pubKeyX {Type: sol_bytes32}, // pubKeyX
{Type: sol_bytes32}, // pubKeyY {Type: sol_bytes32}, // pubKeyY
{Type: sol_bytes32}, // signatureRX {Type: sol_bytes32}, // signatureRX
{Type: sol_bytes32}, // signatureS {Type: sol_bytes32}, // signatureS
{Type: sol_bytes32Arr}, // fields {Type: sol_bytes32Arr}, // fields
}).Unpack(calldata) }).Unpack(calldata)
if err != nil { if err != nil {

View file

@ -3,14 +3,13 @@ mod mina;
use std::array::TryFromSliceError; use std::array::TryFromSliceError;
use mina::{Message, NetworkId}; use mina::{Message, NetworkId};
use mina_hasher::Hashable;
use mina_signer::{BaseField, CurvePoint, PubKey, ScalarField, Signature}; use mina_signer::{BaseField, CurvePoint, PubKey, ScalarField, Signature};
use o1_utils::FieldHelpers; use o1_utils::FieldHelpers;
pub const FIELD_SIZE: usize = 32; pub const FIELD_SIZE: usize = 32;
#[no_mangle] #[no_mangle]
pub extern "C" fn poseidon_hash( pub extern "C" fn poseidon(
network_id: u8, network_id: u8,
field_ptr: *const u8, field_ptr: *const u8,
field_len: usize, field_len: usize,
@ -99,8 +98,6 @@ pub extern "C" fn verify(
Err(_) => return false, Err(_) => return false,
}; };
println!("{:?}", msg.to_roinput().to_fields()[0].to_biguint());
let result = mina::verify(&signature, &pubkey, &msg, network_id); let result = mina::verify(&signature, &pubkey, &msg, network_id);
unsafe { *output_ptr = result }; unsafe { *output_ptr = result };