Giter Club home page Giter Club logo

Comments (8)

AvishaiW avatar AvishaiW commented on July 22, 2024

@lauraweindorf sorry for the late response.
The verify() function is a private function and cannot be called from the outside. methods from the Erc20Interface trait are the only ones that can be called from the outside, therefore, it wasn't able to decrypt your request.
Hope this helps.

from enigma-core.

secretchaingirl avatar secretchaingirl commented on July 22, 2024

Hi @AvishaiW

I just reviewed his code again. It's calling the private verify() function from his Erc20Interface impl's public function join_game as:

fn join_game(game_id: U256, pub_key: H256, move_2: String, sig: Vec<u8>) {
        let hash = encode(Hash::Keccak256, &move_2.as_bytes()).unwrap();
        assert!(Self::verify(pub_key, hash, sig));

It seems to be the same way it's done in enigma-core/examples/eng_wasm_contracts/erc20/src/lib.rs, where the private verify() function is called from the ContractInferface impl's public function mint as:

 fn mint(owner: H256, addr: H256, tokens: U256, sig: Vec<u8>) {
        // verify the owner is the one who is minting.
        let contract_owner: H256 = read_state!(CONTRACT_OWNER).unwrap();
        assert_eq!(owner, contract_owner);
        assert!(Self::verify(owner, addr, tokens, sig));

In both cases the private function is being called from the trait implementation's public function as Self::verify().

Just checking because he said he copied from the example code?

from enigma-core.

AvishaiW avatar AvishaiW commented on July 22, 2024

Hey @lauraweindorf,
I think I'm still missing some information.
from my understanding and from looking at this repo verify is called from a function from within the SC, which seems to be ok.
Is it possible to get the code which creates the signature which is passed into the secret contract, because the SC itself seems to be fine?
Thanks!

from enigma-core.

secretchaingirl avatar secretchaingirl commented on July 22, 2024

Sorry for the delay, @AvishaiW! I'll see if I can get that info for you. Meanwhile, what do you think of that array definition/initialization:

let mut new_sig: [u8; 65] = [0u8; 65];

instead of:

let mut new_sig: [u8; 65] = [u8; 65];

The former is the way it's setup in this example secret contract:

enigma-core/examples/eng_wasm_contracts/erc20/src/lib.rs

Peter had copied from there and built his code using that as a base. I did notice that when I corrected that statement, his issue was resolved.

Thanks for looking into this!

from enigma-core.

AvishaiW avatar AvishaiW commented on July 22, 2024

That's strange that it fixed his issue. From my understanding that is a sufficient way of writing in rust as you can see here: https://stackoverflow.com/questions/53120755/what-does-0u8-mean-in-rust, what do you say?

from enigma-core.

secretchaingirl avatar secretchaingirl commented on July 22, 2024

oh you're right. I wonder if there's a difference between using that notation with array initialization vs a statement initializing a non-array type?

from enigma-core.

AvishaiW avatar AvishaiW commented on July 22, 2024

Hope this answers your question: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=23563c7e97891df1f37d7925df938481

from enigma-core.

secretchaingirl avatar secretchaingirl commented on July 22, 2024

okay, yeah that answers it. Thanks @AvishaiW!

Do you still want the code that creates the signature which is passed into his secret contract? Or should we just close this issue?

from enigma-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.