Giter VIP home page Giter VIP logo

Comments (4)

q9f avatar q9f commented on June 13, 2024 1

Hi there, checking in on the status of this PR (#68), would be very helpful to implement EIP-1271 for Sign-In with Ethereum spruceid/siwe-ruby#15, let me know if there is anything I can do to help!

@w4ll3 I'm tracking EIP-1271 here, let's briefly discuss this. I'm not very familiar with the mechanics of 1271 but will you require full smart-contract support as in ethereum.rb gem? @kurotaky is working on that but it might take a couple of weeks to release this.

It's quite probable that 1271 does only require a subset of the functionality of that PR #68. Could you describe in a few bullet points what the 1271 authentication workflow looks like, so I can take a look? Maybe we can prioritize this specific feature.

from eth.rb.

q9f avatar q9f commented on June 13, 2024

Ref spruceid/siwe-ruby#15

from eth.rb.

w4ll3 avatar w4ll3 commented on June 13, 2024

from eth.rb.

q9f avatar q9f commented on June 13, 2024

Gotcha.

// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8;

library LibBytes {
  function readBytes32(
    bytes memory b,
    uint256 index
  )
    internal
    pure
    returns (bytes32 result)
  {
    index += 32;
    require(b.length >= index);
    assembly {
      result := mload(add(b, index))
    }
    return result;
  }
}

contract Signer {
  using LibBytes for bytes;
  address constant internal OWNER = 0xCaA29806044A08E533963b2e573C1230A2cd9a2d;
  bytes4 constant internal MAGIC_VALUE = 0x1626ba7e;

  function isValidSignature(
    bytes32 _hash,
    bytes calldata _signature
  )
    external
    pure
    returns (bytes4)
  {
    if (recoverSigner(_hash, _signature) == OWNER) {
      return MAGIC_VALUE;
    } else {
      return 0xffffffff;
    }
  }

  function recoverSigner(
    bytes32 _hash,
    bytes memory _signature
  )
    internal
    pure
    returns (address signer)
  {
    require(_signature.length == 65);
    uint8 v = uint8(_signature[64]);
    bytes32 r = _signature.readBytes32(0);
    bytes32 s = _signature.readBytes32(32);
    signer = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash)), v, r, s);
    return signer;
  }
}

from eth.rb.

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.